Skip to content

Commit 1b16b7a

Browse files
committed
Merge branch 'master' of github.com:apache/maven-integration-testing into MPH-183_dependency-management-hierarchy-inputsource
2 parents 7be71e6 + 1336e2d commit 1b16b7a

File tree

62 files changed

+1164
-173
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+1164
-173
lines changed

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public void testitMNG1021() throws Exception {
4848
verifier.setAutoclean(false);
4949
verifier.deleteDirectory("repo");
5050
verifier.deleteArtifacts("org.apache.maven.its.mng1021");
51-
verifier.addCliArgument("-Dmaven.buildconsumer=false");
51+
verifier.addCliArgument("-Dmaven.consumer.pom=false");
5252
verifier.addCliArgument("initialize");
5353
verifier.execute();
5454
verifier.verifyErrorFreeLog();

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

+1
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ public void testit() throws Exception {
4848
verifier.setAutoclean(false);
4949
verifier.deleteDirectory("target");
5050
verifier.addCliArgument("pre-site");
51+
verifier.addCliArgument("-Dmaven.site.skip=true");
5152
verifier.execute();
5253
verifier.verifyErrorFreeLog();
5354

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

+68-1
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/java/org/apache/maven/it/MavenITmng3396DependencyManagementForOverConstrainedRangesTest.java

-3
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ public void testitMNG3396() throws Exception {
4646
verifier.deleteArtifact(GROUP_ID, "A", "1.0", "jar");
4747
verifier.deleteArtifact(GROUP_ID, "B", "1.0", "pom");
4848
verifier.deleteArtifact(GROUP_ID, "B", "1.0", "jar");
49-
verifier.addCliArgument("-Dmaven.buildconsumer=false");
5049
verifier.addCliArgument("install");
5150
verifier.execute();
5251
verifier.verifyErrorFreeLog();
@@ -60,7 +59,6 @@ public void testitMNG3396() throws Exception {
6059
verifier.deleteArtifact(GROUP_ID, "A", "3.0", "jar");
6160
verifier.deleteArtifact(GROUP_ID, "plugin", "1.0", "pom");
6261
verifier.deleteArtifact(GROUP_ID, "plugin", "1.0", "jar");
63-
verifier.addCliArgument("-Dmaven.buildconsumer=false");
6462
verifier.addCliArgument("install");
6563
verifier.execute();
6664
verifier.verifyErrorFreeLog();
@@ -70,7 +68,6 @@ public void testitMNG3396() throws Exception {
7068
verifier = newVerifier(testDir.getAbsolutePath(), "remote");
7169
verifier.deleteArtifact(GROUP_ID, "pluginuser", "1.0", "pom");
7270
verifier.deleteArtifact(GROUP_ID, "pluginuser", "1.0", "jar");
73-
verifier.addCliArgument("-Dmaven.buildconsumer=false");
7471
verifier.addCliArgument("install");
7572
verifier.execute();
7673
verifier.verifyErrorFreeLog();

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

+2
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import org.apache.maven.shared.verifier.VerificationException;
2424
import org.apache.maven.shared.verifier.Verifier;
2525
import org.apache.maven.shared.verifier.util.ResourceExtractor;
26+
import org.junit.jupiter.api.Disabled;
2627
import org.junit.jupiter.api.Test;
2728

2829
/**
@@ -31,6 +32,7 @@
3132
* @author Benjamin Bentmann
3233
*
3334
*/
35+
@Disabled("MNG-7255 provides the default groupId from the parent")
3436
public class MavenITmng3863AutoPluginGroupIdTest extends AbstractMavenIntegrationTestCase {
3537

3638
public MavenITmng3863AutoPluginGroupIdTest() {

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public void testContinuousDeliveryFriendlyVersionsAreWarningFreeWithoutBuildCons
5050
verifier.setAutoclean(false);
5151
verifier.deleteDirectory("target");
5252
verifier.addCliArgument("-Dchangelist=changelist");
53-
verifier.addCliArgument("-Dmaven.buildconsumer=false");
53+
verifier.addCliArgument("-Dmaven.consumerpom=false");
5454
verifier.addCliArgument("validate");
5555
verifier.execute();
5656
verifier.verifyErrorFreeLog();
@@ -83,7 +83,7 @@ public void testContinuousDeliveryFriendlyVersionsAreWarningFreeWithBuildConsume
8383
verifier.setAutoclean(false);
8484
verifier.deleteDirectory("target");
8585
verifier.addCliArgument("-Dchangelist=changelist");
86-
verifier.addCliArgument("-Dmaven.buildconsumer=true");
86+
verifier.addCliArgument("-Dmaven.consumerpom=true");
8787
verifier.addCliArgument("validate");
8888
verifier.execute();
8989
verifier.verifyErrorFreeLog();

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public void testWithoutBuildConsumer() throws Exception {
5757
verifier.setAutoclean(false);
5858
verifier.addCliArgument("-q");
5959
verifier.addCliArgument("-U");
60-
verifier.addCliArgument("-Dmaven.buildconsumer=false");
60+
verifier.addCliArgument("-Dmaven.consumerpom=false");
6161
verifier.addCliArgument("verify");
6262
verifier.execute();
6363

@@ -93,7 +93,7 @@ public void testWithBuildConsumer() throws Exception {
9393
verifier.setAutoclean(false);
9494
verifier.addCliArgument("-q");
9595
verifier.addCliArgument("-U");
96-
verifier.addCliArgument("-Dmaven.buildconsumer=true");
96+
verifier.addCliArgument("-Dmaven.consumerpom=true");
9797
verifier.addCliArgument("verify");
9898
verifier.execute();
9999

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public void testitShouldResolveTheDependenciesWithoutBuildConsumer() throws Exce
5858

5959
// verifier.setLogFileName( "log-only.txt" );
6060
verifier.addCliArgument("-Drevision=1.2");
61-
verifier.addCliArgument("-Dmaven.buildconsumer=false");
61+
verifier.addCliArgument("-Dmaven.consumerpom=false");
6262
verifier.addCliArgument("clean");
6363
verifier.execute();
6464
verifier.addCliArgument("package");
@@ -76,7 +76,7 @@ public void testitShouldResolveTheDependenciesWithBuildConsumer() throws Excepti
7676

7777
verifier.setLogFileName("log-bc.txt");
7878
verifier.addCliArgument("-Drevision=1.2");
79-
verifier.addCliArgument("-Dmaven.buildconsumer=true");
79+
verifier.addCliArgument("-Dmaven.consumerpom=true");
8080
verifier.addCliArgument("clean");
8181
verifier.execute();
8282
verifier.addCliArgument("package");

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public void testitShouldResolveTheDependenciesWithoutBuildConsumer() throws Exce
5656
verifier.setAutoclean(false);
5757

5858
verifier.addCliArgument("-Drevision=1.2");
59-
verifier.addCliArgument("-Dmaven.buildconsumer=false");
59+
verifier.addCliArgument("-Dmaven.consumerpom=false");
6060
verifier.setLogFileName("install-log.txt");
6161
verifier.addCliArguments("clean", "install");
6262
verifier.execute();
@@ -82,7 +82,7 @@ public void testitShouldResolveTheDependenciesWithBuildConsumer() throws Excepti
8282
verifier.setForkJvm(true);
8383

8484
verifier.addCliArgument("-Drevision=1.2");
85-
verifier.addCliArgument("-Dmaven.buildconsumer=true");
85+
verifier.addCliArgument("-Dmaven.consumerpom=true");
8686
verifier.setLogFileName("install-log.txt");
8787
verifier.addCliArguments("clean", "install");
8888
verifier.execute();

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

+4-12
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,11 @@
2020

2121
import java.io.File;
2222
import java.io.IOException;
23-
import java.util.List;
2423

2524
import org.apache.maven.shared.utils.io.FileUtils;
2625
import org.apache.maven.shared.verifier.Verifier;
2726
import org.apache.maven.shared.verifier.util.ResourceExtractor;
2827
import org.junit.jupiter.api.Test;
29-
import org.opentest4j.AssertionFailedError;
3028

3129
/**
3230
* With the build-consumer the pom.xml will be adjusted during the process.
@@ -111,15 +109,9 @@ public void testPublishedPoms() throws Exception {
111109
}
112110

113111
static void assertTextEquals(File file1, File file2) throws IOException {
114-
List<String> s1 = FileUtils.loadFile(file1);
115-
List<String> s2 = FileUtils.loadFile(file2);
116-
try {
117-
assertEquals("Not same size", s1.size(), s2.size());
118-
for (int i = 0; i < s1.size(); i++) {
119-
assertEquals("Mismatch line " + i, s1.get(i), s2.get(i));
120-
}
121-
} catch (AssertionFailedError error) {
122-
assertEquals(error.getMessage(), s1, s2);
123-
}
112+
assertEquals(
113+
"pom files differ " + file1 + " " + file2,
114+
String.join("\n", FileUtils.loadFile(file1)),
115+
String.join("\n", FileUtils.loadFile(file2)));
124116
}
125117
}

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

+4-1
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,9 @@ public void testPublishedPoms() throws Exception {
134134
}
135135

136136
static void assertTextEquals(File file1, File file2) throws IOException {
137-
assertEquals(FileUtils.loadFile(file1), FileUtils.loadFile(file2));
137+
assertEquals(
138+
"pom files differ " + file1 + " " + file2,
139+
String.join("\n", FileUtils.loadFile(file1)),
140+
String.join("\n", FileUtils.loadFile(file2)));
138141
}
139142
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
package org.apache.maven.it;
20+
21+
import java.io.File;
22+
import java.io.IOException;
23+
24+
import org.apache.maven.shared.verifier.VerificationException;
25+
import org.apache.maven.shared.verifier.Verifier;
26+
import org.apache.maven.shared.verifier.util.ResourceExtractor;
27+
import org.junit.jupiter.api.Test;
28+
29+
public class MavenITmng7255InferredGroupIdTest extends AbstractMavenIntegrationTestCase {
30+
private static final String PROJECT_PATH = "/mng-7255-inferred-groupid";
31+
32+
public MavenITmng7255InferredGroupIdTest() {
33+
super("[4.0.0-alpha-5,)");
34+
}
35+
36+
@Test
37+
public void testInferredGroupId() throws IOException, VerificationException {
38+
final File projectDir = ResourceExtractor.simpleExtractResources(getClass(), PROJECT_PATH);
39+
final Verifier verifier = newVerifier(projectDir.getAbsolutePath());
40+
41+
verifier.addCliArgument("validate");
42+
verifier.execute();
43+
44+
verifier.verifyErrorFreeLog();
45+
}
46+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
package org.apache.maven.it;
20+
21+
import java.io.File;
22+
23+
import org.apache.maven.shared.verifier.VerificationException;
24+
import org.apache.maven.shared.verifier.Verifier;
25+
import org.apache.maven.shared.verifier.util.ResourceExtractor;
26+
import org.junit.jupiter.api.Test;
27+
28+
import static org.junit.jupiter.api.Assertions.assertThrows;
29+
30+
/**
31+
* This is a test set for <a href="https://issues.apache.org/jira/browse/MNG-8181">MNG-8181</a>.
32+
*/
33+
public class MavenITmng8181CentralRepoTest extends AbstractMavenIntegrationTestCase {
34+
public MavenITmng8181CentralRepoTest() {
35+
super("[4.0.0-beta-4,)");
36+
}
37+
38+
/**
39+
* Verify that the central url can be overridden by a user property.
40+
*
41+
* @throws Exception in case of failure
42+
*/
43+
@Test
44+
public void testitModel() throws Exception {
45+
File testDir = ResourceExtractor.simpleExtractResources(getClass(), "/mng-8181-central-repo");
46+
47+
Verifier verifier = newVerifier(testDir.getAbsolutePath(), null);
48+
verifier.setAutoclean(false);
49+
verifier.addCliArgument("--install-settings=install-settings.xml");
50+
verifier.addCliArgument("--settings=settings.xml");
51+
verifier.addCliArgument("-Dmaven.repo.local=" + testDir.toPath().resolve("target/local-repo"));
52+
verifier.addCliArgument("-Dmaven.repo.central=http://repo1.maven.org/");
53+
verifier.addCliArgument("validate");
54+
assertThrows(VerificationException.class, verifier::execute);
55+
verifier.verifyTextInLog("central (http://repo1.maven.org/, default, releases)");
56+
}
57+
}

0 commit comments

Comments
 (0)