Skip to content

Commit

Permalink
Fix ITs for BOM packaging / build pom
Browse files Browse the repository at this point in the history
  • Loading branch information
gnodet committed Aug 21, 2023
1 parent dde4c49 commit 352f78c
Show file tree
Hide file tree
Showing 18 changed files with 270 additions and 164 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public void testitMNG1021() throws Exception {
verifier.setAutoclean(false);
verifier.deleteDirectory("repo");
verifier.deleteArtifacts("org.apache.maven.its.mng1021");
verifier.addCliArgument("-Dmaven.experimental.buildconsumer=false");
verifier.addCliArgument("initialize");
verifier.execute();
verifier.verifyErrorFreeLog();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public void testitMNG3396() throws Exception {
verifier.deleteArtifact(GROUP_ID, "A", "1.0", "jar");
verifier.deleteArtifact(GROUP_ID, "B", "1.0", "pom");
verifier.deleteArtifact(GROUP_ID, "B", "1.0", "jar");
verifier.addCliArgument("-Dmaven.experimental.buildconsumer=false");
verifier.addCliArgument("install");
verifier.execute();
verifier.verifyErrorFreeLog();
Expand All @@ -59,6 +60,7 @@ public void testitMNG3396() throws Exception {
verifier.deleteArtifact(GROUP_ID, "A", "3.0", "jar");
verifier.deleteArtifact(GROUP_ID, "plugin", "1.0", "pom");
verifier.deleteArtifact(GROUP_ID, "plugin", "1.0", "jar");
verifier.addCliArgument("-Dmaven.experimental.buildconsumer=false");
verifier.addCliArgument("install");
verifier.execute();
verifier.verifyErrorFreeLog();
Expand All @@ -68,6 +70,7 @@ public void testitMNG3396() throws Exception {
verifier = newVerifier(testDir.getAbsolutePath(), "remote");
verifier.deleteArtifact(GROUP_ID, "pluginuser", "1.0", "pom");
verifier.deleteArtifact(GROUP_ID, "pluginuser", "1.0", "jar");
verifier.addCliArgument("-Dmaven.experimental.buildconsumer=false");
verifier.addCliArgument("install");
verifier.execute();
verifier.verifyErrorFreeLog();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,13 @@

import java.io.File;
import java.io.IOException;
import java.util.List;

import org.apache.maven.shared.utils.io.FileUtils;
import org.apache.maven.shared.verifier.Verifier;
import org.apache.maven.shared.verifier.util.ResourceExtractor;
import org.junit.jupiter.api.Test;
import org.opentest4j.AssertionFailedError;

/**
* With the build-consumer the pom.xml will be adjusted during the process.
Expand Down Expand Up @@ -87,13 +89,32 @@ public void testPublishedPoms() throws Exception {
new File(verifier.getArtifactPath(
"org.sonatype.mavenbook.multi", "simple-weather", "0.9-MNG6656-SNAPSHOT", "pom")));

assertTextEquals(
new File(testDir, "expected/simple-weather-build.pom"),
new File(verifier.getArtifactPath(
"org.sonatype.mavenbook.multi", "simple-weather", "0.9-MNG6656-SNAPSHOT", "pom", "build")));

assertTextEquals(
new File(testDir, "expected/simple-webapp.pom"),
new File(verifier.getArtifactPath(
"org.sonatype.mavenbook.multi", "simple-webapp", "0.9-MNG6656-SNAPSHOT", "pom")));

assertTextEquals(
new File(testDir, "expected/simple-webapp-build.pom"),
new File(verifier.getArtifactPath(
"org.sonatype.mavenbook.multi", "simple-webapp", "0.9-MNG6656-SNAPSHOT", "pom", "build")));
}

static void assertTextEquals(File file1, File file2) throws IOException {
assertEquals(FileUtils.loadFile(file1), FileUtils.loadFile(file2));
List<String> s1 = FileUtils.loadFile(file1);
List<String> s2 = FileUtils.loadFile(file2);
try {
assertEquals("Not same size", s1.size(), s2.size());
for (int i = 0; i < s1.size(); i++) {
assertEquals("Mismatch line " + i, s1.get(i), s2.get(i));
}
} catch (AssertionFailedError error) {
assertEquals(error.getMessage(), s1, s2);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -87,16 +87,31 @@ public void testPublishedPoms() throws Exception {
new File(verifier.getArtifactPath(
"org.sonatype.mavenbook.multi", "simple-weather", "0.9-MNG6957-SNAPSHOT", "pom")));

assertTextEquals(
new File(testDir, "expected/simple-weather-build.pom"),
new File(verifier.getArtifactPath(
"org.sonatype.mavenbook.multi", "simple-weather", "0.9-MNG6957-SNAPSHOT", "pom", "build")));

assertTextEquals(
new File(testDir, "expected/simple-webapp.pom"),
new File(verifier.getArtifactPath(
"org.sonatype.mavenbook.multi", "simple-webapp", "0.9-MNG6957-SNAPSHOT", "pom")));

assertTextEquals(
new File(testDir, "expected/simple-webapp-build.pom"),
new File(verifier.getArtifactPath(
"org.sonatype.mavenbook.multi", "simple-webapp", "0.9-MNG6957-SNAPSHOT", "pom", "build")));

assertTextEquals(
new File(testDir, "expected/simple-testutils.pom"),
new File(verifier.getArtifactPath(
"org.sonatype.mavenbook.multi", "simple-testutils", "0.9-MNG6957-SNAPSHOT", "pom")));

assertTextEquals(
new File(testDir, "expected/simple-testutils-build.pom"),
new File(verifier.getArtifactPath(
"org.sonatype.mavenbook.multi", "simple-testutils", "0.9-MNG6957-SNAPSHOT", "pom", "build")));

assertTextEquals(
new File(testDir, "expected/utils-parent.pom"),
new File(verifier.getArtifactPath(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.io.File;

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

verifier.verifyErrorFreeLog();

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

assertThat(pom, containsString("projectProperty"));
assertThat(pom, not(containsString("activeProperty")));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ under the License.
<artifactId>simple-parent</artifactId>
<packaging>pom</packaging>
<name>Multi Chapter Simple Parent Project</name>



<build>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<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">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.sonatype.mavenbook.multi</groupId>
<artifactId>simple-parent</artifactId>
<version>0.9-MNG6656-SNAPSHOT</version>
</parent>
<artifactId>simple-weather</artifactId>
<packaging>jar</packaging>

<name>Multi Chapter Simple Weather API</name>

</project>
Original file line number Diff line number Diff line change
@@ -1,32 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<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">
<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">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.sonatype.mavenbook.multi</groupId>
<artifactId>simple-parent</artifactId>
<version>0.9-MNG6656-SNAPSHOT</version>
</parent>
<groupId>org.sonatype.mavenbook.multi</groupId>
<artifactId>simple-weather</artifactId>
<packaging>jar</packaging>

<version>0.9-MNG6656-SNAPSHOT</version>
<name>Multi Chapter Simple Weather API</name>

</project>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<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">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.sonatype.mavenbook.multi</groupId>
<artifactId>simple-parent</artifactId>
<version>0.9-MNG6656-SNAPSHOT</version>
</parent>

<artifactId>simple-webapp</artifactId>
<name>Multi Chapter Simple Web Application Project</name>
<dependencies>
<dependency>
<groupId>org.sonatype.mavenbook.multi</groupId>
<artifactId>simple-weather</artifactId>
<version>0.9-MNG6656-SNAPSHOT</version>
</dependency>
</dependencies>
<build>
<finalName>simple-webapp</finalName>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.3.2</version>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -1,49 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<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">
<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">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.sonatype.mavenbook.multi</groupId>
<artifactId>simple-parent</artifactId>
<version>0.9-MNG6656-SNAPSHOT</version>
</parent>

<groupId>org.sonatype.mavenbook.multi</groupId>
<artifactId>simple-webapp</artifactId>
<version>0.9-MNG6656-SNAPSHOT</version>
<name>Multi Chapter Simple Web Application Project</name>
<dependencies>
<dependency>
<groupId>org.sonatype.mavenbook.multi</groupId>
<artifactId>simple-weather</artifactId>
<version>0.9-MNG6656-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
</dependencies>
<build>
<finalName>simple-webapp</finalName>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.3.2</version>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<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">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.sonatype.mavenbook.multi</groupId>
<artifactId>utils-parent</artifactId>
<version>0.9-MNG6957-SNAPSHOT</version>
</parent>
<artifactId>simple-testutils</artifactId>
</project>
Original file line number Diff line number Diff line change
@@ -1,28 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<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">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.sonatype.mavenbook.multi</groupId>
<artifactId>utils-parent</artifactId>
<version>0.9-MNG6957-SNAPSHOT</version>
</parent>
<groupId>org.sonatype.mavenbook.multi</groupId>
<artifactId>simple-testutils</artifactId>
</project>
<version>0.9-MNG6957-SNAPSHOT</version>
</project>
Loading

0 comments on commit 352f78c

Please sign in to comment.