Issue
Here is the scenario:
Two Maven 3 project builds.
Build 1 has snapshot jars that get deployed to Nexus.
Build 2 has dependencies on the snapshots, referenced like 1.0.0-SNAPSHOT, that gets packaged up and zipped up using the mvn clean package assembly:single
command.
The issue that we run into: Occasionally when the assembly is being created, the MANIFEST file for the jar will sometimes say some.jar.1.0.0-SNAPSHOT and sometimes it will say some.jar.1.0.0-datetime stamp, thus causing class not defined errors.
Is there a way to prevent this naming issue in the manifest file?
--edit--
Further research has discovered the following:
"If the snapshot was resolved from a repo then it will be timestamped, if it came from the reactor or local repo, then it will be -SNAPSHOT. The plugin calls into the maven resolution logic so this is core maven behavior. "
This is the exact issue that is being run into. The 2nd build manifest file always has an entry of ./lib/Framework-1.0.0-SNAPSHOT.jar where as the actual jar file name changes between ./lib/Framework-1.0.0-SNAPSHOT.jar and ./lib/Framework-1.0.0-timestamp.jar based on the quote above.
Solution
In <dependencySet>
you need to set <outputFileNameMapping>${artifact.artifactId}-${artifact.baseVersion}.${artifact.extension}</outputFileNameMapping>
for example:
<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>appserverB</id>
<formats>
<format>zip</format>
</formats>
<dependencySets>
<dependencySet>
<outputDirectory>/lib</outputDirectory>
<outputFileNameMapping>${artifact.artifactId}-${artifact.baseVersion}.${artifact.extension}</outputFileNameMapping>
<includes>
<include>application:logging</include>
<include>application:core</include>
<include>application:utils</include>
<include>application:appserverB</include>
</includes>
</dependencySet>
</dependencySets>
</assembly>
If you are using one of the built-in assembly descriptors you will need to replicate it for your self and add in the outputFileNameMapping
entry yourself
Answered By - Stephen Connolly
Answer Checked By - Gilberto Lyons (JavaFixing Admin)