Skip to content

Commit c2b3404

Browse files
committed
[MNG-7838] Add IT
1 parent ea0b4e5 commit c2b3404

File tree

1 file changed

+67
-0
lines changed

1 file changed

+67
-0
lines changed

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

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,73 @@ public void testitPackagePhase() throws Exception {
152152
assertContains(classpath, new String[] {prefix + "tests.jar"});
153153
}
154154

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-";
188+
189+
List<String> classpath;
190+
191+
classpath = verifier.loadLines("consumer-a/target/compile.txt", "UTF-8");
192+
assertContains(classpath, new String[] {prefix + "tests.jar"});
193+
assertNotContains(classpath, new String[] {prefix + "client.jar"});
194+
classpath = verifier.loadLines("consumer-a/target/runtime.txt", "UTF-8");
195+
assertContains(classpath, new String[] {prefix + "tests.jar"});
196+
assertNotContains(classpath, new String[] {prefix + "client.jar"});
197+
classpath = verifier.loadLines("consumer-a/target/test.txt", "UTF-8");
198+
assertContains(classpath, new String[] {prefix + "tests.jar"});
199+
assertNotContains(classpath, new String[] {prefix + "client.jar"});
200+
201+
classpath = verifier.loadLines("consumer-b/target/compile.txt", "UTF-8");
202+
assertContains(classpath, new String[] {prefix + "client.jar"});
203+
assertNotContains(classpath, new String[] {prefix + "tests.jar"});
204+
classpath = verifier.loadLines("consumer-b/target/runtime.txt", "UTF-8");
205+
assertContains(classpath, new String[] {prefix + "client.jar"});
206+
assertNotContains(classpath, new String[] {prefix + "tests.jar"});
207+
classpath = verifier.loadLines("consumer-b/target/test.txt", "UTF-8");
208+
assertContains(classpath, new String[] {prefix + "client.jar"});
209+
assertNotContains(classpath, new String[] {prefix + "tests.jar"});
210+
211+
classpath = verifier.loadLines("consumer-c/target/compile.txt", "UTF-8");
212+
assertContains(classpath, new String[] {prefix + "client.jar"});
213+
assertContains(classpath, new String[] {prefix + "tests.jar"});
214+
classpath = verifier.loadLines("consumer-c/target/runtime.txt", "UTF-8");
215+
assertContains(classpath, new String[] {prefix + "client.jar"});
216+
assertContains(classpath, new String[] {prefix + "tests.jar"});
217+
classpath = verifier.loadLines("consumer-c/target/test.txt", "UTF-8");
218+
assertContains(classpath, new String[] {prefix + "client.jar"});
219+
assertContains(classpath, new String[] {prefix + "tests.jar"});
220+
}
221+
155222
private void assertContains(List<String> collection, String[] items) {
156223
for (String item : items) {
157224
assertContains(collection, item);

0 commit comments

Comments
 (0)