Search in sources :

Example 11 with Feature

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

the class AbstractArtifactDependencyWalker method traverseFeature.

protected void traverseFeature(FeatureRef ref, ArtifactDependencyVisitor visitor, WalkbackPath visited) {
    ArtifactDescriptor artifact = artifacts.getArtifact(ArtifactType.TYPE_ECLIPSE_FEATURE, ref.getId(), ref.getVersion());
    if (artifact != null) {
        if (visited.visited(artifact.getKey())) {
            return;
        }
        visited.enter(artifact);
        try {
            File location = artifact.getLocation();
            Feature feature = Feature.loadFeature(location);
            traverseFeature(location, feature, ref, visitor, visited);
        } finally {
            visited.leave(artifact);
        }
    } else {
        visitor.missingFeature(ref, visited.getWalkback());
    }
}
Also used : ArtifactDescriptor(org.eclipse.tycho.ArtifactDescriptor) File(java.io.File) Feature(org.eclipse.tycho.model.Feature)

Example 12 with Feature

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

the class EclipseModelTest method testDefaultXmlEncoding.

public void testDefaultXmlEncoding() throws Exception {
    // Run the test with -Dfile.encoding=Cp1252 to be sure
    Feature feature = Feature.read(new File("src/test/resources/modelio/feature-default-encoding.xml"));
    Feature.write(feature, new File("target/feature-default-encoding.xml"));
    Document document = XMLParser.parse(new File("target/feature-default-encoding.xml"));
    Element child = document.getChild("/feature/license");
    assertEquals("\u201cI AGREE\u201d", child.getText().trim());
}
Also used : Element(de.pdark.decentxml.Element) Document(de.pdark.decentxml.Document) Feature(org.eclipse.tycho.model.Feature) File(java.io.File)

Example 13 with Feature

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

the class ExpandReleaseVersionTest method test.

@Test
public void test() throws Exception {
    Verifier verifier = getVerifier("/TYCHO0453expandReleaseVersion", false);
    verifier.executeGoal("integration-test");
    verifier.verifyErrorFreeLog();
    File featureXml = new File(verifier.getBasedir(), "feature/target/feature.xml");
    Feature feature = Feature.read(featureXml);
    Assert.assertEquals("1.0.0.1234567890-bundle", feature.getPlugins().get(0).getVersion());
    // TODO included features
    File siteXml = new File(verifier.getBasedir(), "site/target/site/site.xml");
    UpdateSite site = UpdateSite.read(siteXml);
    Assert.assertEquals("1.0.0.1234567890-feature", site.getFeatures().get(0).getVersion());
// TODO .product version expansion
}
Also used : Verifier(org.apache.maven.it.Verifier) File(java.io.File) Feature(org.eclipse.tycho.model.Feature) UpdateSite(org.eclipse.tycho.model.UpdateSite) Test(org.junit.Test) AbstractTychoIntegrationTest(org.eclipse.tycho.test.AbstractTychoIntegrationTest)

Example 14 with Feature

use of org.eclipse.tycho.model.Feature 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 15 with Feature

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

the class PackageFeatureMojo method execute.

@Override
public void execute() throws MojoExecutionException, MojoFailureException {
    outputDirectory.mkdirs();
    Feature feature = Feature.loadFeature(basedir);
    File licenseFeature = licenseFeatureHelper.getLicenseFeature(feature, project);
    updateLicenseProperties(feature, licenseFeature);
    File featureXml = new File(outputDirectory, Feature.FEATURE_XML);
    try {
        expandVersionQualifiers(feature);
        Feature.write(feature, featureXml);
    } catch (IOException e) {
        throw new MojoExecutionException("Error updating feature.xml", e);
    }
    BuildProperties buildProperties = buildPropertiesParser.parse(project.getBasedir());
    checkBinIncludesExist(buildProperties);
    File featureProperties = getFeatureProperties(licenseFeature, buildProperties);
    File outputJar = new File(outputDirectory, finalName + ".jar");
    outputJar.getParentFile().mkdirs();
    MavenArchiver archiver = new MavenArchiver();
    JarArchiver jarArchiver = getJarArchiver();
    archiver.setArchiver(jarArchiver);
    archiver.setOutputFile(outputJar);
    jarArchiver.setDestFile(outputJar);
    try {
        archiver.getArchiver().addFileSet(getManuallyIncludedFiles(buildProperties));
        if (licenseFeature != null) {
            archiver.getArchiver().addArchivedFileSet(licenseFeatureHelper.getLicenseFeatureFileSet(licenseFeature));
        }
        archiver.getArchiver().addFile(featureXml, Feature.FEATURE_XML);
        if (featureProperties != null) {
            archiver.getArchiver().addFile(featureProperties, FEATURE_PROPERTIES);
        }
        if (archive == null) {
            archive = new MavenArchiveConfiguration();
            archive.setAddMavenDescriptor(false);
        }
        archiver.createArchive(session, project, archive);
    } catch (Exception e) {
        throw new MojoExecutionException("Error creating feature package", e);
    }
    project.getArtifact().setFile(outputJar);
    if (deployableFeature) {
        assembleDeployableFeature();
    }
}
Also used : BuildProperties(org.eclipse.tycho.core.shared.BuildProperties) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) MavenArchiver(org.apache.maven.archiver.MavenArchiver) IOException(java.io.IOException) MavenArchiveConfiguration(org.apache.maven.archiver.MavenArchiveConfiguration) Feature(org.eclipse.tycho.model.Feature) ZipFile(java.util.zip.ZipFile) File(java.io.File) JarArchiver(org.codehaus.plexus.archiver.jar.JarArchiver) ComponentLookupException(org.codehaus.plexus.component.repository.exception.ComponentLookupException) IOException(java.io.IOException) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) MojoFailureException(org.apache.maven.plugin.MojoFailureException)

Aggregations

Feature (org.eclipse.tycho.model.Feature)16 File (java.io.File)13 IOException (java.io.IOException)3 ZipFile (java.util.zip.ZipFile)3 PluginRef (org.eclipse.tycho.model.PluginRef)3 Test (org.junit.Test)3 Properties (java.util.Properties)2 Verifier (org.apache.maven.it.Verifier)2 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)2 ArtifactDescriptor (org.eclipse.tycho.ArtifactDescriptor)2 ArtifactKey (org.eclipse.tycho.ArtifactKey)2 ArtifactDependencyVisitor (org.eclipse.tycho.core.ArtifactDependencyVisitor)2 FeatureRef (org.eclipse.tycho.model.FeatureRef)2 UpdateSite (org.eclipse.tycho.model.UpdateSite)2 AbstractTychoIntegrationTest (org.eclipse.tycho.test.AbstractTychoIntegrationTest)2 Document (de.pdark.decentxml.Document)1 Element (de.pdark.decentxml.Element)1 InputStream (java.io.InputStream)1 LinkedHashSet (java.util.LinkedHashSet)1 MavenArchiveConfiguration (org.apache.maven.archiver.MavenArchiveConfiguration)1