Search in sources :

Example 1 with ArtifactDependencyVisitor

use of org.eclipse.tycho.core.ArtifactDependencyVisitor in project tycho by eclipse.

the class AbstractArtifactBasedProject method checkForMissingDependencies.

@Override
public void checkForMissingDependencies(MavenProject project) {
    TargetPlatformConfiguration configuration = TychoProjectUtils.getTargetPlatformConfiguration(project);
    // this throws exceptions when dependencies are missing
    getDependencyWalker(project).walk(new ArtifactDependencyVisitor() {
    });
}
Also used : TargetPlatformConfiguration(org.eclipse.tycho.core.TargetPlatformConfiguration) ArtifactDependencyVisitor(org.eclipse.tycho.core.ArtifactDependencyVisitor)

Example 2 with ArtifactDependencyVisitor

use of org.eclipse.tycho.core.ArtifactDependencyVisitor in project tycho by eclipse.

the class OsgiBundleProject method getDependencyWalker.

@Override
public ArtifactDependencyWalker getDependencyWalker(MavenProject project) {
    final DependencyArtifacts artifacts = getDependencyArtifacts(project);
    final List<ClasspathEntry> cp = getClasspath(project);
    return new ArtifactDependencyWalker() {

        @Override
        public void walk(ArtifactDependencyVisitor visitor) {
            for (ClasspathEntry entry : cp) {
                ArtifactDescriptor artifact = artifacts.getArtifact(entry.getArtifactKey());
                ArtifactKey key = artifact.getKey();
                File location = artifact.getLocation();
                ReactorProject project = artifact.getMavenProject();
                String classifier = artifact.getClassifier();
                Set<Object> installableUnits = artifact.getInstallableUnits();
                PluginDescription plugin = new DefaultPluginDescription(key, location, project, classifier, null, installableUnits);
                visitor.visitPlugin(plugin);
            }
        }

        @Override
        public void traverseFeature(File location, Feature feature, ArtifactDependencyVisitor visitor) {
        }

        @Override
        public void traverseUpdateSite(UpdateSite site, ArtifactDependencyVisitor artifactDependencyVisitor) {
        }

        @Override
        public void traverseProduct(ProductConfiguration productConfiguration, ArtifactDependencyVisitor visitor) {
        }
    };
}
Also used : DependencyArtifacts(org.eclipse.tycho.artifacts.DependencyArtifacts) ArtifactKey(org.eclipse.tycho.ArtifactKey) ProductConfiguration(org.eclipse.tycho.model.ProductConfiguration) ReactorProject(org.eclipse.tycho.ReactorProject) ArtifactDependencyWalker(org.eclipse.tycho.core.ArtifactDependencyWalker) Feature(org.eclipse.tycho.model.Feature) ArtifactDependencyVisitor(org.eclipse.tycho.core.ArtifactDependencyVisitor) ArtifactDescriptor(org.eclipse.tycho.ArtifactDescriptor) ClasspathEntry(org.eclipse.tycho.classpath.ClasspathEntry) File(java.io.File) PluginDescription(org.eclipse.tycho.core.PluginDescription) UpdateSite(org.eclipse.tycho.model.UpdateSite)

Example 3 with ArtifactDependencyVisitor

use of org.eclipse.tycho.core.ArtifactDependencyVisitor in project tycho by eclipse.

the class EclipseFeatureProject method newDependencyWalker.

@Override
protected ArtifactDependencyWalker newDependencyWalker(MavenProject project, TargetEnvironment environment) {
    final File location = project.getBasedir();
    final Feature feature = Feature.loadFeature(location);
    return new AbstractArtifactDependencyWalker(getDependencyArtifacts(project, environment), getEnvironments(project, environment)) {

        @Override
        public void walk(ArtifactDependencyVisitor visitor) {
            traverseFeature(location, feature, visitor);
        }
    };
}
Also used : File(java.io.File) Feature(org.eclipse.tycho.model.Feature) ArtifactDependencyVisitor(org.eclipse.tycho.core.ArtifactDependencyVisitor)

Example 4 with ArtifactDependencyVisitor

use of org.eclipse.tycho.core.ArtifactDependencyVisitor in project tycho by eclipse.

the class ProductExportMojo method getBundles.

private Map<String, PluginDescription> getBundles(TargetEnvironment environment) {
    final Map<String, PluginDescription> bundles = new LinkedHashMap<>();
    getDependencyWalker(environment).walk(new ArtifactDependencyVisitor() {

        @Override
        public void visitPlugin(PluginDescription plugin) {
            bundles.put(plugin.getKey().getId(), plugin);
        }
    });
    return bundles;
}
Also used : PluginDescription(org.eclipse.tycho.core.PluginDescription) ArtifactDependencyVisitor(org.eclipse.tycho.core.ArtifactDependencyVisitor) LinkedHashMap(java.util.LinkedHashMap)

