maven-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Artamonov, Juri" <jartamo...@fusionone.com>
Subject RE: Built-On date for my manifest
Date Mon, 19 Feb 2007 09:57:52 GMT
You can easily use your own plugin for setting that kind of stuff into
your manifest file. I believe you want to have this information for
every project where archive is the result of the build. Then you can
write the plugin (example listed below) and specify this plugin in
parent pom for your company for example.

1. Write plugin something like this:


/**
 * Goal which gets all information required fro manifest file.
 *
 * @goal create
 * @phase compile
 */
public class ManifestInformationMojo
    extends AbstractMojo
{
    /**
     * The maven project.
     *
     * @parameter expression="${project}"
     * @required
     * @readonly
     */
    private MavenProject project;

	public void execute() throws MojoExecutionException,
MojoFailureException { 
             
        String date = null;
        try
        {
            SimpleDateFormat sdf = new SimpleDateFormat();
            date = sdf.format(new Date());            
        }
        catch (RepositoryMetadataResolutionException e)
        {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        
        if ( project != null )
            {
                getLog().info( "Storing build date: " + date);
                //project.getProperties().put("buildNumber",
buildNumber);
                project.getProperties().put("date", date);
                
            }                     
    }

}

2. Specify the plugin in parent pom of your company for example
3. Specify in the pom.xml file for the archive plugin for the projects
where you need the date information the following:

			<archive>
						<manifestEntries>
	
<BuildDate>${date}</BuildDate>
						</manifestEntries>
			</archive>

In result you will have the date information you need in the
META-INF\Manifest.mf file.

Following this example you can write any information into Manifest file
like for example calculating by yourself Build Number for the project.

Best regards,
                 Juri.


-----Original Message-----
From: Brandon Goodin [mailto:brandon.goodin@gmail.com] 
Sent: Monday, February 19, 2007 6:22 AM
To: Maven Users List
Subject: Re: Built-On date for my manifest

We are currently using the buildnumber plugin to name our release with
the
svn repository revision number. We don't want the actual date involved
in
the release name. Are there any other solutions that have been used? I
was
thinking of trying to set an environment variable with antrun and then
use
it later on in the maven build and report.

Brandon

On 2/18/07, Tony Ambrozie <tony.ambrozie@gmail.com> wrote:
>
> You could try to use the buildnumber plugin:
>
http://commons.ucalgary.ca/projects/maven-buildnumber-plugin/howto.html
>
> Thanks'
>
>
> On 2/18/07, Brandon Goodin <brandon.goodin@gmail.com> wrote:
> >
> > I want to get the current date/time to add to my manifest file. Is
there
> a
> > simple property i can use to retrieve the current date/time. I'm
sorry
> if
> > this is a dumb question. But, i searched the list archives and
googled.
> I
> > came up empty.
> >
> > <archive>
> > ...
> >   <manifestEntries>
> >     <Build-On>... need date here... </Build-On>
> >   </manifestEntries>
> > ...
> > </archive>
> >
> > Thanks
> > Brandon
> >
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Mime
View raw message