1

I have a multi-module Maven project. One of the modules is responsible for packaging up the outputs of all the other modules into one deliverable. I'm currently hitting a problem where my assembly is unable to gather the output from the other modules, failing with the message:

[WARNING] The following patterns were never triggered in this artifact 
  inclusion filter:
o  '*:a'

A simplified version of my project layout is show below, where moduleA is a project that builds a standard jar-with-dependencies output and moduleB is my module responsible for packaging. The root-level pom.xml lists moduleA and moduleB as modules.

parent
|- moduleA (foo:a)
   |- pom.xml
   |-src
     |- ...   
|- moduleB (foo:b)
   |- pom.xml
   |- src
      |- main
         |- assembly
            |- assembly.xml
|- pom.xml

I have created an assembly descriptor for moduleB that currently looks like this:

<assembly>
  <id>dist</id>
  <formats>
    <format>tar.gz</format>
  </formats>

  <moduleSets>
    <moduleSet>
      <includes>
        <include>*:a</include>
      </includes>
      <binaries>
        <attachmentClassifier>jar-with-dependencies</attachmentClassifier>
        <outputDirectory>package</outputDirectory>
        <dependencySets>
          <dependencySet>
            <excludes>
              <exclude>*:*</exclude>
            </excludes>
          </dependencySet>
        </dependencySets>
      </binaries>
    </moduleSet>
  </moduleSets>
</assembly>

I have also listed moduleA as a dependency of moduleB in moduleB's pom.xml file (compile scope). I have done this because I believe it will force moduleB to be built after moduleA; it appears to work.

Can anyone suggest why my moduleB assembly is not gathering up the jar-with-dependencies output from moduleA and complaining about the pattern never being triggered?

I have tried specifying the groupId of moduleA (rather than using a wildcard) but it has not helped. I have also attempted to simplify the assembly descriptor for moduleB as follows, without any change in result:

<assembly>
  <id>dist</id>
  <formats>
    <format>tar.gz</format>
  </formats>

  <moduleSets>
    <moduleSet>
      <includes>
        <include>foo:a</include>
      </includes>
      <binaries>
        <outputDirectory>package</outputDirectory>
        <dependencySets></dependencySets>
      </binaries>
    </moduleSet>
  </moduleSets>
</assembly>

NEW: A SSCCE for this issue can be found here: http://dl.dropbox.com/u/108474287/parent.zip

Maven version: Apache Maven 2.2.1 (r801777; 2009-08-06 20:16:01+0100)

Duncan Jones
  • 67,400
  • 29
  • 193
  • 254

3 Answers3

1

I think the problem is that you have a multi module project and you try to have a <moduleSet/> referencing a sibling. From the Including Module Binaries you can find this text:

The new (since 2.2) useAllReactorProjects flag in the moduleSet section allows you to consume module binaries from child modules in a multimodule build. This is an important to resolve the conflict between Maven's build ordering and the old approach to module binaries, where the assembly was build from the parent POM.

So I updated your assembly file to this (added <useAllReactorProjects/>) and got it working:

<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2
                              http://maven.apache.org/xsd/assembly-1.1.2.xsd">
    <id>dist</id>
    <formats>
        <format>tar.gz</format>
    </formats>

    <moduleSets>
        <moduleSet>
            <useAllReactorProjects>true</useAllReactorProjects>
            <includes>
                <include>*:a</include>
            </includes>
            <binaries>
                <outputDirectory>package</outputDirectory>
                <dependencySets>
                    <dependencySet>
                        <excludes>
                            <exclude>*:*</exclude>
                        </excludes>
                    </dependencySet>
                </dependencySets>
            </binaries>
        </moduleSet>
    </moduleSets>
</assembly>

NB I have removed the tag <attachmentClassifier>jar-with-dependencies</attachmentClassifier> since it is completely wrong.

The output is a .tar.gz which I think is what you want to achieve although that jar-with-dependencies is somewhat pointing in another direction. Not really clear to me what you want...


An alternative to the maven-assembly-plugin could be to use the maven-shade-plugin.

maba
  • 47,113
  • 10
  • 108
  • 118
  • Thank you. Infuriatingly, I read the documentation for [useAllReactorProjects](http://maven.apache.org/plugins/maven-assembly-plugin/assembly.html#class_moduleSet) but it confused me by saying "Default value is true. (Since 2.2)". Apparently not! – Duncan Jones Sep 26 '12 at 07:52
  • Also, please note that `jar-with-dependencies` is correct and achieves what I want (which is to attach the jar-with-dependencies output, not the standard output). – Duncan Jones Sep 26 '12 at 07:53
  • It's good that it worked. But the `` did not work for me so I assumed it was wrong. But I guess that your `foo:a` has that classifier which my test setup doesn't. – maba Sep 26 '12 at 07:55
  • Yes, that must be the case. My moduleA also has a POM configured to produce a jar-with-dependencies output. – Duncan Jones Sep 26 '12 at 07:56
  • FYI - I have created a Maven site issue to address the confusing statement regarding the default value for `useAllReactorProjects`: http://jira.codehaus.org/browse/MNGSITE-164 – Duncan Jones Sep 26 '12 at 08:06
  • I've got the same issue, however adding `useAllReactorProjects` has not fixed the problem. Is there anything else I could try? – thecoop Nov 04 '13 at 15:02
  • something that drove me crazy is that if you supply the `-rf` option to build that distribution module, it will fail and print the `The following patterns were never triggered in this artifact inclusion filter:` error – Martin Serrano May 18 '15 at 21:45
0

As per the Maven documentation, given the following project structure, and all appropriate module references in the parent POM:

+ parent (groupId: org.test, artifactId: parent)
  |
  + child1 (groupId: org.test, artifactId: child1)
  |
  + child2 (groupId: org.test, artifactId: child2)

We can select just the child1 module using the following moduleSet:

<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
  [...]
  <moduleSets>
    [...]
    <moduleSet>
      <includes>
        <include>org.test:child1</include>
      </includes>
    </moduleSet>
  </moduleSets>
  [...]
</assembly>

I have never used wildcards in the includes option, can you mention the package instead of the wildcard?

Anshu
  • 7,783
  • 5
  • 31
  • 41
  • I shall try without wildcards and will report back. I don't think this will help, however, as the Maven documentation (which I have read in some detail) suggests [wildcards are just fine](http://maven.apache.org/plugins/maven-assembly-plugin/assembly.html#class_moduleSet). – Duncan Jones Sep 25 '12 at 17:38
  • It has not helped. I've added some notes to my original question. – Duncan Jones Sep 26 '12 at 06:58
0

In my case I missed to include that module as the dependency in the POM and included in the src.xml only. It just another place to look at if you encounter the problem.

User2709
  • 573
  • 5
  • 17