Search in sources :

Example 6 with PluginRef

use of org.eclipse.tycho.model.PluginRef in project tycho by eclipse.

the class AbstractArtifactDependencyWalker method traverseProduct.

protected void traverseProduct(ProductConfiguration product, ArtifactDependencyVisitor visitor, WalkbackPath visited) {
    if (product.useFeatures()) {
        for (FeatureRef ref : product.getFeatures()) {
            traverseFeature(ref, visitor, visited);
        }
    } else {
        for (PluginRef ref : product.getPlugins()) {
            traversePlugin(ref, visitor, visited);
        }
    }
    Set<String> bundles = new HashSet<>();
    for (ArtifactDescriptor artifact : visited.getVisited()) {
        ArtifactKey key = artifact.getKey();
        if (ArtifactType.TYPE_ECLIPSE_PLUGIN.equals(key.getType())) {
            bundles.add(key.getId());
        }
    }
    if (environments != null && product.includeLaunchers()) {
        for (TargetEnvironment environment : environments) {
            String os = environment.getOs();
            String ws = environment.getWs();
            String arch = environment.getArch();
            String id;
            // see http://jira.codehaus.org/browse/MNGECLIPSE-1075
            if (PlatformPropertiesUtils.OS_MACOSX.equals(os) && (PlatformPropertiesUtils.ARCH_X86.equals(arch) || PlatformPropertiesUtils.ARCH_PPC.equals(arch))) {
                id = "org.eclipse.equinox.launcher." + ws + "." + os;
            } else {
                id = "org.eclipse.equinox.launcher." + ws + "." + os + "." + arch;
            }
            if (!bundles.contains(id)) {
                PluginRef ref = new PluginRef("plugin");
                ref.setId(id);
                ref.setOs(os);
                ref.setWs(ws);
                ref.setArch(arch);
                ref.setUnpack(true);
                traversePlugin(ref, visitor, visited);
            }
        }
    }
}
Also used : ArtifactKey(org.eclipse.tycho.ArtifactKey) ArtifactDescriptor(org.eclipse.tycho.ArtifactDescriptor) PluginRef(org.eclipse.tycho.model.PluginRef) FeatureRef(org.eclipse.tycho.model.FeatureRef) TargetEnvironment(org.eclipse.tycho.core.shared.TargetEnvironment) HashSet(java.util.HashSet)

Example 7 with PluginRef

use of org.eclipse.tycho.model.PluginRef in project tycho by eclipse.

the class GeneratePomsMojo method getFeatureFeaturesAndPlugins.

private Set<File> getFeatureFeaturesAndPlugins(File basedir) throws MojoExecutionException {
    try {
        Set<File> result = new LinkedHashSet<>();
        Feature feature = Feature.read(new File(basedir, "feature.xml"));
        for (PluginRef plugin : feature.getPlugins()) {
            addPlugin(result, plugin.getId());
        }
        for (FeatureRef includedFeature : feature.getIncludedFeatures()) {
            addFeature(result, includedFeature.getId());
        }
        for (Feature.RequiresRef require : feature.getRequires()) {
            for (Feature.ImportRef imp : require.getImports()) {
                addPlugin(result, imp.getPlugin());
                addFeature(result, imp.getFeature());
            }
        }
        return result;
    } catch (IOException e) {
        throw new MojoExecutionException("Exception processing feature " + toString(basedir), e);
    } catch (XmlPullParserException e) {
        throw new MojoExecutionException("Exception processing feature " + toString(basedir), e);
    }
}
Also used : LinkedHashSet(java.util.LinkedHashSet) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) PluginRef(org.eclipse.tycho.model.PluginRef) XmlPullParserException(org.codehaus.plexus.util.xml.pull.XmlPullParserException) FeatureRef(org.eclipse.tycho.model.FeatureRef) IOException(java.io.IOException) File(java.io.File) Feature(org.eclipse.tycho.model.Feature)

Example 8 with PluginRef

use of org.eclipse.tycho.model.PluginRef in project tycho by eclipse.

the class WorkspaceTychoOsgiRuntimeLocator method addProduct.

public boolean addProduct(EquinoxRuntimeDescription result, Artifact pom) throws MavenExecutionException {
    ProductConfiguration product;
    try {
        product = ProductConfiguration.read(new File(pom.getFile().getParentFile(), pom.getArtifactId() + ".product"));
    } catch (IOException e) {
        return false;
    }
    // the above fails with IOException if .product file is not available or can't be read
    // we get here only when we have valid product instance
    Set<String> missing = new LinkedHashSet<>();
    for (PluginRef pluginRef : product.getPlugins()) {
        DevBundleInfo bundleInfo = workspaceState.getBundleInfo(pluginRef.getId(), pluginRef.getVersion());
        if (bundleInfo != null) {
            addBundle(result, bundleInfo);
        } else {
            missing.add(pluginRef.toString());
        }
    }
    if (!missing.isEmpty()) {
        throw new MavenExecutionException("Inconsistent m2e-tycho workspace state, missing bundles: " + missing.toString(), (Throwable) null);
    }
    Map<String, BundleConfiguration> bundleConfigurations = product.getPluginConfiguration();
    if (bundleConfigurations != null) {
        for (BundleConfiguration bundleConfiguration : bundleConfigurations.values()) {
            result.addBundleStartLevel(bundleConfiguration.getId(), bundleConfiguration.getStartLevel(), bundleConfiguration.isAutoStart());
        }
    }
    return true;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) MavenExecutionException(org.apache.maven.MavenExecutionException) BundleConfiguration(org.eclipse.tycho.model.BundleConfiguration) ProductConfiguration(org.eclipse.tycho.model.ProductConfiguration) DevBundleInfo(org.eclipse.tycho.dev.DevBundleInfo) PluginRef(org.eclipse.tycho.model.PluginRef) IOException(java.io.IOException) File(java.io.File)

