repor...">

Module: link to another module from the handle

My build descriptor for module (APP1):

<?xml version="1.0" encoding="UTF-8"?> <assembly> <id>report</id> <formats> <format>jar</format> </formats> <includeBaseDirectory>false</includeBaseDirectory> <moduleSets> <moduleSet> <includes> <include>*-APP2</include>[trying to refer to another module ie module-APP2] </includes> <sources> <fileSets> <fileSet> <directory>/</directory> <includes> <include>**/target</include> </includes> </fileSet> </fileSets> <excludeSubModuleDirectories>false</excludeSubModuleDirectories> <outputDirectoryMapping>/</outputDirectoryMapping> </sources> </moduleSet> </moduleSets> </assembly> 

When I run mvn install cmd, I get

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

where am i wrong

I changed how:

 <?xml version="1.0" encoding="UTF-8"?><assembly> <id>report</id> <formats> <format>jar</format> </formats> <includeBaseDirectory>false</includeBaseDirectory> <moduleSets> <moduleSet> <includes> <include>sampleMaven:module-APP2</include> </includes> <sources> <fileSets> <fileSet> <directory>/</directory> <includes> <include>target/*</include> </includes> </fileSet> </fileSets> <excludeSubModuleDirectories>false</excludeSubModuleDirectories> <outputDirectoryMapping>/</outputDirectoryMapping> </sources> </moduleSet> </moduleSets> </assembly> 

still it turns out:

 [WARNING] The following patterns were never triggered in this artifact inclusion filter: o 'sampleMaven:module-APP2' 

Updated on 18 / sep: Home proj pom.xml →

http://maven.apache.org/maven-v4_0_0.xsd "> 4.0.0 sampleMaven ana 0.0.1-SNAPSHOT POM

APP1

 <module>APP2</module> 

2) For APP1, pom.xml - →

  <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 http://maven.apache.org/maven-v4_0_0.xsd"> 

ana sampleMaven 0.0.1-SNAPSHOT 4.0.0 sampleMaven APP1 APP1 0.0.1-SNAPSHOT
.. / APP 2

 <build> <plugins> <plugin> <artifactId>maven-assembly-plugin</artifactId> <version>2.2-beta-3</version> <executions> <execution> <id>assemblyone</id> <phase>compile</phase> <goals> <goal>single</goal> </goals> <configuration> <finalName>App1</finalName> <appendAssemblyId>false</appendAssemblyId> <descriptors> <descriptor>${basedir}/src/main/resources/assemblies/report.xml</descriptor> </descriptors> </configuration> </execution> </executions> </plugin> </plugins> </build> </project> ... 

3) Assembly descriptor →

the report is clear false

  <sources> <fileSets> <fileSet> <directory>/</directory> <includes> <include>target/*</include> </includes> </fileSet> </fileSets> <excludeSubModuleDirectories>false</excludeSubModuleDirectories> <outputDirectoryMapping>/</outputDirectoryMapping> </sources> <binaries> <outputDirectory> ${module.artifactId}-${module.version} </outputDirectory> <dependencySets> <dependencySet/> </dependencySets> </binaries> </moduleSet> 

When starting gettting -> stacktrace Error:

org.apache.maven.project.DuplicateProjectException: Project 'sampleMaven: APP2' is duplicated in the reactor

+4
source share
2 answers

Update. The Maven book has a section including modulesSets in assemblies. The approach that you have in your example is out of date. There is also a problem with the assembly order when defining modules from parent sets. The parent must be created first so that the child can inherit it, but the child must be built so that the parent can include it in its assembly. The following approach relates to this cycle.

Define the parent pom that references the assembly module.

 <?xml version="1.0" encoding="UTF-8"?> <project> <modelVersion>4.0.0</modelVersion> <groupId>name.seller.rich</groupId> <artifactId>test-parent</artifactId> <packaging>pom</packaging> <version>1.0.0</version> <modules> <module>test-assembly</module> </modules> <dependencies> </project> 

In the assembly module, define the module with a relative path to the actual application module (s) and define the configuration of the assembly plugin:

 <?xml version="1.0" encoding="UTF-8"?> <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 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>name.seller.rich</groupId> <artifactId>test-assembly</artifactId> <packaging>pom</packaging> <version>1.0.0-SNAPSHOT</version> <modules> <module>../my-app2</module> </modules> <build> <plugins> <plugin> <artifactId>maven-assembly-plugin</artifactId> <version>2.2-beta-4</version> <executions> <execution> <id>assembly</id> <phase>package</phase> <goals> <goal>single</goal> </goals> <configuration> <finalName>App1</finalName> <appendAssemblyId>false</appendAssemblyId> <descriptors> <descriptor>src/main/assembly/my-assembly.xml</descriptor> </descriptors> </configuration> </execution> </executions> </plugin> </plugins> </build> </project> 

and my-assembly.xml is defined as follows:

 <?xml version="1.0" encoding="UTF-8"?><assembly> <id>my-assembly</id> <formats> <format>jar</format> </formats> <includeBaseDirectory>false</includeBaseDirectory> <moduleSets> <moduleSet> <binaries> <outputDirectory> ${module.artifactId}-${module.version} </outputDirectory> <dependencySets> <dependencySet/> </dependencySets> </binaries> </moduleSet> </moduleSets> </assembly> 

Building a parent module will result in an assembly order:

  • parent test
  • my-app2
  • test assembly

So, when the assembly is packaged, my-app2 will be built and available for inclusion. The binary declaration will contain banks.

+3
source

I'm still looking for a solution to build a mutli module application, and I think I'm almost there !!! :-)

The trick is to create a separate module and not add it to the parent, because you want to create your parent (which builds all the modules) and then call the assembly.

I have a zip file that contains everything I need, only an executable banker does not include sources ... but I will try to figure it out as soon as possible. If I can make it work, I will insert this solution here :)

Peace

+2
source

All Articles