Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The maven assembly plugin moduleset sources instructions are not including any files and not matching the included modules

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?

like image 431
marathon Avatar asked Jun 26 '13 02:06

marathon


4 Answers

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!

like image 128
John Ament Avatar answered Nov 18 '22 04:11

John Ament


It worked for me using the following configuration:

  <includeSubModules>false</includeSubModules>
  <useAllReactorProjects>true</useAllReactorProjects>
like image 26
Nava Polak Onik Avatar answered Nov 18 '22 04:11

Nava Polak Onik


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
like image 2
AdrianRM Avatar answered Nov 18 '22 02:11

AdrianRM


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:

  • Include the relevant files into the jar (maybe the source plugin helps) and use dependencySet.
  • Change your module structure, such that module_assembly is the parent and module_parent and module_a are submodules. Of cource, the dependency structure remains as it is.
  • Just use a fileSet in the assembly with relative paths that point into the other project (ugly!)
like image 1
Alex Krauss Avatar answered Nov 18 '22 02:11

Alex Krauss