Skip to content

Commit 37b9369

Browse files
authored
[MNG-7877] Fix ITs for build bom + consumer/pom simplification (#292)
1 parent 2730c77 commit 37b9369

30 files changed

+466
-233
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +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.experimental.buildconsumer=false");
5152
verifier.addCliArgument("initialize");
5253
verifier.execute();
5354
verifier.verifyErrorFreeLog();

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ 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.experimental.buildconsumer=false");
4950
verifier.addCliArgument("install");
5051
verifier.execute();
5152
verifier.verifyErrorFreeLog();
@@ -59,6 +60,7 @@ public void testitMNG3396() throws Exception {
5960
verifier.deleteArtifact(GROUP_ID, "A", "3.0", "jar");
6061
verifier.deleteArtifact(GROUP_ID, "plugin", "1.0", "pom");
6162
verifier.deleteArtifact(GROUP_ID, "plugin", "1.0", "jar");
63+
verifier.addCliArgument("-Dmaven.experimental.buildconsumer=false");
6264
verifier.addCliArgument("install");
6365
verifier.execute();
6466
verifier.verifyErrorFreeLog();
@@ -68,6 +70,7 @@ public void testitMNG3396() throws Exception {
6870
verifier = newVerifier(testDir.getAbsolutePath(), "remote");
6971
verifier.deleteArtifact(GROUP_ID, "pluginuser", "1.0", "pom");
7072
verifier.deleteArtifact(GROUP_ID, "pluginuser", "1.0", "jar");
73+
verifier.addCliArgument("-Dmaven.experimental.buildconsumer=false");
7174
verifier.addCliArgument("install");
7275
verifier.execute();
7376
verifier.verifyErrorFreeLog();

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

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,13 @@
2020

2121
import java.io.File;
2222
import java.io.IOException;
23+
import java.util.List;
2324

2425
import org.apache.maven.shared.utils.io.FileUtils;
2526
import org.apache.maven.shared.verifier.Verifier;
2627
import org.apache.maven.shared.verifier.util.ResourceExtractor;
2728
import org.junit.jupiter.api.Test;
29+
import org.opentest4j.AssertionFailedError;
2830

2931
/**
3032
* With the build-consumer the pom.xml will be adjusted during the process.
@@ -77,6 +79,11 @@ public void testPublishedPoms() throws Exception {
7779
new File(verifier.getArtifactPath(
7880
"org.sonatype.mavenbook.multi", "parent", "0.9-MNG6656-SNAPSHOT", "pom")));
7981

82+
assertTextEquals(
83+
new File(testDir, "expected/parent-build.pom"),
84+
new File(verifier.getArtifactPath(
85+
"org.sonatype.mavenbook.multi", "parent", "0.9-MNG6656-SNAPSHOT", "pom", "build")));
86+
8087
assertTextEquals(
8188
new File(testDir, "expected/simple-parent.pom"),
8289
new File(verifier.getArtifactPath(
@@ -87,13 +94,32 @@ public void testPublishedPoms() throws Exception {
8794
new File(verifier.getArtifactPath(
8895
"org.sonatype.mavenbook.multi", "simple-weather", "0.9-MNG6656-SNAPSHOT", "pom")));
8996

97+
assertTextEquals(
98+
new File(testDir, "expected/simple-weather-build.pom"),
99+
new File(verifier.getArtifactPath(
100+
"org.sonatype.mavenbook.multi", "simple-weather", "0.9-MNG6656-SNAPSHOT", "pom", "build")));
101+
90102
assertTextEquals(
91103
new File(testDir, "expected/simple-webapp.pom"),
92104
new File(verifier.getArtifactPath(
93105
"org.sonatype.mavenbook.multi", "simple-webapp", "0.9-MNG6656-SNAPSHOT", "pom")));
106+
107+
assertTextEquals(
108+
new File(testDir, "expected/simple-webapp-build.pom"),
109+
new File(verifier.getArtifactPath(
110+
"org.sonatype.mavenbook.multi", "simple-webapp", "0.9-MNG6656-SNAPSHOT", "pom", "build")));
94111
}
95112

96113
static void assertTextEquals(File file1, File file2) throws IOException {
97-
assertEquals(FileUtils.loadFile(file1), FileUtils.loadFile(file2));
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+
}
98124
}
99125
}

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

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,30 +77,60 @@ public void testPublishedPoms() throws Exception {
7777
new File(verifier.getArtifactPath(
7878
"org.sonatype.mavenbook.multi", "parent", "0.9-MNG6957-SNAPSHOT", "pom")));
7979

80+
assertTextEquals(
81+
new File(testDir, "expected/parent-build.pom"),
82+
new File(verifier.getArtifactPath(
83+
"org.sonatype.mavenbook.multi", "parent", "0.9-MNG6957-SNAPSHOT", "pom", "build")));
84+
8085
assertTextEquals(
8186
new File(testDir, "expected/simple-parent.pom"),
8287
new File(verifier.getArtifactPath(
8388
"org.sonatype.mavenbook.multi", "simple-parent", "0.9-MNG6957-SNAPSHOT", "pom")));
8489

90+
assertTextEquals(
91+
new File(testDir, "expected/simple-parent-build.pom"),
92+
new File(verifier.getArtifactPath(
93+
"org.sonatype.mavenbook.multi", "simple-parent", "0.9-MNG6957-SNAPSHOT", "pom", "build")));
94+
8595
assertTextEquals(
8696
new File(testDir, "expected/simple-weather.pom"),
8797
new File(verifier.getArtifactPath(
8898
"org.sonatype.mavenbook.multi", "simple-weather", "0.9-MNG6957-SNAPSHOT", "pom")));
8999

100+
assertTextEquals(
101+
new File(testDir, "expected/simple-weather-build.pom"),
102+
new File(verifier.getArtifactPath(
103+
"org.sonatype.mavenbook.multi", "simple-weather", "0.9-MNG6957-SNAPSHOT", "pom", "build")));
104+
90105
assertTextEquals(
91106
new File(testDir, "expected/simple-webapp.pom"),
92107
new File(verifier.getArtifactPath(
93108
"org.sonatype.mavenbook.multi", "simple-webapp", "0.9-MNG6957-SNAPSHOT", "pom")));
94109

110+
assertTextEquals(
111+
new File(testDir, "expected/simple-webapp-build.pom"),
112+
new File(verifier.getArtifactPath(
113+
"org.sonatype.mavenbook.multi", "simple-webapp", "0.9-MNG6957-SNAPSHOT", "pom", "build")));
114+
95115
assertTextEquals(
96116
new File(testDir, "expected/simple-testutils.pom"),
97117
new File(verifier.getArtifactPath(
98118
"org.sonatype.mavenbook.multi", "simple-testutils", "0.9-MNG6957-SNAPSHOT", "pom")));
99119

120+
assertTextEquals(
121+
new File(testDir, "expected/simple-testutils-build.pom"),
122+
new File(verifier.getArtifactPath(
123+
"org.sonatype.mavenbook.multi", "simple-testutils", "0.9-MNG6957-SNAPSHOT", "pom", "build")));
124+
100125
assertTextEquals(
101126
new File(testDir, "expected/utils-parent.pom"),
102127
new File(verifier.getArtifactPath(
103128
"org.sonatype.mavenbook.multi", "utils-parent", "0.9-MNG6957-SNAPSHOT", "pom")));
129+
130+
assertTextEquals(
131+
new File(testDir, "expected/utils-parent-build.pom"),
132+
new File(verifier.getArtifactPath(
133+
"org.sonatype.mavenbook.multi", "utils-parent", "0.9-MNG6957-SNAPSHOT", "pom", "build")));
104134
}
105135

106136
static void assertTextEquals(File file1, File file2) throws IOException {

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import java.io.File;
2222

2323
import org.apache.commons.io.FileUtils;
24+
import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
2425
import org.apache.maven.shared.verifier.Verifier;
2526
import org.apache.maven.shared.verifier.util.ResourceExtractor;
2627
import org.junit.jupiter.api.Test;
@@ -54,8 +55,12 @@ void testLeakyModel() throws Exception {
5455

5556
verifier.verifyErrorFreeLog();
5657

57-
String pom = FileUtils.readFileToString(
58-
new File(verifier.getArtifactPath("org.apache.maven.its.mng7228", "test", "1.0.0-SNAPSHOT", "pom")));
58+
String classifier = null;
59+
if (getMavenVersion().compareTo(new DefaultArtifactVersion("4.0.0-alpha-7")) > 0) {
60+
classifier = "build";
61+
}
62+
String pom = FileUtils.readFileToString(new File(
63+
verifier.getArtifactPath("org.apache.maven.its.mng7228", "test", "1.0.0-SNAPSHOT", "pom", classifier)));
5964

6065
assertThat(pom, containsString("projectProperty"));
6166
assertThat(pom, not(containsString("activeProperty")));
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
Licensed to the Apache Software Foundation (ASF) under one
4+
or more contributor license agreements. See the NOTICE file
5+
distributed with this work for additional information
6+
regarding copyright ownership. The ASF licenses this file
7+
to you under the Apache License, Version 2.0 (the
8+
"License"); you may not use this file except in compliance
9+
with the License. You may obtain a copy of the License at
10+
11+
http://www.apache.org/licenses/LICENSE-2.0
12+
13+
Unless required by applicable law or agreed to in writing,
14+
software distributed under the License is distributed on an
15+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16+
KIND, either express or implied. See the License for the
17+
specific language governing permissions and limitations
18+
under the License.
19+
-->
20+
<project xmlns="http://maven.apache.org/POM/4.1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" root="true" xsi:schemaLocation="http://maven.apache.org/POM/4.1.0 https://maven.apache.org/maven-v4_1_0.xsd">
21+
<groupId>org.sonatype.mavenbook.multi</groupId>
22+
<artifactId>parent</artifactId>
23+
<version>0.9-${changelist}-SNAPSHOT</version>
24+
<packaging>pom</packaging>
25+
<name>Multi Chapter Parent Project</name>
26+
27+
<!-- Optimized from https://github.com/sonatype/maven-example-en/tree/master/examples/ch-multi -->
28+
<modules>
29+
<module>simple-parent</module>
30+
</modules>
31+
</project>
Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,9 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<!--
3-
Licensed to the Apache Software Foundation (ASF) under one
4-
or more contributor license agreements. See the NOTICE file
5-
distributed with this work for additional information
6-
regarding copyright ownership. The ASF licenses this file
7-
to you under the Apache License, Version 2.0 (the
8-
"License"); you may not use this file except in compliance
9-
with the License. You may obtain a copy of the License at
10-
11-
http://www.apache.org/licenses/LICENSE-2.0
12-
13-
Unless required by applicable law or agreed to in writing,
14-
software distributed under the License is distributed on an
15-
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16-
KIND, either express or implied. See the License for the
17-
specific language governing permissions and limitations
18-
under the License.
19-
-->
20-
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/maven-v4_0_0.xsd">
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
213
<modelVersion>4.0.0</modelVersion>
224
<groupId>org.sonatype.mavenbook.multi</groupId>
235
<artifactId>parent</artifactId>
246
<version>0.9-MNG6656-SNAPSHOT</version>
257
<packaging>pom</packaging>
268
<name>Multi Chapter Parent Project</name>
27-
28-
<!-- Optimized from https://github.com/sonatype/maven-example-en/tree/master/examples/ch-multi -->
29-
30-
</project>
9+
</project>
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
Licensed to the Apache Software Foundation (ASF) under one
4+
or more contributor license agreements. See the NOTICE file
5+
distributed with this work for additional information
6+
regarding copyright ownership. The ASF licenses this file
7+
to you under the Apache License, Version 2.0 (the
8+
"License"); you may not use this file except in compliance
9+
with the License. You may obtain a copy of the License at
10+
11+
http://www.apache.org/licenses/LICENSE-2.0
12+
13+
Unless required by applicable law or agreed to in writing,
14+
software distributed under the License is distributed on an
15+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16+
KIND, either express or implied. See the License for the
17+
specific language governing permissions and limitations
18+
under the License.
19+
-->
20+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/maven-v4_0_0.xsd">
21+
<modelVersion>4.0.0</modelVersion>
22+
<parent>
23+
<groupId>org.sonatype.mavenbook.multi</groupId>
24+
<artifactId>parent</artifactId>
25+
</parent>
26+
<artifactId>simple-parent</artifactId>
27+
<packaging>pom</packaging>
28+
<name>Multi Chapter Simple Parent Project</name>
29+
30+
<modules>
31+
<module>simple-weather</module>
32+
<module>simple-webapp</module>
33+
</modules>
34+
35+
<build>
36+
<pluginManagement>
37+
<plugins>
38+
<plugin>
39+
<groupId>org.apache.maven.plugins</groupId>
40+
<artifactId>maven-compiler-plugin</artifactId>
41+
</plugin>
42+
</plugins>
43+
</pluginManagement>
44+
</build>
45+
46+
</project>
Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,5 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<!--
3-
Licensed to the Apache Software Foundation (ASF) under one
4-
or more contributor license agreements. See the NOTICE file
5-
distributed with this work for additional information
6-
regarding copyright ownership. The ASF licenses this file
7-
to you under the Apache License, Version 2.0 (the
8-
"License"); you may not use this file except in compliance
9-
with the License. You may obtain a copy of the License at
10-
11-
http://www.apache.org/licenses/LICENSE-2.0
12-
13-
Unless required by applicable law or agreed to in writing,
14-
software distributed under the License is distributed on an
15-
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16-
KIND, either express or implied. See the License for the
17-
specific language governing permissions and limitations
18-
under the License.
19-
-->
20-
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/maven-v4_0_0.xsd">
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
213
<modelVersion>4.0.0</modelVersion>
224
<parent>
235
<groupId>org.sonatype.mavenbook.multi</groupId>
@@ -27,18 +9,13 @@ under the License.
279
<artifactId>simple-parent</artifactId>
2810
<packaging>pom</packaging>
2911
<name>Multi Chapter Simple Parent Project</name>
30-
31-
32-
3312
<build>
3413
<pluginManagement>
3514
<plugins>
3615
<plugin>
37-
<groupId>org.apache.maven.plugins</groupId>
3816
<artifactId>maven-compiler-plugin</artifactId>
3917
</plugin>
4018
</plugins>
4119
</pluginManagement>
4220
</build>
43-
44-
</project>
21+
</project>
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
Licensed to the Apache Software Foundation (ASF) under one
4+
or more contributor license agreements. See the NOTICE file
5+
distributed with this work for additional information
6+
regarding copyright ownership. The ASF licenses this file
7+
to you under the Apache License, Version 2.0 (the
8+
"License"); you may not use this file except in compliance
9+
with the License. You may obtain a copy of the License at
10+
11+
http://www.apache.org/licenses/LICENSE-2.0
12+
13+
Unless required by applicable law or agreed to in writing,
14+
software distributed under the License is distributed on an
15+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16+
KIND, either express or implied. See the License for the
17+
specific language governing permissions and limitations
18+
under the License.
19+
-->
20+
<project xmlns="http://maven.apache.org/POM/4.1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.1.0 https://maven.apache.org/maven-v4_1_0.xsd">
21+
<parent>
22+
<groupId>org.sonatype.mavenbook.multi</groupId>
23+
<artifactId>simple-parent</artifactId>
24+
</parent>
25+
<artifactId>simple-weather</artifactId>
26+
<packaging>jar</packaging>
27+
28+
<name>Multi Chapter Simple Weather API</name>
29+
30+
</project>

0 commit comments

Comments
 (0)