Search in sources :

Example 1 with PackageFeatureMojo

use of org.eclipse.tycho.packaging.PackageFeatureMojo in project tycho by eclipse.

the class PackageFeatureMojoTest method testAddMavenDescriptorSetToTrue.

public void testAddMavenDescriptorSetToTrue() throws Exception {
    File basedir = getBasedir("projects/addMavenDescriptor/featureForcedToTrue");
    File platform = new File("src/test/resources/eclipse");
    List<MavenProject> projects = getSortedProjects(basedir, platform);
    MavenProject project = getProject(projects, "featureForcedToTrue");
    MavenSession session = newMavenSession(project, projects);
    // set build qualifier
    lookupMojoWithDefaultConfiguration(project, session, "build-qualifier").execute();
    PackageFeatureMojo mojo = (PackageFeatureMojo) lookupMojo("package-feature", project.getFile());
    setVariableValueToObject(mojo, "project", project);
    setVariableValueToObject(mojo, "session", session);
    mojo.execute();
    ZipFile zip = new ZipFile(new File(basedir, "target/featureForcedToTrue.jar"));
    try {
        ZipEntry entry = zip.getEntry("META-INF/maven");
        assertNotNull("There must be a 'META-INF/maven/' entry in the feature.jar!", entry);
    } finally {
        zip.close();
    }
}
Also used : PackageFeatureMojo(org.eclipse.tycho.packaging.PackageFeatureMojo) MavenSession(org.apache.maven.execution.MavenSession) MavenProject(org.apache.maven.project.MavenProject) ZipFile(java.util.zip.ZipFile) ZipEntry(java.util.zip.ZipEntry) ZipFile(java.util.zip.ZipFile) File(java.io.File)

Example 2 with PackageFeatureMojo

use of org.eclipse.tycho.packaging.PackageFeatureMojo in project tycho by eclipse.

the class PackageFeatureMojoTest method testLicenseFeature.

public void testLicenseFeature() throws Exception {
    File basedir = getBasedir("projects/licenseFeature/feature");
    File platform = new File("src/test/resources/projects/licenseFeature/eclipse");
    List<MavenProject> projects = getSortedProjects(basedir, platform);
    MavenProject project = getProject(projects, "licenseFeature.feature");
    MavenSession session = newMavenSession(project, projects);
    // set build qualifier
    lookupMojoWithDefaultConfiguration(project, session, "build-qualifier").execute();
    PackageFeatureMojo mojo = (PackageFeatureMojo) lookupMojo("package-feature", project.getFile());
    setVariableValueToObject(mojo, "project", project);
    setVariableValueToObject(mojo, "session", session);
    setVariableValueToObject(mojo, "finalName", "feature");
    mojo.execute();
    ZipFile zip = new ZipFile(new File(basedir, "target/feature.jar"));
    try {
        // igorf: input streams are closed by zip.close() at the end, sloppy but should work
        // all bin.includes files from license features are included
        assertNotNull(zip.getEntry("file-license.txt"));
        assertNull(zip.getEntry("file-unlicense.txt"));
        // do not leak build.properties into 'this' feature
        assertNull(zip.getEntry("build.properties"));
        // license feature id/version are stripped off
        Feature feature = Feature.read(zip.getInputStream(zip.getEntry(Feature.FEATURE_XML)));
        assertNull(feature.getLicenseFeature());
        assertNull(feature.getLicenseFeatureVersion());
        assertEquals("http://www.foo.bar", feature.getLicenseURL());
        assertEquals("This is the license", feature.getLicense().trim());
        // feature.properties merged
        Properties p = new Properties();
        p.load(zip.getInputStream(zip.getEntry("feature.properties")));
        assertEquals("test property value", p.getProperty("test"));
        assertEquals("license test property value", p.getProperty("license-test"));
        // when present both in 'this' and license feature, files from 'this' feature are included
        assertEquals("file.txt contents", IOUtil.toString(zip.getInputStream(zip.getEntry("file.txt"))));
    } finally {
        zip.close();
    }
}
Also used : PackageFeatureMojo(org.eclipse.tycho.packaging.PackageFeatureMojo) MavenSession(org.apache.maven.execution.MavenSession) MavenProject(org.apache.maven.project.MavenProject) ZipFile(java.util.zip.ZipFile) Properties(java.util.Properties) ZipFile(java.util.zip.ZipFile) File(java.io.File) Feature(org.eclipse.tycho.model.Feature)

Example 3 with PackageFeatureMojo

use of org.eclipse.tycho.packaging.PackageFeatureMojo in project tycho by eclipse.

the class PackageFeatureMojoTest method testAddMavenDescriptorNotAddedPerDefault.

public void testAddMavenDescriptorNotAddedPerDefault() throws Exception {
    File basedir = getBasedir("projects/addMavenDescriptor/featureDefault/");
    File platform = new File("src/test/resources/eclipse");
    List<MavenProject> projects = getSortedProjects(basedir, platform);
    MavenProject project = getProject(projects, "featureDefault");
    MavenSession session = newMavenSession(project, projects);
    // set build qualifier
    lookupMojoWithDefaultConfiguration(project, session, "build-qualifier").execute();
    PackageFeatureMojo mojo = (PackageFeatureMojo) lookupMojo("package-feature", project.getFile());
    setVariableValueToObject(mojo, "project", project);
    setVariableValueToObject(mojo, "session", session);
    mojo.execute();
    ZipFile zip = new ZipFile(new File(basedir, "target/featureDefault.jar"));
    try {
        ZipEntry entry = zip.getEntry("META-INF/maven");
        assertNull("No 'META-INF/maven/' entry must be in the feature.jar!", entry);
    } finally {
        zip.close();
    }
}
Also used : PackageFeatureMojo(org.eclipse.tycho.packaging.PackageFeatureMojo) MavenSession(org.apache.maven.execution.MavenSession) MavenProject(org.apache.maven.project.MavenProject) ZipFile(java.util.zip.ZipFile) ZipEntry(java.util.zip.ZipEntry) ZipFile(java.util.zip.ZipFile) File(java.io.File)

Aggregations

File (java.io.File)3 ZipFile (java.util.zip.ZipFile)3 MavenSession (org.apache.maven.execution.MavenSession)3 MavenProject (org.apache.maven.project.MavenProject)3 PackageFeatureMojo (org.eclipse.tycho.packaging.PackageFeatureMojo)3 ZipEntry (java.util.zip.ZipEntry)2 Properties (java.util.Properties)1 Feature (org.eclipse.tycho.model.Feature)1