This works for all situations although we mainly use it to include build
information on our demo web apps.

Create a properties file e.g. build.properties where any build variable
properties can be accessed by the java/jstl etc. Have your maven.xml build
update this file using the ant <propertyfile> task. e.g.

    <propertyfile file="${project.build.properties}" comment="Updated by
MAVEN build">
      <entry key="build.number" value="${project.build.label}"/>
      <entry key="build.date" type="date" value="now" pattern="dd/MM/yyyy
HH:mm"/>
      <entry key="version" value="${pom.currentVersion}"/>
    </propertyfile>

Andy


                                                                                
                                                             
                      [EMAIL PROTECTED]                                         
                                                       
                      lutions.com                    To:       
[EMAIL PROTECTED]                                                        
                                                     cc:                        
                                                             
                      06/12/2004 10:51               Subject:  RE: Best 
practise: embedding pom.currentVersion into source code              
                      Please respond to users                                   
                                                             
                                                                                
                                                             
                                                                                
                                                             




[EMAIL PROTECTED] wrote on Monday, December 06, 2004 11:09 AM:

> Hi all,
>
> I have a mavenised application, whose version number is contained in
> project.xml.
>
> I would like the app to build such that when you run "app
> --version", it gives the version number as specified in the
> pom when the program was built.
>
> What is the best practise way to do this?

I'll do this getting the value from the generated manifest. I build my app
with the javaapp plugin (see maven-plugins.sf.net) and you can access the
values with something like:

    public static void main(String[] args) {
        Package pkg = Manifest.class.getPackage();
        String specVersion = pkg.getSpecificationVersion();
        String implVersion = pkg.getImplementationVersion();
    }

Note, that the specification version is currently not available using the
jar plugin of Maven, this is fixed in the javaapp plugin. Additionally this
works only, if the classes are really loaded from the jar. Using this code
from within an IDE or a unit test it will fail.

- Jörg

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


PLEASE NOTE: THE ABOVE MESSAGE WAS RECEIVED FROM THE INTERNET.

On entering the GSi, this email was scanned for viruses by the Government
Secure Intranet (GSi) virus scanning service supplied exclusively by
Energis in partnership with MessageLabs.

Please see http://www.gsi.gov.uk/main/notices/information/gsi-003-2002.pdf
for further details.

In case of problems, please call your organisational IT helpdesk







For the latest data on the economy and society 
consult National Statistics at http://www.statistics.gov.uk

**********************************************************************
Please Note:  Incoming and outgoing email messages
are routinely monitored for compliance with our policy
on the use of electronic communications
**********************************************************************
Legal Disclaimer  :  Any views expressed by
the sender of this message are not necessarily
those of the Office for National Statistics
**********************************************************************

The original of this email was scanned for viruses by the Government Secure 
Intranet (GSi) virus scanning service supplied exclusively by Energis in 
partnership with MessageLabs.

On leaving the GSi this email was certified virus-free

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to