Search in sources :

Example 1 with PluginDescription

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

the class AbstractArtifactDependencyWalker method traversePlugin.

private void traversePlugin(PluginRef ref, ArtifactDependencyVisitor visitor, WalkbackPath visited) {
    if (!matchTargetEnvironment(ref)) {
        return;
    }
    ArtifactDescriptor artifact = artifacts.getArtifact(ArtifactType.TYPE_ECLIPSE_PLUGIN, ref.getId(), ref.getVersion());
    if (artifact != null) {
        ArtifactKey key = artifact.getKey();
        if (visited.visited(key)) {
            return;
        }
        File location = artifact.getLocation();
        ReactorProject project = artifact.getMavenProject();
        String classifier = artifact.getClassifier();
        Set<Object> installableUnits = artifact.getInstallableUnits();
        PluginDescription description = new DefaultPluginDescription(key, location, project, classifier, ref, installableUnits);
        visited.enter(description);
        try {
            visitor.visitPlugin(description);
        } finally {
            visited.leave(description);
        }
    } else {
        visitor.missingPlugin(ref, visited.getWalkback());
    }
}
Also used : ArtifactKey(org.eclipse.tycho.ArtifactKey) ArtifactDescriptor(org.eclipse.tycho.ArtifactDescriptor) ReactorProject(org.eclipse.tycho.ReactorProject) File(java.io.File) PluginDescription(org.eclipse.tycho.core.PluginDescription)

Example 2 with PluginDescription

use of org.eclipse.tycho.core.PluginDescription 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 PluginDescription

use of org.eclipse.tycho.core.PluginDescription 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 4 with PluginDescription

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

the class ArtifactDependencyWalkerTest method walkProduct.

protected void walkProduct(String productFile, final ArrayList<PluginDescription> plugins, final ArrayList<FeatureDescription> features) throws Exception, IOException, XmlPullParserException {
    DependencyArtifacts platform = getTargetPlatform();
    final ProductConfiguration product = ProductConfiguration.read(new File(productFile));
    ArtifactDependencyWalker walker = new AbstractArtifactDependencyWalker(platform) {

        @Override
        public void walk(ArtifactDependencyVisitor visitor) {
            traverseProduct(product, visitor);
        }
    };
    walker.walk(new ArtifactDependencyVisitor() {

        @Override
        public void visitPlugin(PluginDescription plugin) {
            plugins.add(plugin);
        }

        @Override
        public boolean visitFeature(FeatureDescription feature) {
            features.add(feature);
            return true;
        }
    });
}
Also used : AbstractArtifactDependencyWalker(org.eclipse.tycho.core.osgitools.AbstractArtifactDependencyWalker) DependencyArtifacts(org.eclipse.tycho.artifacts.DependencyArtifacts) ProductConfiguration(org.eclipse.tycho.model.ProductConfiguration) FeatureDescription(org.eclipse.tycho.core.FeatureDescription) AbstractArtifactDependencyWalker(org.eclipse.tycho.core.osgitools.AbstractArtifactDependencyWalker) ArtifactDependencyWalker(org.eclipse.tycho.core.ArtifactDependencyWalker) File(java.io.File) PluginDescription(org.eclipse.tycho.core.PluginDescription) ArtifactDependencyVisitor(org.eclipse.tycho.core.ArtifactDependencyVisitor)

Example 5 with PluginDescription

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

the class ProductExportMojo method generateOSGiBundles.

private void generateOSGiBundles(Properties props, TargetEnvironment environment) throws MojoFailureException {
    Map<String, BundleConfiguration> bundlesToStart = productConfiguration.getPluginConfiguration();
    if (bundlesToStart == null) {
        bundlesToStart = new HashMap<>();
        // This is the wellknown set of bundles for Eclipse based application for 3.3 and 3.4 without p2
        // 
        bundlesToStart.put(// 
        "org.eclipse.equinox.common", new BundleConfiguration("org.eclipse.equinox.common", 2, true));
        // 
        bundlesToStart.put(// 
        "org.eclipse.core.runtime", new BundleConfiguration("org.eclipse.core.runtime", -1, true));
    }
    Map<String, PluginDescription> bundles = new LinkedHashMap<>(getBundles(environment));
    StringBuilder osgiBundles = new StringBuilder();
    for (PluginDescription plugin : bundles.values()) {
        String bundleId = plugin.getKey().getId();
        // starts
        if ("org.eclipse.osgi".equals(bundleId)) {
            continue;
        }
        if (osgiBundles.length() > 0) {
            osgiBundles.append(',');
        }
        osgiBundles.append(bundleId);
        BundleConfiguration startup = bundlesToStart.get(bundleId);
        if (startup != null) {
            osgiBundles.append('@');
            if (startup.getStartLevel() > 0) {
                osgiBundles.append(startup.getStartLevel());
            }
            if (startup.isAutoStart()) {
                if (startup.getStartLevel() > 0) {
                    osgiBundles.append(':');
                }
                osgiBundles.append("start");
            }
        }
    }
    setPropertyIfNotNull(props, "osgi.bundles", osgiBundles.toString());
}
Also used : BundleConfiguration(org.eclipse.tycho.model.BundleConfiguration) PluginDescription(org.eclipse.tycho.core.PluginDescription) LinkedHashMap(java.util.LinkedHashMap)

Aggregations

PluginDescription (org.eclipse.tycho.core.PluginDescription)6 ArtifactDependencyVisitor (org.eclipse.tycho.core.ArtifactDependencyVisitor)4 File (java.io.File)3 ArtifactDescriptor (org.eclipse.tycho.ArtifactDescriptor)3 ReactorProject (org.eclipse.tycho.ReactorProject)3 LinkedHashMap (java.util.LinkedHashMap)2 ArtifactKey (org.eclipse.tycho.ArtifactKey)2 DependencyArtifacts (org.eclipse.tycho.artifacts.DependencyArtifacts)2 ArtifactDependencyWalker (org.eclipse.tycho.core.ArtifactDependencyWalker)2 FeatureDescription (org.eclipse.tycho.core.FeatureDescription)2 ProductConfiguration (org.eclipse.tycho.model.ProductConfiguration)2 ParsePosition (java.text.ParsePosition)1 SimpleDateFormat (java.text.SimpleDateFormat)1 Date (java.util.Date)1 ClasspathEntry (org.eclipse.tycho.classpath.ClasspathEntry)1 TychoProject (org.eclipse.tycho.core.TychoProject)1 AbstractArtifactDependencyWalker (org.eclipse.tycho.core.osgitools.AbstractArtifactDependencyWalker)1 DefaultReactorProject (org.eclipse.tycho.core.osgitools.DefaultReactorProject)1 BundleConfiguration (org.eclipse.tycho.model.BundleConfiguration)1 Feature (org.eclipse.tycho.model.Feature)1