I am building a simple Jar project with maven(latest)
When running maven package, I get the jar file at the target directory correctly,
I would like to customize the output so maven will copy some files and dependencies to the target alongside the jar.
The current folder structure is:
/
-- resources
-- src/main/java/com..(project sources)
-- src/main/assembly (location of the assebmly.xml)
The desired target directory structure is:
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 custom assembly on apache web site,
I added the configuration to maven-assembly-plugin and configured the assembly.xml
but I must do something wrong, I dont get the correct output,
Here is the assembly.xml
<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 contain the lib with dependencies but it is located in folder with the artifact name,
The resources directory is not being copy at all.
Please advise
Thank you
By design, maven assembly plugin creates output in a subfolder of target. This is to avoid confusion with other artifacts which get created therein (
classes,test-classes, etc.).As for resources not getting copied, 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.xmlto place project artifact in root, dependant libraries in lib and resources in resources folder of the assembly folder…