Search in sources :

Example 1 with PluginRef

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

the class EclipseModelTest method testFeature.

public void testFeature() throws Exception {
    Feature feature = Feature.read(new File("src/test/resources/modelio/feature.xml"));
    assertEquals("1.0.0", feature.getVersion());
    List<PluginRef> plugins = feature.getPlugins();
    assertEquals(1, plugins.size());
    assertEquals("pluginA", plugins.get(0).getId());
    List<FeatureRef> features = feature.getIncludedFeatures();
    assertEquals(1, features.size());
    List<Feature.RequiresRef> requires = feature.getRequires();
    assertEquals(1, requires.size());
    assertEquals("pluginB", requires.get(0).getImports().get(0).getPlugin());
    assertEquals("featureC", requires.get(0).getImports().get(1).getFeature());
    // not structural data - getters
    assertEquals("featureA", feature.getLabel());
    assertEquals("COMPANY", feature.getProvider());
    assertEquals("Test License", feature.getLicense().trim());
    assertEquals("http://www.example.com/license", feature.getLicenseURL());
    assertEquals(null, feature.getCopyrightURL());
    assertEquals(null, feature.getCopyright());
    feature.setVersion("1.2.3");
    plugins.get(0).setVersion("3.4.5");
    // not structural data - setters
    feature.setLabel("featureA_MODIFIED");
    feature.setProvider("COMPANY_MODIFIED");
    feature.setLicense("Test License MODIFIED");
    feature.setLicenseURL("http://www.example.com/license_MODIFIED");
    feature.setCopyright("Test Copyright");
    feature.setCopyrightURL("http://www.example.com/copyright");
    File updatedFile = new File(target, "feature.xml");
    Feature.write(feature, updatedFile);
    Feature updated = Feature.read(updatedFile);
    assertEquals("1.2.3", updated.getVersion());
    assertEquals("3.4.5", updated.getPlugins().get(0).getVersion());
    // not structural data - persistence
    assertEquals("featureA_MODIFIED", feature.getLabel());
    assertEquals("COMPANY_MODIFIED", feature.getProvider());
    assertEquals("Test License MODIFIED", feature.getLicense());
    assertEquals("http://www.example.com/license_MODIFIED", feature.getLicenseURL());
    assertEquals("http://www.example.com/copyright", feature.getCopyrightURL());
    assertEquals("Test Copyright", feature.getCopyright());
}
Also used : PluginRef(org.eclipse.tycho.model.PluginRef) FeatureRef(org.eclipse.tycho.model.FeatureRef) Feature(org.eclipse.tycho.model.Feature) File(java.io.File)

Example 2 with PluginRef

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

the class ProductConfigurationTest method testProductConfigurationParse.

@Test
public void testProductConfigurationParse() throws Exception {
    ProductConfiguration config = ProductConfiguration.read(getClass().getResourceAsStream("/product/MyFirstRCP.product"));
    Assert.assertEquals("My First RCP", config.getName());
    Assert.assertEquals("MyFirstRCP.product1", config.getProduct());
    Assert.assertEquals("MyFirstRCP.application", config.getApplication());
    Assert.assertEquals(false, config.useFeatures());
    /*
         * ConfigIni configIni = config.getConfigIni(); Assert.assertNotNull(configIni);
         * Assert.assertEquals("linux.ini", configIni.getLinuxIcon());
         * Assert.assertEquals("macosx.ini", configIni.getMacosxIcon());
         * Assert.assertEquals("solaris.ini", configIni.getSolarisIcon());
         * Assert.assertEquals("win32.ini", configIni.getWin32());
         * 
         * LauncherArguments launcherArgs = config.getLauncherArgs();
         * Assert.assertNotNull(launcherArgs); Assert.assertEquals("-all args",
         * launcherArgs.getProgramArgs()); Assert.assertEquals("-linux args",
         * launcherArgs.getProgramArgsLin()); Assert.assertEquals("-mac args",
         * launcherArgs.getProgramArgsMac()); Assert.assertEquals("-solaris args",
         * launcherArgs.getProgramArgsSol()); Assert.assertEquals("-win32 args",
         * launcherArgs.getProgramArgsWin()); Assert.assertEquals("-all vm",
         * launcherArgs.getVmArgs()); Assert.assertEquals("-linux vm", launcherArgs.getVmArgsLin());
         * Assert.assertEquals("-mac vm", launcherArgs.getVmArgsMac());
         * Assert.assertEquals("-solaris vm", launcherArgs.getVmArgsSol());
         * Assert.assertEquals("-win32 vm", launcherArgs.getVmArgsWin());
         */
    Launcher launcher = config.getLauncher();
    Assert.assertNotNull(launcher);
    Assert.assertEquals("launchername", launcher.getName());
    Assert.assertEquals("XPM", launcher.getLinuxIcon().get(Launcher.ICON_LINUX));
    Assert.assertEquals("icns", launcher.getMacosxIcon().get(Launcher.ICON_MAC));
    Assert.assertEquals("large", launcher.getSolarisIcon().get(Launcher.ICON_SOLARIS_LARGE));
    Assert.assertEquals("medium", launcher.getSolarisIcon().get(Launcher.ICON_SOLARIS_MEDIUM));
    Assert.assertEquals("small", launcher.getSolarisIcon().get(Launcher.ICON_SOLARIS_SMALL));
    Assert.assertEquals("tiny", launcher.getSolarisIcon().get(Launcher.ICON_SOLARIS_TINY));
    Assert.assertEquals(false, launcher.getWindowsUseIco());
    // Assert.assertEquals("iconon", launcher.getWindowsIcon().getIco().getPath());
    Assert.assertEquals("16-32", launcher.getWindowsIcon().get(Launcher.ICON_WINDOWS_SMALL_HIGH));
    Assert.assertEquals("16-8", launcher.getWindowsIcon().get(Launcher.ICON_WINDOWS_SMALL_LOW));
    Assert.assertEquals("32-32", launcher.getWindowsIcon().get(Launcher.ICON_WINDOWS_MEDIUM_HIGH));
    Assert.assertEquals("32-8", launcher.getWindowsIcon().get(Launcher.ICON_WINDOWS_MEDIUM_LOW));
    Assert.assertEquals("48-32", launcher.getWindowsIcon().get(Launcher.ICON_WINDOWS_LARGE_HIGH));
    Assert.assertEquals("48-8", launcher.getWindowsIcon().get(Launcher.ICON_WINDOWS_LARGE_LOW));
    Assert.assertEquals("256-32", launcher.getWindowsIcon().get(Launcher.ICON_WINDOWS_EXTRA_LARGE_HIGH));
    List<PluginRef> plugins = config.getPlugins();
    Assert.assertNotNull(plugins);
    Assert.assertEquals(2, plugins.size());
    PluginRef plugin = plugins.get(0);
    Assert.assertNotNull(plugin);
    Assert.assertEquals("HeadlessProduct", plugin.getId());
    Assert.assertNull(plugin.getVersion());
    List<FeatureRef> features = config.getFeatures();
    Assert.assertNotNull(features);
    Assert.assertEquals(2, features.size());
    FeatureRef feature = features.get(0);
    Assert.assertNotNull(feature);
    Assert.assertEquals("HeadlessFeature", feature.getId());
    Assert.assertEquals("1.0.0", feature.getVersion());
}
Also used : ProductConfiguration(org.eclipse.tycho.model.ProductConfiguration) PluginRef(org.eclipse.tycho.model.PluginRef) Launcher(org.eclipse.tycho.model.Launcher) FeatureRef(org.eclipse.tycho.model.FeatureRef) Test(org.junit.Test)

