I have a multi-module maven project, and I'm trying to get the moduleset sources portion of the assembly plugin to work.
I have modules "module_parent", "module_a", and "module_assembly".
module_a and module_assembly are children of module_parent.
module_assembly has a declared pom dependency on module_a.
module_assmebly has the assembly plugin, with the assembly.xml looking like:
<?xml version="1.0"?>
<assembly>
<id>bin</id>
<formats>
<format>zip</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<moduleSets>
<moduleSet>
<useAllReactorProjects>true</useAllReactorProjects>
<includes>
<include>com.mystuff:module_a</include>
</includes>
<sources>
<fileSets>
<fileSet>
<outputDirectory>/</outputDirectory>
<excludes>
<exclude>**/target/**</exclude>
</excludes>
<directory>/</directory>
</fileSet>
</fileSets>
</sources>
</moduleSet>
</moduleSets>
</assembly> <!-- -->
I have an explicit dependency in module_assembly for module_a. The dependency in module_assembly's pom looks like:
<dependencies>
<dependency>
<groupId>com.mystuff</groupId>
<artifactId>module_a</artifactId>
<version>1.0</version>
<type>pom</type>
</dependency>
</dependencies>
The error I get from mvn package with debug turned on is:
[DEBUG] All known ContainerDescritporHandler components: [metaInf-services, plexus, metaInf-spring, file-aggregator]
[DEBUG] No dependency sets specified.
[WARNING] The following patterns were never triggered in this artifact inclusion filter:
o 'com.mystuff:module_a'
[DEBUG] Cannot find ArtifactResolver with hint: project-cache-aware
org.codehaus.plexus.component.repository.exception.ComponentLookupException: java.util.NoSuchElementException
role: org.apache.maven.artifact.resolver.ArtifactResolver
roleHint: project-cache-aware
at org.codehaus.plexus.DefaultPlexusContainer.lookup(DefaultPlexusContainer.java:257)
at org.codehaus.plexus.DefaultPlexusContainer.lookup(DefaultPlexusContainer.java:233)
at
<snip>
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
Caused by: java.util.NoSuchElementException
at java.util.Collections$EmptyIterator.next(Collections.java:3006)
at org.codehaus.plexus.DefaultPlexusContainer.lookup(DefaultPlexusContainer.java:253)
... 43 more
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
<snip>
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-assembly-plugin:2.2:single (make-assembly) on project apm-server-distribution: Failed to create assembly: Error creating assembly archive bin: You must set at least one file. -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-assembly-plugin:2.2:single (make-assembly) on project apm-server-distribution: Failed to create assembly: Error creating assembly archive bin: You must set at least one file.
I think the main problem is this warning line:
[WARNING] The following patterns were never triggered in this artifact inclusion filter:
o 'com.mystuff:module_a'
How do I correct this?
If module_assembly doesn't have a child reference to your module, it's not counted as a module. Note the content here refers to children only: http://maven.apache.org/plugins/maven-assembly-plugin/advanced-module-set-topics.html
If you want to do this, you need to use a dependencySet rather than a moduleSet.
PS - Thank you for the bounty!
It worked for me using the following configuration:
<includeSubModules>false</includeSubModules>
<useAllReactorProjects>true</useAllReactorProjects>
I was just debugging the assembly plugin, because I have a similar problen, and I think that the problem is <useAllReactorProjects>true</useAllReactorProjects>
. On top of that, there is also the tag <includeSubModules>
, which is probably what you want.
<assembly>
<id>bin</id>
<formats>
<format>zip</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<moduleSets>
<moduleSet>
<useAllReactorProjects>false</useAllReactorProjects><!-- Or just don't remove this line -->
<includeSubModules>true>
...
</moduleSet>
</moduleSets>
</assembly
What you are trying does not work, since module_a is not a submodule of module_assembly.
Here are some ideas of what you can do:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With