diff --git a/tycho-build/src/main/java/org/eclipse/tycho/build/TychoGraphBuilder.java b/tycho-build/src/main/java/org/eclipse/tycho/build/TychoGraphBuilder.java index 02c41a54ea..b73786adca 100644 --- a/tycho-build/src/main/java/org/eclipse/tycho/build/TychoGraphBuilder.java +++ b/tycho-build/src/main/java/org/eclipse/tycho/build/TychoGraphBuilder.java @@ -195,19 +195,20 @@ public Result build(MavenSession session) { while (!queue.isEmpty()) { ProjectRequest projectRequest = queue.poll(); if (selectedProjects.add(projectRequest.mavenProject)) { - if (projectRequest.requestDownstream) { + if (projectRequest.requestUpstream) { Collection depends = projectDependenciesMap .getOrDefault(projectRequest.mavenProject, Collections.emptyList()); depends.stream()// .map(iuProjectMap::get)// .filter(Objects::nonNull)// .distinct()// - .peek(project -> loggerAdapter.debug(" + add downstream project '" + project.getName() + .peek(project -> loggerAdapter.debug(" + add upstream project '" + project.getName() + "' of project '" + projectRequest.mavenProject.getName() + "'..."))// + // make behaviors are both false here as projectDependenciesMap includes transitive already .forEach( - project -> queue.add(new ProjectRequest(project, true, false, projectRequest))); + project -> queue.add(new ProjectRequest(project, false, false, projectRequest))); } - if (projectRequest.requestUpstream) { + if (projectRequest.requestDownstream) { projectDependenciesMap.entrySet().stream()// .filter(entry -> { return entry.getValue().stream()// @@ -217,10 +218,11 @@ public Result build(MavenSession session) { })// .map(Entry::getKey)// .distinct()// - .peek(project -> loggerAdapter.debug(" + add upstream project '" + project.getName() + .peek(project -> loggerAdapter.debug(" + add downstream project '" + project.getName() + "' of project '" + projectRequest.mavenProject.getName() + "'..."))// + // make behaviors are both false here as projectDependenciesMap includes transitive already .forEach( - project -> queue.add(new ProjectRequest(project, true, false, projectRequest))); + project -> queue.add(new ProjectRequest(project, false, false, projectRequest))); } } } @@ -361,6 +363,12 @@ private static final class ProjectRequest { boolean matches(MavenProject mavenproject) { return this.mavenProject == mavenproject; } + + @Override + public String toString() { + return "ProjectRequest [mavenProject=" + mavenProject + ", parent=" + parent + ", requestDownstream=" + + requestDownstream + ", requestUpstream=" + requestUpstream + "]"; + } } } diff --git a/tycho-its/projects/reactor.makeBehaviour/.mvn/extensions.xml b/tycho-its/projects/reactor.makeBehaviour/.mvn/extensions.xml new file mode 100644 index 0000000000..805692fd8b --- /dev/null +++ b/tycho-its/projects/reactor.makeBehaviour/.mvn/extensions.xml @@ -0,0 +1,10 @@ + + + + org.eclipse.tycho + tycho-build + + 2.7.0-SNAPSHOT + + diff --git a/tycho-its/projects/reactor.makeBehaviour/bundle1/META-INF/MANIFEST.MF b/tycho-its/projects/reactor.makeBehaviour/bundle1/META-INF/MANIFEST.MF new file mode 100644 index 0000000000..a28cb03e22 --- /dev/null +++ b/tycho-its/projects/reactor.makeBehaviour/bundle1/META-INF/MANIFEST.MF @@ -0,0 +1,6 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: Bundle 1 +Bundle-SymbolicName: bundle1;singleton:=true +Bundle-Version: 1.0.0.qualifier +Bundle-RequiredExecutionEnvironment: J2SE-1.5 diff --git a/tycho-its/projects/reactor.makeBehaviour/bundle1/build.properties b/tycho-its/projects/reactor.makeBehaviour/bundle1/build.properties new file mode 100644 index 0000000000..34d2e4d2da --- /dev/null +++ b/tycho-its/projects/reactor.makeBehaviour/bundle1/build.properties @@ -0,0 +1,4 @@ +source.. = src/ +output.. = bin/ +bin.includes = META-INF/,\ + . diff --git a/tycho-its/projects/reactor.makeBehaviour/bundle1/pom.xml b/tycho-its/projects/reactor.makeBehaviour/bundle1/pom.xml new file mode 100644 index 0000000000..79fd84744b --- /dev/null +++ b/tycho-its/projects/reactor.makeBehaviour/bundle1/pom.xml @@ -0,0 +1,16 @@ + + + 4.0.0 + + 1.0.0-SNAPSHOT + bundle1 + eclipse-plugin + + + tycho-its-project.reactor.makeBehaviour + parent + 1.0.0-SNAPSHOT + + + diff --git a/tycho-its/projects/reactor.makeBehaviour/bundle2/META-INF/MANIFEST.MF b/tycho-its/projects/reactor.makeBehaviour/bundle2/META-INF/MANIFEST.MF new file mode 100644 index 0000000000..563adff3db --- /dev/null +++ b/tycho-its/projects/reactor.makeBehaviour/bundle2/META-INF/MANIFEST.MF @@ -0,0 +1,6 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: Bundle 2 +Bundle-SymbolicName: bundle2;singleton:=true +Bundle-Version: 1.0.0.qualifier +Bundle-RequiredExecutionEnvironment: J2SE-1.5 diff --git a/tycho-its/projects/reactor.makeBehaviour/bundle2/build.properties b/tycho-its/projects/reactor.makeBehaviour/bundle2/build.properties new file mode 100644 index 0000000000..34d2e4d2da --- /dev/null +++ b/tycho-its/projects/reactor.makeBehaviour/bundle2/build.properties @@ -0,0 +1,4 @@ +source.. = src/ +output.. = bin/ +bin.includes = META-INF/,\ + . diff --git a/tycho-its/projects/reactor.makeBehaviour/bundle2/pom.xml b/tycho-its/projects/reactor.makeBehaviour/bundle2/pom.xml new file mode 100644 index 0000000000..3e99463cfd --- /dev/null +++ b/tycho-its/projects/reactor.makeBehaviour/bundle2/pom.xml @@ -0,0 +1,16 @@ + + + 4.0.0 + + 1.0.0-SNAPSHOT + bundle2 + eclipse-plugin + + + tycho-its-project.reactor.makeBehaviour + parent + 1.0.0-SNAPSHOT + + + diff --git a/tycho-its/projects/reactor.makeBehaviour/feature1/build.properties b/tycho-its/projects/reactor.makeBehaviour/feature1/build.properties new file mode 100644 index 0000000000..4fb4ed1a18 --- /dev/null +++ b/tycho-its/projects/reactor.makeBehaviour/feature1/build.properties @@ -0,0 +1 @@ +bin.includes=feature.xml \ No newline at end of file diff --git a/tycho-its/projects/reactor.makeBehaviour/feature1/feature.xml b/tycho-its/projects/reactor.makeBehaviour/feature1/feature.xml new file mode 100644 index 0000000000..fba20dfab4 --- /dev/null +++ b/tycho-its/projects/reactor.makeBehaviour/feature1/feature.xml @@ -0,0 +1,13 @@ + + + + + + diff --git a/tycho-its/projects/reactor.makeBehaviour/feature1/pom.xml b/tycho-its/projects/reactor.makeBehaviour/feature1/pom.xml new file mode 100644 index 0000000000..b84199f2e9 --- /dev/null +++ b/tycho-its/projects/reactor.makeBehaviour/feature1/pom.xml @@ -0,0 +1,14 @@ + + + 4.0.0 + + + tycho-its-project.reactor.makeBehaviour + parent + 1.0.0-SNAPSHOT + + + feature1 + eclipse-feature + diff --git a/tycho-its/projects/reactor.makeBehaviour/feature2/build.properties b/tycho-its/projects/reactor.makeBehaviour/feature2/build.properties new file mode 100644 index 0000000000..4fb4ed1a18 --- /dev/null +++ b/tycho-its/projects/reactor.makeBehaviour/feature2/build.properties @@ -0,0 +1 @@ +bin.includes=feature.xml \ No newline at end of file diff --git a/tycho-its/projects/reactor.makeBehaviour/feature2/feature.xml b/tycho-its/projects/reactor.makeBehaviour/feature2/feature.xml new file mode 100644 index 0000000000..200d4939ae --- /dev/null +++ b/tycho-its/projects/reactor.makeBehaviour/feature2/feature.xml @@ -0,0 +1,17 @@ + + + + + + + + diff --git a/tycho-its/projects/reactor.makeBehaviour/feature2/pom.xml b/tycho-its/projects/reactor.makeBehaviour/feature2/pom.xml new file mode 100644 index 0000000000..fb665ac039 --- /dev/null +++ b/tycho-its/projects/reactor.makeBehaviour/feature2/pom.xml @@ -0,0 +1,14 @@ + + + 4.0.0 + + + tycho-its-project.reactor.makeBehaviour + parent + 1.0.0-SNAPSHOT + + + feature2 + eclipse-feature + diff --git a/tycho-its/projects/reactor.makeBehaviour/pom.xml b/tycho-its/projects/reactor.makeBehaviour/pom.xml new file mode 100644 index 0000000000..b0a210dbcb --- /dev/null +++ b/tycho-its/projects/reactor.makeBehaviour/pom.xml @@ -0,0 +1,28 @@ + + 4.0.0 + + tycho-its-project.reactor.makeBehaviour + parent + 1.0.0-SNAPSHOT + pom + + + feature1 + feature2 + bundle1 + bundle2 + + + + + + org.eclipse.tycho + tycho-maven-plugin + ${tycho-version} + true + + + + + diff --git a/tycho-its/src/test/java/org/eclipse/tycho/test/reactor/makeBehaviour/MavenReactorMakeOptionsTest.java b/tycho-its/src/test/java/org/eclipse/tycho/test/reactor/makeBehaviour/MavenReactorMakeOptionsTest.java new file mode 100644 index 0000000000..574a61cdad --- /dev/null +++ b/tycho-its/src/test/java/org/eclipse/tycho/test/reactor/makeBehaviour/MavenReactorMakeOptionsTest.java @@ -0,0 +1,109 @@ +package org.eclipse.tycho.test.reactor.makeBehaviour; + +import static org.junit.Assert.fail; + +import org.apache.maven.it.VerificationException; +import org.apache.maven.it.Verifier; +import org.eclipse.tycho.test.AbstractTychoIntegrationTest; +import org.junit.Before; +import org.junit.Test; + +/** + * Test Maven reactor make behaviours + * + * Test project dependencies: + * + *
+ * feature2 -> feature1,bundle2
+ * feature1 -> bundle1
+ * 
+ * + */ +public class MavenReactorMakeOptionsTest extends AbstractTychoIntegrationTest { + + private Verifier verifier; + + @Before + public void setUp() throws Exception { + verifier = getVerifier("reactor.makeBehaviour"); + verifier.executeGoal("clean"); + } + + @Test + public void testCompleteBuild() throws Exception { + verifier.executeGoal("verify"); + verifier.verifyErrorFreeLog(); + verifier.assertFilePresent("bundle1/target/bundle1-1.0.0-SNAPSHOT.jar"); + verifier.assertFilePresent("bundle2/target/bundle2-1.0.0-SNAPSHOT.jar"); + verifier.assertFilePresent("feature1/target/feature1-1.0.0-SNAPSHOT.jar"); + verifier.assertFilePresent("feature2/target/feature2-1.0.0-SNAPSHOT.jar"); + } + + @Test + public void testAlsoMake() throws Exception { + // REACTOR_MAKE_UPSTREAM + verifier.addCliOption("-am"); + verifier.addCliOption("-pl feature1"); + verifier.executeGoal("verify"); + verifier.verifyErrorFreeLog(); + verifier.assertFilePresent("bundle1/target/bundle1-1.0.0-SNAPSHOT.jar"); + verifier.assertFileNotPresent("bundle2/target/bundle2-1.0.0-SNAPSHOT.jar"); + verifier.assertFilePresent("feature1/target/feature1-1.0.0-SNAPSHOT.jar"); + verifier.assertFileNotPresent("feature2/target/feature2-1.0.0-SNAPSHOT.jar"); + } + + @Test + public void testAlsoMakeDependents() throws Exception { + // REACTOR_MAKE_DOWNSTREAM + verifier.addCliOption("-amd"); + verifier.addCliOption("-pl bundle1,bundle2"); + verifier.executeGoal("verify"); + verifier.verifyErrorFreeLog(); + verifier.assertFilePresent("bundle1/target/bundle1-1.0.0-SNAPSHOT.jar"); + verifier.assertFilePresent("bundle2/target/bundle2-1.0.0-SNAPSHOT.jar"); + verifier.assertFilePresent("feature1/target/feature1-1.0.0-SNAPSHOT.jar"); + verifier.assertFilePresent("feature2/target/feature2-1.0.0-SNAPSHOT.jar"); + } + + @Test + public void testBoth() throws Exception { + // REACTOR_MAKE_BOTH + verifier.addCliOption("-am"); + verifier.addCliOption("-amd"); + verifier.addCliOption("-pl feature1,bundle2"); + verifier.executeGoal("verify"); + verifier.verifyErrorFreeLog(); + verifier.assertFilePresent("bundle1/target/bundle1-1.0.0-SNAPSHOT.jar"); + verifier.assertFilePresent("bundle2/target/bundle2-1.0.0-SNAPSHOT.jar"); + verifier.assertFilePresent("feature1/target/feature1-1.0.0-SNAPSHOT.jar"); + verifier.assertFilePresent("feature2/target/feature2-1.0.0-SNAPSHOT.jar"); + } + + @Test + public void testSingleProjectNoOptionFails() throws Exception { + try { + verifier.addCliOption("-pl feature1"); + verifier.executeGoal("verify"); + fail("Build should fail due to missing reactor dependency"); + } catch (VerificationException e) { + verifier.verifyTextInLog( + "Missing requirement: feature1.feature.group 1.0.0.qualifier requires 'org.eclipse.equinox.p2.iu; bundle1 0.0.0' but it could not be found"); + } + } + + @Test + public void testDownstreamFailsIfMissingDownstreamDependency() throws Exception { + // Downstream brings in feature2 but this requires bundle2 which is unrelated + // to specified projects + try { + verifier.addCliOption("-amd"); + verifier.addCliOption("-pl bundle1,feature1"); + verifier.executeGoal("verify"); + fail("Build should fail due to missing reactor dependency"); + } catch (VerificationException e) { + verifier.verifyTextInLog( + "Missing requirement: feature2.feature.group 1.0.0.qualifier requires 'org.eclipse.equinox.p2.iu; bundle2 0.0.0' but it could not be found"); + } + } + +}