Skip to content

Commit 1e803a6

Browse files
authored
[MNG-7838] Fix IT and add another one (#278)
1 parent 58c7b16 commit 1e803a6

File tree

2 files changed

+69
-1
lines changed

2 files changed

+69
-1
lines changed

core-it-suite/src/test/java/org/apache/maven/it/MavenITmng3043BestEffortReactorResolutionTest.java

Lines changed: 68 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,74 @@ public void testitPackagePhase() throws Exception {
117117
verifier.execute();
118118
verifier.verifyErrorFreeLog();
119119

120-
String prefix = matchesVersionRange("[4.0.0-alpha-4,)") ? "dependency-0.1-SNAPSHOT-" : "";
120+
String prefix = "";
121+
122+
List<String> classpath;
123+
124+
classpath = verifier.loadLines("consumer-a/target/compile.txt", "UTF-8");
125+
assertContains(classpath, new String[] {prefix + "tests.jar"});
126+
assertNotContains(classpath, new String[] {prefix + "client.jar"});
127+
classpath = verifier.loadLines("consumer-a/target/runtime.txt", "UTF-8");
128+
assertContains(classpath, new String[] {prefix + "tests.jar"});
129+
assertNotContains(classpath, new String[] {prefix + "client.jar"});
130+
classpath = verifier.loadLines("consumer-a/target/test.txt", "UTF-8");
131+
assertContains(classpath, new String[] {prefix + "tests.jar"});
132+
assertNotContains(classpath, new String[] {prefix + "client.jar"});
133+
134+
classpath = verifier.loadLines("consumer-b/target/compile.txt", "UTF-8");
135+
assertContains(classpath, new String[] {prefix + "client.jar"});
136+
assertNotContains(classpath, new String[] {prefix + "tests.jar"});
137+
classpath = verifier.loadLines("consumer-b/target/runtime.txt", "UTF-8");
138+
assertContains(classpath, new String[] {prefix + "client.jar"});
139+
assertNotContains(classpath, new String[] {prefix + "tests.jar"});
140+
classpath = verifier.loadLines("consumer-b/target/test.txt", "UTF-8");
141+
assertContains(classpath, new String[] {prefix + "client.jar"});
142+
assertNotContains(classpath, new String[] {prefix + "tests.jar"});
143+
144+
classpath = verifier.loadLines("consumer-c/target/compile.txt", "UTF-8");
145+
assertContains(classpath, new String[] {prefix + "client.jar"});
146+
assertContains(classpath, new String[] {prefix + "tests.jar"});
147+
classpath = verifier.loadLines("consumer-c/target/runtime.txt", "UTF-8");
148+
assertContains(classpath, new String[] {prefix + "client.jar"});
149+
assertContains(classpath, new String[] {prefix + "tests.jar"});
150+
classpath = verifier.loadLines("consumer-c/target/test.txt", "UTF-8");
151+
assertContains(classpath, new String[] {prefix + "client.jar"});
152+
assertContains(classpath, new String[] {prefix + "tests.jar"});
153+
}
154+
155+
/**
156+
* Test that dependency resolution still uses the actual artifact files once these have been
157+
* assembled/attached in the "package" phase. This ensures the class path is accurate and not locked to
158+
* the output directories of the best effort model from above.
159+
*
160+
* @throws Exception in case of failure
161+
*/
162+
@Test
163+
public void testitPackagePhasesSlitted() throws Exception {
164+
requiresMavenVersion("[4.0.0-beta-4,)");
165+
166+
File testDir = ResourceExtractor.simpleExtractResources(getClass(), "/mng-3043");
167+
168+
Verifier verifier = newVerifier(testDir.getAbsolutePath());
169+
verifier.setAutoclean(false);
170+
verifier.deleteDirectory("target");
171+
verifier.deleteDirectory("consumer-a/target");
172+
verifier.deleteDirectory("consumer-b/target");
173+
verifier.deleteDirectory("consumer-c/target");
174+
verifier.deleteArtifacts("org.apache.maven.its.mng3043");
175+
verifier.setLogFileName("log-package-pre.txt");
176+
verifier.addCliArguments("--also-make", "--projects", ":dependency", "package");
177+
verifier.execute();
178+
verifier.verifyErrorFreeLog();
179+
180+
verifier = newVerifier(testDir.getAbsolutePath());
181+
verifier.setAutoclean(false);
182+
verifier.setLogFileName("log-package-pre.txt");
183+
verifier.addCliArguments("--projects", ":consumer-a,:consumer-b,:consumer-c", "package");
184+
verifier.execute();
185+
verifier.verifyErrorFreeLog();
186+
187+
String prefix = "dependency-0.1-SNAPSHOT-";
121188

122189
List<String> classpath;
123190

core-it-suite/src/test/resources-filtered/bootstrap.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ org.apache.geronimo.specs:geronimo-jcdi_2.0_spec:1.3
2020
org.apache.groovy:groovy-ant:4.0.15
2121
org.apache.groovy:groovy:4.0.15
2222
org.apache.maven:maven-api-impl:4.0.0-beta-3
23+
org.apache.maven:maven-api-di:4.0.0-beta-3
2324
org.apache.maven:maven-api-spi:4.0.0-alpha-8
2425
org.apache.maven:maven-api-model:mdo:4.0.0-alpha-8
2526
org.apache.maven.extensions:maven-extensions:pom:41

0 commit comments

Comments
 (0)