Java Ninja Chronicles By Norris Shelton

Things I learned in the pursuit of code

We were given a project that built a custom server. They had the need to deploy the code and the dependencies. The dependencies were placed in /lib via the maven-dependency-plugin. They were generating the MANIFEST.MF via the maven-jar-plugin. The problem was that what was in the manifest wasn’t exactly what was in the lib directory. An example is in the lib directory, there was a file named adapter-models-1.0-SNAPSHOT.jar. Unfortunately, the manifest contained adapter-models-1.0-20141201.182800-510.jar in the Class-Path, which was the unique snapshot identifier.

I fixed this by adding useUniqueVersions to their manifest element of the maven-jar-plugin.

            <plugin>
                <artifactId>maven-jar-plugin</artifactId>
                <configuration>
                    <archive>
                        <manifest>
                            <addClasspath>true</addClasspath>
                            <classpathPrefix>lib/</classpathPrefix>
                            <mainClass>com.this.and.that</mainClass>
                            <useUniqueVersions>false</useUniqueVersions>
                        </manifest>
                        <manifestEntries>
                            <Implementation-Version>${project.version}-${changeSet:} (${changeSetDate:})
                            </Implementation-Version>
                        </manifestEntries>
                    </archive>
                </configuration>
            </plugin>

December 1st, 2014

Posted In: Maven

Tags: , , , ,

Leave a Comment

LinkedIn Auto Publish Powered By : XYZScripts.com