0

I have a parent pom.xml which builds a series of modules. As part of the parent pom.xml I read a configuration and put a number of variables into the build environment:

 BUILD_DATE=2014/07/24 15\:37\:06
 BUILD_NUMBER=78
 VERSION=GGY1.6

I wish to place this information into the manifest jar file. I am doing this as follows:

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-jar-plugin</artifactId>
            <configuration>
                <finalName>atf</finalName>
                <archive>
                    <manifestEntries>
                        <Built-Date>${maven.build.timestamp}</Built-Date>
                        <Version>${VERSION}B${BUILD_NUMBER}</Version>
                    </manifestEntries>
                </archive>
            </configuration>
        </plugin>

I am not sure which section of the pom.xml this should go into. I have put it in the build phase, and in some modules this works out ok, but in others it comes out in the manifest as:

Created-By: Apache Maven 3.0.5
Built-Date: 28/07/2014-16:00
Version: ${VERSION}B${BUILD_NUMBER}
Archiver-Version: Plexus Archiver

Is there a specific place in the pom.xml I need to put the maven-jar-plugin in order for it to pick up variables created by the parent?

eeijlar
  • 1,232
  • 3
  • 20
  • 53
  • Try `${env.VERSION}`, although I'm not quite sure that would work. You should be passing these as arguments to the JVM by passing in `MAVEN_OPTS=-DVERSION=$VERSION -DBUILD_NUMBER=$BUILD_NUMBER`. – carlspring Jul 28 '14 at 15:31

1 Answers1

0

I think the missing piece in the modules pom.xml files was this:

        <plugin><groupId>org.codehaus.mojo</groupId>
            <artifactId>properties-maven-plugin</artifactId>
        </plugin>

Any module pom which had this piece added, populated the manifest correctly... along with the maven-jar-plugin snippet. It looks like both are needed in order to access the values set by the parent pom.xml

eeijlar
  • 1,232
  • 3
  • 20
  • 53