Add jar-with-dependencies artifact from another Maven module

I have a multi-module Maven project. One of the modules is responsible for packing all the other modules into one supplied. I am currently facing a problem where my assembly cannot collect the output from other modules without receiving a message:

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

The following is a simplified version of my project layout, where moduleA is the project that creates the standard output jar-with-dependencies 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 created an assembly descriptor for moduleB , which 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 also listed moduleA as the dependency of moduleB in the moduleB pom.xml file (compilation scope). I did this because I believe that moduleA will be created moduleB ; it works.

Can anyone suggest why my assembly moduleB does not collect jar-with-dependations output from moduleA and complains that the template never starts?

I tried to specify groupId moduleA (and not use a wildcard), but that didn't help. I also tried to simplify the assembly descriptor for moduleB as follows, without any changes as a 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 : SSCCE for this problem 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)

+1
source share
3 answers

I think the problem is that you have a project with several modules, and you are trying to have a <moduleSet/> link that references one brother. From Including binary module files you can find this text:

The new useAllReactorProjects flag (starting with version 2.2) in the moduleSet section allows you to use binary files of modules from child modules in a multi-module assembly. This is important to resolve the conflict between ordering the Maven assembly and the old approach to the binaries of the modules where the assembly was created from the parent POM.

So, I updated your build file to this ( <useAllReactorProjects/> added) 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 removed the <attachmentClassifier>jar-with-dependencies</attachmentClassifier> tag <attachmentClassifier>jar-with-dependencies</attachmentClassifier> because it is completely wrong.

The conclusion is .tar.gz , which, I think, is what you want to achieve, although jar-with-dependencies points somewhat in a different direction. It is not clear what you want ...


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

+1
source

According to the Maven documentation, given the following project structure and all the relevant 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 only select the child1 module using the following module:

 <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 never used wildcards in the include option, can you mention a package instead of a wildcard?

0
source

In my case, I missed the inclusion of this module as a dependency in the POM and is only included in src.xml. This is just another place to see if you encounter a problem.

0
source

Source: https://habr.com/ru/post/957360/


All Articles