Example 5 with ArtifactDependencyVisitor

use of org.eclipse.tycho.core.ArtifactDependencyVisitor in project tycho by eclipse.

the class UpdateSiteMojo method execute.

@Override
public void execute() throws MojoExecutionException, MojoFailureException {
    target.mkdirs();
    try {
        // remove content collected in former builds.
        // Even without clean goal the build result must not assembly out dated content
        FileUtils.cleanDirectory(target);
    } catch (IOException e) {
        throw new MojoFailureException("Unable to delete old update site content: " + target.getAbsolutePath(), e);
    }
    try {
        UpdateSite site = UpdateSite.read(new File(basedir, UpdateSite.SITE_XML));
        UpdateSiteAssembler assembler = new UpdateSiteAssembler(session, target);
        if (inlineArchives) {
            assembler.setArchives(site.getArchives());
        }
        getDependencyWalker().walk(assembler);
        getDependencyWalker().traverseUpdateSite(site, new ArtifactDependencyVisitor() {

            @Override
            public boolean visitFeature(FeatureDescription feature) {
                FeatureRef featureRef = feature.getFeatureRef();
                String id = featureRef.getId();
                ReactorProject otherProject = feature.getMavenProject();
                String version;
                if (otherProject != null) {
                    version = otherProject.getExpandedVersion();
                } else {
                    version = feature.getKey().getVersion();
                }
                String url = UpdateSiteAssembler.FEATURES_DIR + id + "_" + version + ".jar";
                ((SiteFeatureRef) featureRef).setUrl(url);
                featureRef.setVersion(version);
                // don't traverse included features
                return false;
            }
        });
        if (inlineArchives) {
            site.removeArchives();
        }
        File file = new File(target, "site.xml");
        UpdateSite.write(site, file);
        // Copy the associate sites file, if necessary
        if (site.getAssociateSitesUrl() != null) {
            File srcAssociateSitesFile = new File(basedir, site.getAssociateSitesUrl());
            if (srcAssociateSitesFile.exists()) {
                FileUtils.copyFile(srcAssociateSitesFile, new File(target + File.separator + site.getAssociateSitesUrl()));
            }
        }
    } catch (Exception e) {
        throw new MojoExecutionException(e.getMessage(), e);
    }
}
Also used : FeatureDescription(org.eclipse.tycho.core.FeatureDescription) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) MojoFailureException(org.apache.maven.plugin.MojoFailureException) ReactorProject(org.eclipse.tycho.ReactorProject) IOException(java.io.IOException) SiteFeatureRef(org.eclipse.tycho.model.UpdateSite.SiteFeatureRef) FeatureRef(org.eclipse.tycho.model.FeatureRef) ArtifactDependencyVisitor(org.eclipse.tycho.core.ArtifactDependencyVisitor) IOException(java.io.IOException) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) MojoFailureException(org.apache.maven.plugin.MojoFailureException) UpdateSite(org.eclipse.tycho.model.UpdateSite) File(java.io.File)

Aggregations

ArtifactDependencyVisitor (org.eclipse.tycho.core.ArtifactDependencyVisitor)8 File (java.io.File)4 PluginDescription (org.eclipse.tycho.core.PluginDescription)4 ReactorProject (org.eclipse.tycho.ReactorProject)3 FeatureDescription (org.eclipse.tycho.core.FeatureDescription)3 ProductConfiguration (org.eclipse.tycho.model.ProductConfiguration)3 ArtifactDescriptor (org.eclipse.tycho.ArtifactDescriptor)2 DependencyArtifacts (org.eclipse.tycho.artifacts.DependencyArtifacts)2 ArtifactDependencyWalker (org.eclipse.tycho.core.ArtifactDependencyWalker)2 Feature (org.eclipse.tycho.model.Feature)2 FeatureRef (org.eclipse.tycho.model.FeatureRef)2 UpdateSite (org.eclipse.tycho.model.UpdateSite)2 IOException (java.io.IOException)1 ParsePosition (java.text.ParsePosition)1 SimpleDateFormat (java.text.SimpleDateFormat)1 Date (java.util.Date)1 LinkedHashMap (java.util.LinkedHashMap)1 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)1 MojoFailureException (org.apache.maven.plugin.MojoFailureException)1 ArtifactKey (org.eclipse.tycho.ArtifactKey)1