Custom maven build - how to copy external help folder

I am creating a simple Jar project with maven (last)
When running the maven package, I load the jar file into the target directory correctly,
I would like to configure the output so that maven will copy some files and dependencies to the target along with the bank.

Current folder structure:

/ -- resources -- src/main/java/com..(project sources) -- src/main/assembly (location of the assebmly.xml) 

Landing page target structure:

 target | -- myJar1.0.jar (the artiface) -- resources (from the root build folder) -- lib (all the dependancies) | -- anotherJar-1.0.jar -- anotherJar2-1.0.jar -- anotherJar3-1.0.jar 


I read the custom assembly on the apache website, I added the configuration to the maven-assembly-plugin and set up the assembly.xml file but I have to do something wrong, I am not getting the correct output.

Here is the assembly.xml file

 <assembly> <id/> <formats> <format>dir</format> </formats> <includeBaseDirectory>false</includeBaseDirectory> <dependencySets> <dependencySet> <outputDirectory>/lib</outputDirectory> </dependencySet> </dependencySets> <fileSets> <fileSet> <directory>target</directory> <outputDirectory>/lib</outputDirectory> <includes> <include>*.jar</include> </includes> </fileSet> <fileSet> <directory>resources</directory> <outputDirectory>/resources</outputDirectory> <includes> <include>*.*</include> </includes> </fileSet> </fileSets> 

The target directory contains lib with dependencies, but it is in the folder with the name of the artifact, the resource directory is not copied at all.

Please inform Thank you

+4
source share
2 answers

By design, the maven build plugin generates output in the target subfolder. This is done in order to avoid confusion with other artifacts that are created there ( classes , test-classes , etc.).

For non-copied resources, you can omit the <includes> section if you want the entire contents of the folder to be copied. Also, the first <fileSet> section is redundant.

Updated assembly.xml to place the project artifact in the root, dependent libraries in lib and resources in the resources folder of the assembly folder ...

 <assembly> <id/> <formats> <format>dir</format> </formats> <includeBaseDirectory>false</includeBaseDirectory> <dependencySets> <dependencySet> <outputDirectory>/lib</outputDirectory> <excludes> <exclude>${project.groupId}:${project.artifactId}</exclude> </excludes> </dependencySet> <dependencySet> <outputDirectory>/</outputDirectory> <includes> <include>${project.groupId}:${project.artifactId}</include> </includes> </dependencySet> </dependencySets> <fileSets> <fileSet> <directory>resources</directory> <outputDirectory>/resources</outputDirectory>> </fileSet> </fileSets> 
+4
source

I think you will need a Maven resource plugin for this purpose.

0
source

All Articles