Example 9 with PluginRef

use of org.eclipse.tycho.model.PluginRef in project tycho by eclipse.

the class FeatureXmlTransformerTest method testExpandReferences.

@SuppressWarnings("deprecation")
@Test
public void testExpandReferences() throws Exception {
    subject = new FeatureXmlTransformer(new SilentLog(), new NoopFileLockService());
    Feature feature = Feature.read(new File(TestUtil.getBasedir("projects/featureXmlVersionExpansion/"), "feature.xml"));
    TargetPlatform tp = mock(TargetPlatform.class);
    when(tp.resolveArtifact("eclipse-feature", "org.eclipse.rcp", "4.5.0.qualifier")).thenReturn(rcpFeatureInTP);
    when(tp.resolveArtifact("eclipse-plugin", "org.junit4", "4.8.1.qualifier")).thenReturn(junit4InTP);
    when(tp.getArtifactLocation(junit4InTP)).thenReturn(junit4JarLocation);
    subject.expandReferences(feature, tp);
    assertThat(feature.getIncludedFeatures(), hasItem(feature("org.eclipse.rcp", "4.5.0.v20140918")));
    assertThat(feature.getPlugins(), hasItem(plugin("org.junit4", "4.8.1.v20100302")));
    PluginRef plugin = feature.getPlugins().get(0);
    assertThat(plugin.getId(), is("org.junit4"));
    // 1720 bytes rounded to kiB
    assertThat(plugin.getDownloadSize(), is(1L));
    // 2419 bytes rounded to kiB // TODO shouldn't installSize=downloadSize for unpack=false?
    assertThat(plugin.getInstallSize(), is(2L));
    assertThat(plugin.isUnpack(), is(false));
}
Also used : SilentLog(org.apache.maven.plugin.testing.SilentLog) PluginRef(org.eclipse.tycho.model.PluginRef) NoopFileLockService(org.eclipse.tycho.test.util.NoopFileLockService) TargetPlatform(org.eclipse.tycho.artifacts.TargetPlatform) Feature(org.eclipse.tycho.model.Feature) File(java.io.File) Test(org.junit.Test)

Example 10 with PluginRef

use of org.eclipse.tycho.model.PluginRef in project tycho by eclipse.

the class FeatureXmlTransformer method expandReferences.

/**
 * Replaces references in the feature model with versions from the target platform.
 *
 * @param feature
 *            The feature model to have plug-in and feature references completed.
 */
public Feature expandReferences(Feature feature, TargetPlatform targetPlatform) throws MojoFailureException {
    for (PluginRef pluginRef : feature.getPlugins()) {
        ArtifactKey plugin = resolvePluginReference(targetPlatform, pluginRef);
        pluginRef.setVersion(plugin.getVersion());
        File location = targetPlatform.getArtifactLocation(plugin);
        setDownloadAndInstallSize(pluginRef, location);
    }
    for (FeatureRef featureRef : feature.getIncludedFeatures()) {
        ArtifactKey includedFeature = resolveFeatureReference(targetPlatform, featureRef);
        featureRef.setVersion(includedFeature.getVersion());
    }
    return feature;
}
Also used : ArtifactKey(org.eclipse.tycho.ArtifactKey) PluginRef(org.eclipse.tycho.model.PluginRef) FeatureRef(org.eclipse.tycho.model.FeatureRef) JarFile(java.util.jar.JarFile) File(java.io.File)

Aggregations

PluginRef (org.eclipse.tycho.model.PluginRef)11 FeatureRef (org.eclipse.tycho.model.FeatureRef)7 File (java.io.File)5 ArtifactKey (org.eclipse.tycho.ArtifactKey)3 Feature (org.eclipse.tycho.model.Feature)3 IOException (java.io.IOException)2 LinkedHashSet (java.util.LinkedHashSet)2 ArtifactDescriptor (org.eclipse.tycho.ArtifactDescriptor)2 ProductConfiguration (org.eclipse.tycho.model.ProductConfiguration)2 Test (org.junit.Test)2 HashSet (java.util.HashSet)1 JarFile (java.util.jar.JarFile)1 MavenExecutionException (org.apache.maven.MavenExecutionException)1 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)1 SilentLog (org.apache.maven.plugin.testing.SilentLog)1 XmlPullParserException (org.codehaus.plexus.util.xml.pull.XmlPullParserException)1 ReactorProject (org.eclipse.tycho.ReactorProject)1 TargetPlatform (org.eclipse.tycho.artifacts.TargetPlatform)1 TargetEnvironment (org.eclipse.tycho.core.shared.TargetEnvironment)1 DevBundleInfo (org.eclipse.tycho.dev.DevBundleInfo)1