Maven-assembly-plugin ignoring manifestEntries?
We’re using this Maven plugin to generate a fat jar for a utility, effectively including all library dependencies un-jarred and re-jarred into a single distribution. The first part was easy, hooking the assembly goal of the maven-assembly-plugin onto the package goal in the maven build lifecycle. Our pom.xml had this entry in it
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<archive>
<manifest>
<mainClass>com.thekua.maven.ExampleProgram</mainClass>
</manifest>
</archive>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals><goal>assembly</goal></goals>
</execution>
</executions>
</plugin>
We tried adding in our own entry into the manifest, the CruisePipelineLabel, with a value that should be set by Cruise. We added the new section so our pom.xml now looked like this:
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<archive>
<manifest><mainClass>com.thekua.maven.ExampleProgram</mainClass></manifest>
<manifestEntries>
<CruisePipelineLabel>
${env.CRUISE_PIPELINE_LABEL}
</CruisePipelineLabel>
</manifestEntries>
</archive>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals><goal>assembly</goal></goals>
</execution>
</executions>
</plugin>
After running the target and inspecting the manifest.mf, I couldn’t see the additional property set. I did some searching, found this bug apparently fixed in the 2.2-beta-2 version. After some debugging, I found out that the plugin apparently does not include these additional entries if the value is not set. I tested this out by changing the line to:
<manifestEntries> <CruisePipelineLabel>aTestValue</CruisePipelineLabel> </manifestEntries>
So the answer to whether or not maven-assembly-plugin ignores an element in the manifestEntries is to ensure the value is set before testing it. It looks like a null value is interpreted as “don’t include”.