Skip to content

Commit

Permalink
Integration test for Maven reactor make behaviours
Browse files Browse the repository at this point in the history
  • Loading branch information
joeshannon authored and laeubi committed Jan 31, 2022
1 parent 0de2625 commit eaae267
Show file tree
Hide file tree
Showing 14 changed files with 246 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
.
16 changes: 16 additions & 0 deletions tycho-its/projects/reactor.makeBehaviour/bundle1/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>

<version>1.0.0-SNAPSHOT</version>
<artifactId>bundle1</artifactId>
<packaging>eclipse-plugin</packaging>

<parent>
<groupId>tycho-its-project.reactor.makeBehaviour</groupId>
<artifactId>parent</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
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
Require-Bundle: bundle1
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
.
16 changes: 16 additions & 0 deletions tycho-its/projects/reactor.makeBehaviour/bundle2/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>

<version>1.0.0-SNAPSHOT</version>
<artifactId>bundle2</artifactId>
<packaging>eclipse-plugin</packaging>

<parent>
<groupId>tycho-its-project.reactor.makeBehaviour</groupId>
<artifactId>parent</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
bin.includes=feature.xml
13 changes: 13 additions & 0 deletions tycho-its/projects/reactor.makeBehaviour/feature1/feature.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<feature
id="feature1"
version="1.0.0.qualifier">

<plugin
id="bundle1"
download-size="0"
install-size="0"
version="0.0.0"
unpack="false"/>

</feature>
14 changes: 14 additions & 0 deletions tycho-its/projects/reactor.makeBehaviour/feature1/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>tycho-its-project.reactor.makeBehaviour</groupId>
<artifactId>parent</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>

<artifactId>feature1</artifactId>
<packaging>eclipse-feature</packaging>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
bin.includes=feature.xml
17 changes: 17 additions & 0 deletions tycho-its/projects/reactor.makeBehaviour/feature2/feature.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<feature
id="feature2"
version="1.0.0.qualifier">

<includes
id="feature1"
version="0.0.0"/>

<plugin
id="bundle2"
download-size="0"
install-size="0"
version="0.0.0"
unpack="false"/>

</feature>
14 changes: 14 additions & 0 deletions tycho-its/projects/reactor.makeBehaviour/feature2/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>tycho-its-project.reactor.makeBehaviour</groupId>
<artifactId>parent</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>

<artifactId>feature2</artifactId>
<packaging>eclipse-feature</packaging>
</project>
28 changes: 28 additions & 0 deletions tycho-its/projects/reactor.makeBehaviour/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>tycho-its-project.reactor.makeBehaviour</groupId>
<artifactId>parent</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>pom</packaging>

<modules>
<module>feature1</module>
<module>feature2</module>
<module>bundle1</module>
<module>bundle2</module>
</modules>

<build>
<plugins>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-maven-plugin</artifactId>
<version>${tycho-version}</version>
<extensions>true</extensions>
</plugin>
</plugins>
</build>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
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:
*
* <pre>
* feature2 -> feature1,bundle2
* feature1 -> bundle1
* </pre>
*
*/
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.assertFilePresent("feature1/target/feature1-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("TODO complete");
}
}

@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("TODO complete");
}
}

}

0 comments on commit eaae267

Please sign in to comment.