You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by el...@apache.org on 2026/08/04 11:02:28 UTC
(maven-assembly-plugin) branch master updated: Improve module-set integration test coverage (#1343)
This is an automated email from the ASF dual-hosted git repository.
elharo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-assembly-plugin.git
The following commit(s) were added to refs/heads/master by this push:
new 20e5bc3e Improve module-set integration test coverage (#1343)
20e5bc3e is described below
commit 20e5bc3ee3eda0763ae4fceae296acccbdb2858b
Author: Václav Haisman <vh...@gmail.com>
AuthorDate: Tue Aug 4 13:02:23 2026 +0200
Improve module-set integration test coverage (#1343)
* Add coverage for includeDependencies=false
Give a selected module a runtime dependency. Verify that includeDependencies=false excludes it from the assembly.
* Add attachmentClassifier integration coverage
Create a classified module artifact. Verify that module binaries select it instead of the main artifact.
* Assert transitive module dependency inclusion
Extend the implied dependency-set IT. Verify that it includes a transitively-only artifact.
* Strengthen module-set integration assertions
---
.../using-moduleSet-implied-depSet/verify.bsh | 1 +
.../module-attachment-classifier/assembly/pom.xml | 54 ++++++++++++++++++++++
.../assembly/src/main/assembly/bin.xml | 43 +++++++++++++++++
.../pom.xml | 33 ++++++-------
.../producer}/pom.xml | 41 +++++++++-------
.../src/test/resources/attachment-marker.txt | 1 +
.../verify.groovy} | 35 ++++++--------
.../child1/pom.xml | 6 +++
.../multimodule-wholeReactorFromChild/verify.bsh | 11 +++++
9 files changed, 173 insertions(+), 52 deletions(-)
diff --git a/src/it/projects/dependency-sets/using-moduleSet-implied-depSet/verify.bsh b/src/it/projects/dependency-sets/using-moduleSet-implied-depSet/verify.bsh
index e241f8f2..7d6db166 100644
--- a/src/it/projects/dependency-sets/using-moduleSet-implied-depSet/verify.bsh
+++ b/src/it/projects/dependency-sets/using-moduleSet-implied-depSet/verify.bsh
@@ -23,6 +23,7 @@ boolean result = true;
result = result && new File( basedir, "module-b/target/module-b-1.0-SNAPSHOT-bin/modules/jdom-1.0.jar" ).exists();
result = result && new File( basedir, "module-b/target/module-b-1.0-SNAPSHOT-bin/modules/velocity-1.4.jar" ).exists();
+result = result && new File( basedir, "module-b/target/module-b-1.0-SNAPSHOT-bin/modules/velocity-dep-1.4.jar" ).exists();
result = result && new File( basedir, "module-b/target/module-b-1.0-SNAPSHOT-bin/modules/module-a.jar" ).exists();
result = result && new File( basedir, "module-b/target/module-b-1.0-SNAPSHOT-bin/modules/module-b.jar" ).exists();
diff --git a/src/it/projects/multimodule/module-attachment-classifier/assembly/pom.xml b/src/it/projects/multimodule/module-attachment-classifier/assembly/pom.xml
new file mode 100644
index 00000000..0d31283e
--- /dev/null
+++ b/src/it/projects/multimodule/module-attachment-classifier/assembly/pom.xml
@@ -0,0 +1,54 @@
+<?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.apache.maven.plugins.assembly.it</groupId>
+ <artifactId>module-attachment-classifier</artifactId>
+ <version>1.0</version>
+ </parent>
+
+ <artifactId>assembly</artifactId>
+
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>assembly</id>
+ <phase>package</phase>
+ <goals>
+ <goal>single</goal>
+ </goals>
+ <configuration>
+ <descriptors>
+ <descriptor>src/main/assembly/bin.xml</descriptor>
+ </descriptors>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/src/it/projects/multimodule/module-attachment-classifier/assembly/src/main/assembly/bin.xml b/src/it/projects/multimodule/module-attachment-classifier/assembly/src/main/assembly/bin.xml
new file mode 100644
index 00000000..bbc81ce8
--- /dev/null
+++ b/src/it/projects/multimodule/module-attachment-classifier/assembly/src/main/assembly/bin.xml
@@ -0,0 +1,43 @@
+<?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.
+-->
+<assembly xmlns="http://maven.apache.org/ASSEMBLY/2.2.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.2.0 https://maven.apache.org/xsd/assembly-2.2.0.xsd">
+ <id>bin</id>
+ <formats>
+ <format>dir</format>
+ </formats>
+ <includeBaseDirectory>false</includeBaseDirectory>
+ <moduleSets>
+ <moduleSet>
+ <useAllReactorProjects>true</useAllReactorProjects>
+ <includes>
+ <include>org.apache.maven.plugins.assembly.it:producer</include>
+ </includes>
+ <binaries>
+ <attachmentClassifier>tests</attachmentClassifier>
+ <includeDependencies>false</includeDependencies>
+ <outputDirectory>modules</outputDirectory>
+ <outputFileNameMapping>${module.artifactId}-${module.classifier}.${module.extension}</outputFileNameMapping>
+ <unpack>false</unpack>
+ </binaries>
+ </moduleSet>
+ </moduleSets>
+</assembly>
diff --git a/src/it/projects/multimodule/multimodule-wholeReactorFromChild/child1/pom.xml b/src/it/projects/multimodule/module-attachment-classifier/pom.xml
similarity index 57%
copy from src/it/projects/multimodule/multimodule-wholeReactorFromChild/child1/pom.xml
copy to src/it/projects/multimodule/module-attachment-classifier/pom.xml
index 671c33d2..d0ea48c5 100644
--- a/src/it/projects/multimodule/multimodule-wholeReactorFromChild/child1/pom.xml
+++ b/src/it/projects/multimodule/module-attachment-classifier/pom.xml
@@ -1,5 +1,4 @@
-<?xml version="1.0"?><project>
-
+<?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
@@ -18,22 +17,24 @@ 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>
- <artifactId>parent</artifactId>
- <groupId>org.test</groupId>
- <version>1.0</version>
+ <groupId>org.apache.maven.plugin.assembly.test</groupId>
+ <artifactId>it-project-parent</artifactId>
+ <version>1</version>
</parent>
- <modelVersion>4.0.0</modelVersion>
- <artifactId>child1</artifactId>
- <name>Child 1</name>
+
+ <groupId>org.apache.maven.plugins.assembly.it</groupId>
+ <artifactId>module-attachment-classifier</artifactId>
<version>1.0</version>
- <url>http://maven.apache.org</url>
- <dependencies>
- <dependency>
- <groupId>org.junit.jupiter</groupId>
- <artifactId>junit-jupiter-api</artifactId>
- <scope>test</scope>
- </dependency>
- </dependencies>
+ <packaging>pom</packaging>
+
+ <modules>
+ <module>producer</module>
+ <module>assembly</module>
+ </modules>
</project>
diff --git a/src/it/projects/multimodule/multimodule-wholeReactorFromChild/child1/pom.xml b/src/it/projects/multimodule/module-attachment-classifier/producer/pom.xml
similarity index 53%
copy from src/it/projects/multimodule/multimodule-wholeReactorFromChild/child1/pom.xml
copy to src/it/projects/multimodule/module-attachment-classifier/producer/pom.xml
index 671c33d2..db83f276 100644
--- a/src/it/projects/multimodule/multimodule-wholeReactorFromChild/child1/pom.xml
+++ b/src/it/projects/multimodule/module-attachment-classifier/producer/pom.xml
@@ -1,5 +1,4 @@
-<?xml version="1.0"?><project>
-
+<?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
@@ -18,22 +17,32 @@ 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>
- <artifactId>parent</artifactId>
- <groupId>org.test</groupId>
+ <groupId>org.apache.maven.plugins.assembly.it</groupId>
+ <artifactId>module-attachment-classifier</artifactId>
<version>1.0</version>
</parent>
- <modelVersion>4.0.0</modelVersion>
- <artifactId>child1</artifactId>
- <name>Child 1</name>
- <version>1.0</version>
- <url>http://maven.apache.org</url>
- <dependencies>
- <dependency>
- <groupId>org.junit.jupiter</groupId>
- <artifactId>junit-jupiter-api</artifactId>
- <scope>test</scope>
- </dependency>
- </dependencies>
+
+ <artifactId>producer</artifactId>
+
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-jar-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>attach-tests</id>
+ <goals>
+ <goal>test-jar</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
</project>
diff --git a/src/it/projects/multimodule/module-attachment-classifier/producer/src/test/resources/attachment-marker.txt b/src/it/projects/multimodule/module-attachment-classifier/producer/src/test/resources/attachment-marker.txt
new file mode 100644
index 00000000..1b490325
--- /dev/null
+++ b/src/it/projects/multimodule/module-attachment-classifier/producer/src/test/resources/attachment-marker.txt
@@ -0,0 +1 @@
+This file is present only in the attached test JAR.
diff --git a/src/it/projects/multimodule/multimodule-wholeReactorFromChild/verify.bsh b/src/it/projects/multimodule/module-attachment-classifier/verify.groovy
similarity index 55%
copy from src/it/projects/multimodule/multimodule-wholeReactorFromChild/verify.bsh
copy to src/it/projects/multimodule/module-attachment-classifier/verify.groovy
index a8dd3ccc..c73ed334 100644
--- a/src/it/projects/multimodule/multimodule-wholeReactorFromChild/verify.bsh
+++ b/src/it/projects/multimodule/module-attachment-classifier/verify.groovy
@@ -6,9 +6,9 @@
* 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
@@ -17,26 +17,21 @@
* under the License.
*/
-import java.io.*;
+import java.util.jar.JarFile
-boolean result = true;
+def modulesDirectory = new File(basedir, 'assembly/target/assembly-1.0-bin/modules')
+def attachment = new File(modulesDirectory, 'producer-tests.jar')
-if ( !new File( basedir, "child4/target/child4-1.0-bin/lib/child1.jar" ).exists() )
-{
- System.out.println( "Child-1 jar is NOT in output!" );
- result = false;
-}
+assert attachment.isFile() : "The attached test JAR is missing: ${attachment}"
-if ( !new File( basedir, "child4/target/child4-1.0-bin/lib/child3.jar" ).exists() )
-{
- System.out.println( "Child-3 jar is NOT in output!" );
- result = false;
-}
+def moduleArtifacts = modulesDirectory.listFiles()*.name.sort()
+assert moduleArtifacts == ['producer-tests.jar'] :
+ "Expected only the attached test JAR, but found: ${moduleArtifacts}"
-if ( new File( basedir, "child4/target/child4-1.0-bin/lib/child2.jar" ).exists() )
-{
- System.out.println( "Child-2 jar SHOULD NOT BE in output!" );
- result = false;
+def jar = new JarFile(attachment)
+try {
+ assert jar.getEntry('attachment-marker.txt') != null :
+ 'The selected artifact does not contain the attachment marker.'
+} finally {
+ jar.close()
}
-
-return result;
diff --git a/src/it/projects/multimodule/multimodule-wholeReactorFromChild/child1/pom.xml b/src/it/projects/multimodule/multimodule-wholeReactorFromChild/child1/pom.xml
index 671c33d2..abaf35a0 100644
--- a/src/it/projects/multimodule/multimodule-wholeReactorFromChild/child1/pom.xml
+++ b/src/it/projects/multimodule/multimodule-wholeReactorFromChild/child1/pom.xml
@@ -35,5 +35,11 @@ under the License.
<artifactId>junit-jupiter-api</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>commons-io</groupId>
+ <artifactId>commons-io</artifactId>
+ <!-- This runtime dependency must be excluded by includeDependencies=false. -->
+ <scope>runtime</scope>
+ </dependency>
</dependencies>
</project>
diff --git a/src/it/projects/multimodule/multimodule-wholeReactorFromChild/verify.bsh b/src/it/projects/multimodule/multimodule-wholeReactorFromChild/verify.bsh
index a8dd3ccc..199c64e6 100644
--- a/src/it/projects/multimodule/multimodule-wholeReactorFromChild/verify.bsh
+++ b/src/it/projects/multimodule/multimodule-wholeReactorFromChild/verify.bsh
@@ -18,6 +18,7 @@
*/
import java.io.*;
+import java.util.Arrays;
boolean result = true;
@@ -39,4 +40,14 @@ if ( new File( basedir, "child4/target/child4-1.0-bin/lib/child2.jar" ).exists()
result = false;
}
+File libDirectory = new File( basedir, "child4/target/child4-1.0-bin/lib" );
+File[] includedArtifacts = libDirectory.listFiles();
+
+if ( includedArtifacts == null || includedArtifacts.length != 2 )
+{
+ System.out.println( "Only the two selected module artifacts should be present when includeDependencies=false." );
+ System.out.println( "Files found: " + Arrays.toString( includedArtifacts ) );
+ result = false;
+}
+
return result;