I’m building an assembly in Maven using a descriptor and I’m trying to simply do the following:
- Include the main project artifact (JAR) without any renaming.
- Include all project dependencies, renaming them.
Rename format:
${project.artifactId}-${project.version}.lib.${artifact.artifactId}.${artifact.extension}`
Currently, my assembly descriptor looks like this:
<?xml version="1.0"?>
<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>default</id>
<formats>
<format>tar.gz</format>
<format>zip</format>
</formats>
<dependencySets>
<dependencySet>
<useProjectArtifact>true</useProjectArtifact>
<outputDirectory>/</outputDirectory>
<excludes>
<exclude>*:*</exclude>
</excludes>
</dependencySet>
<dependencySet>
<useProjectArtifact>false</useProjectArtifact>
<outputDirectory>/</outputDirectory>
<outputFileNameMapping>
${project.artifactId}-${project.version}.lib.${artifact.artifactId}.${artifact.extension}
</outputFileNameMapping>
<unpack>false</unpack>
</dependencySet>
</dependencySets>
</assembly>
Unfortunately, I can’t seem to get the main project artifact to land in the distribution. What am I doing wrong?
You can use a
<files>block to include the project artifact itself separately:(For the
<source>there may be a more correct expression than the one above, but finding a complete list of available Maven properties is difficult. If anyone knows it, feel free to edit!)Lastly, as an aside, if any of your dependencies have classifiers you may want to consider adding
${dashClassifier?}to your<outputFileNameMapping>somewhere, or else the classifier will be missing from the filename.