Example 3 with PluginRef

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

the class FeatureXmlManipulator method changeIncludedPlugins.

private void changeIncludedPlugins(PomVersionChange change, Feature feature) {
    for (PluginRef plugin : feature.getPlugins()) {
        if (change.getArtifactId().equals(plugin.getId()) && change.getVersion().equals(plugin.getVersion())) {
            logger.info("  feature.xml//feature/plugin/@id='" + plugin.getId() + "'/@version: " + change.getVersion() + " => " + change.getNewVersion());
            plugin.setVersion(change.getNewVersion());
        }
    }
}
Also used : PluginRef(org.eclipse.tycho.model.PluginRef)

Example 4 with PluginRef

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

the class ProductFileManipulator method applyChangeToProduct.

protected void applyChangeToProduct(ProjectMetadata project, ProductConfiguration product, String productFileName, PomVersionChange change) {
    if (isSameProject(project, change.getProject())) {
        // in eclipse-repository, change.getArtifactId() doesn't have to match product.getId()
        if (change.getVersion().equals(product.getVersion())) {
            logger.info("  " + productFileName + "//product/@version: " + change.getVersion() + " => " + change.getNewVersion());
            product.setVersion(change.getNewVersion());
        }
    } else if (isBundle(change.getProject())) {
        for (PluginRef plugin : product.getPlugins()) {
            if (change.getArtifactId().equals(plugin.getId()) && change.getVersion().equals(plugin.getVersion())) {
                logger.info("  " + productFileName + "//product/plugins/plugin/@id=" + plugin.getId() + "/@version: " + change.getVersion() + " => " + change.getNewVersion());
                plugin.setVersion(change.getNewVersion());
            }
        }
    } else if (isFeature(change.getProject().getPackaging())) {
        for (FeatureRef feature : product.getFeatures()) {
            if (change.getArtifactId().equals(feature.getId()) && change.getVersion().equals(feature.getVersion())) {
                logger.info("  " + productFileName + "//product/features/feature/@id=" + feature.getId() + "/@version: " + change.getVersion() + " => " + change.getNewVersion());
                feature.setVersion(change.getNewVersion());
            }
        }
    }
}
Also used : PluginRef(org.eclipse.tycho.model.PluginRef) FeatureRef(org.eclipse.tycho.model.FeatureRef)

Example 5 with PluginRef

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

the class AbstractArtifactDependencyWalker method traverseFeature.

protected void traverseFeature(File location, Feature feature, FeatureRef featureRef, ArtifactDependencyVisitor visitor, WalkbackPath visited) {
    ArtifactDescriptor artifact = getArtifact(location, feature.getId());
    if (artifact == null) {
        // ah?
        throw new IllegalStateException("Feature " + location + " with id " + feature.getId() + " is not part of the project build target platform");
    }
    ArtifactKey key = artifact.getKey();
    ReactorProject project = artifact.getMavenProject();
    String classifier = artifact.getClassifier();
    Set<Object> installableUnits = artifact.getInstallableUnits();
    DefaultFeatureDescription description = new DefaultFeatureDescription(key, location, project, classifier, feature, featureRef, installableUnits);
    if (visitor.visitFeature(description)) {
        for (PluginRef ref : feature.getPlugins()) {
            traversePlugin(ref, visitor, visited);
        }
        for (FeatureRef ref : feature.getIncludedFeatures()) {
            traverseFeature(ref, visitor, visited);
        }
    }
}
Also used : ArtifactKey(org.eclipse.tycho.ArtifactKey) ArtifactDescriptor(org.eclipse.tycho.ArtifactDescriptor) ReactorProject(org.eclipse.tycho.ReactorProject) PluginRef(org.eclipse.tycho.model.PluginRef) FeatureRef(org.eclipse.tycho.model.FeatureRef)

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