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