@@ -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
0 commit comments