Index: main/java/org/apache/maven/archiver/MavenArchiver.java =================================================================== --- main/java/org/apache/maven/archiver/MavenArchiver.java (revision 407340) +++ main/java/org/apache/maven/archiver/MavenArchiver.java (working copy) @@ -25,9 +25,12 @@ import org.codehaus.plexus.archiver.jar.ManifestException; import java.io.File; +import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io.OutputStream; +import java.text.SimpleDateFormat; +import java.util.Date; import java.util.Iterator; import java.util.List; import java.util.Map; @@ -43,7 +46,7 @@ private JarArchiver archiver; private File archiveFile; - + /** * Return a pre-configured manifest * @@ -219,6 +222,7 @@ MavenProject workingProject = new MavenProject( project ); File pomPropertiesFile = new File( workingProject.getFile().getParentFile(), "pom.properties" ); + boolean pomExists = pomPropertiesFile.exists(); if ( archiveConfiguration.isAddMavenDescriptor() ) { @@ -232,7 +236,7 @@ // top-level POM elements so that applications that wish to access // POM information without the use of maven tools can do so. // ---------------------------------------------------------------------- - + if ( workingProject.getArtifact().isSnapshot() ) { workingProject.setVersion( workingProject.getArtifact().getVersion() ); @@ -243,20 +247,29 @@ String artifactId = workingProject.getArtifactId(); archiver.addFile( project.getFile(), "META-INF/maven/" + groupId + "/" + artifactId + "/pom.xml" ); - - + + // ---------------------------------------------------------------------- // Create pom.properties file // ---------------------------------------------------------------------- Properties p = new Properties(); + if(pomExists) { + FileInputStream fis = new FileInputStream(pomPropertiesFile); + p.load(fis); + fis.close(); + } + SimpleDateFormat dateFormat = new SimpleDateFormat("MMM d yyyy HH:mm:ss z"); + p.setProperty( "groupId", workingProject.getGroupId() ); p.setProperty( "artifactId", workingProject.getArtifactId() ); p.setProperty( "version", workingProject.getVersion() ); + p.setProperty( "builtOn", dateFormat.format(new Date())); + OutputStream os = new FileOutputStream( pomPropertiesFile ); p.store( os, "Generated by Maven" ); @@ -302,7 +315,7 @@ ManifestSection section = (ManifestSection) iter.next(); Manifest.Section theSection = new Manifest.Section(); theSection.setName( section.getName() ); - + if( !section.isManifestEntriesEmpty() ) { Map entries = section.getManifestEntries(); Set keys = entries.keySet(); @@ -314,11 +327,11 @@ theSection.addConfiguredAttribute( attr ); } } - + manifest.addConfiguredSection( theSection ); } } - + // Configure the jar archiver.addConfiguredManifest( manifest ); @@ -332,7 +345,7 @@ archiver.createArchive(); // Cleanup - if ( archiveConfiguration.isAddMavenDescriptor() ) + if ( archiveConfiguration.isAddMavenDescriptor() && !pomExists ) { pomPropertiesFile.delete(); }