Search code examples
maven-2maven-pluginmaven-assembly-pluginbuild-numbersbuildnumber-maven-plugin

buildnumber-maven-plugin and maven-assembly-plugin


I've set up the buildnumber-maven-plugin to pull the version number from SVN and stash it away in the META-INF/MANIFEST.MF inside the jar. That works ok.

But when I try to use it together with the maven-assembly-plugin to pack all the other libs together It doesn't seem to work, the version number stuff is not included in the manifest in the ...-jar-with-dependencies.jar.

Has anybody managed to get them to work together?

Alternatively: Is there a (reasonable simple) way to output the ${buildNumber} into a text file (.properties, perhaps) using Maven? An Ant task in Maven could do it I guess but is there an easier way?


Solution

  • Argh... after posting I found THIS: how to add arbitrary information in manifest from maven assembly plugin and smacked my head.

    OK, so My maven-assembly-plugin bit in the pom now looks like this

    <build> ... <plugins> ...
        <plugin>
                <artifactId>maven-assembly-plugin</artifactId>
                <configuration>
                    <archive>
                        <manifest>
                            <mainClass>...</mainClass>          
                            <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
                        </manifest>
                        <manifestEntries>
                            <Implementation-Build>${buildNumber}</Implementation-Build>
                        </manifestEntries>
                    </archive>
                    <descriptorRefs>
                        <descriptorRef>jar-with-dependencies</descriptorRef>
                    </descriptorRefs>
                </configuration>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>single</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>