use of org.apache.maven.execution.MavenSession 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();
}
}
use of org.apache.maven.execution.MavenSession 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();
}
}
use of org.apache.maven.execution.MavenSession 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();
}
}
use of org.apache.maven.execution.MavenSession in project tycho by eclipse.
the class PackageIUMojoTest method testThatArtifactPayloadIsCorrect.
public void testThatArtifactPayloadIsCorrect() throws Exception {
File basedir = getBasedir("projects/iuWithPayload/");
File platform = new File("src/test/resources/eclipse");
List<MavenProject> projects = getSortedProjects(basedir, platform);
MavenProject project = getProject(projects, "iuWithPayload");
MavenSession session = newMavenSession(project, projects);
// set build qualifier
lookupMojoWithDefaultConfiguration(project, session, "build-qualifier").execute();
PackageIUMojo mojo = (PackageIUMojo) lookupConfiguredMojo(project, "package-iu");
setVariableValueToObject(mojo, "artifactContentFolder", new File(basedir, "src/main/resources").getAbsolutePath());
mojo.execute();
assertThat(getFilesInZip(new File(basedir, "target/iuWithPayload-1.0.0.zip")), hasItem("file.txt"));
}
use of org.apache.maven.execution.MavenSession in project tycho by eclipse.
the class PackageIUMojoTest method testArtifactWithoutPayload.
public void testArtifactWithoutPayload() throws Exception {
File basedir = getBasedir("projects/iuWithoutPayload");
File platform = new File("src/test/resources/eclipse");
List<MavenProject> projects = getSortedProjects(basedir, platform);
MavenProject project = getProject(projects, "iuWithoutPayload");
MavenSession session = newMavenSession(project, projects);
// set build qualifier
lookupMojoWithDefaultConfiguration(project, session, "build-qualifier").execute();
PackageIUMojo mojo = (PackageIUMojo) lookupConfiguredMojo(project, "package-iu");
mojo.execute();
IU iu = IU.loadIU(new File(basedir, "target"));
Element artifact = iu.getSelfArtifact();
assertThat(artifact, nullValue());
assertThat(new File(basedir, "target/iuWithoutPayload-1.0.0.zip").exists(), is(true));
}
Aggregations