Author: evenisse
Date: Thu Nov 17 16:18:20 2005
New Revision: 345380
URL: http://svn.apache.org/viewcvs?rev=345380&view=rev
Log:
[MNG-1598] Allow user to not include META-INF/maven in jars
Modified:
maven/components/trunk/maven-archiver/src/main/java/org/apache/maven/archiver/MavenArchiveConfiguration.java
maven/components/trunk/maven-archiver/src/main/java/org/apache/maven/archiver/MavenArchiver.java
Modified:
maven/components/trunk/maven-archiver/src/main/java/org/apache/maven/archiver/MavenArchiveConfiguration.java
URL:
http://svn.apache.org/viewcvs/maven/components/trunk/maven-archiver/src/main/java/org/apache/maven/archiver/MavenArchiveConfiguration.java?rev=345380&r1=345379&r2=345380&view=diff
==============================================================================
---
maven/components/trunk/maven-archiver/src/main/java/org/apache/maven/archiver/MavenArchiveConfiguration.java
(original)
+++
maven/components/trunk/maven-archiver/src/main/java/org/apache/maven/archiver/MavenArchiveConfiguration.java
Thu Nov 17 16:18:20 2005
@@ -35,6 +35,8 @@
private boolean index;
+ private boolean addMavenDescriptor = true;
+
private File manifestFile;
private ManifestConfiguration manifest;
@@ -53,6 +55,11 @@
return index;
}
+ public boolean isAddMavenDescriptor()
+ {
+ return addMavenDescriptor;
+ }
+
public File getManifestFile()
{
return manifestFile;
@@ -75,6 +82,11 @@
public void setIndex( boolean index )
{
this.index = index;
+ }
+
+ public void setAddMavenDescriptor( boolean addMavenDescriptor )
+ {
+ this.addMavenDescriptor = addMavenDescriptor;
}
public void setManifestFile( File manifestFile )
Modified:
maven/components/trunk/maven-archiver/src/main/java/org/apache/maven/archiver/MavenArchiver.java
URL:
http://svn.apache.org/viewcvs/maven/components/trunk/maven-archiver/src/main/java/org/apache/maven/archiver/MavenArchiver.java?rev=345380&r1=345379&r2=345380&view=diff
==============================================================================
---
maven/components/trunk/maven-archiver/src/main/java/org/apache/maven/archiver/MavenArchiver.java
(original)
+++
maven/components/trunk/maven-archiver/src/main/java/org/apache/maven/archiver/MavenArchiver.java
Thu Nov 17 16:18:20 2005
@@ -216,55 +216,58 @@
public void createArchive( MavenProject project, MavenArchiveConfiguration
archiveConfiguration )
throws ArchiverException, ManifestException, IOException,
DependencyResolutionRequiredException
{
- //
----------------------------------------------------------------------
- // We want to add the metadata for the project to the JAR in two forms:
- //
- // The first form is that of the POM itself. Applications that wish to
- // access the POM for an artifact using maven tools they can.
- //
- // The second form is that of a properties file containing the basic
- // top-level POM elements so that applications that wish to access
- // POM information without the use of maven tools can do so.
- //
----------------------------------------------------------------------
-
- // we have to clone the project instance so we can write out the pom
with the deployment version,
- // without impacting the main project instance...
- MavenProject workingProject = new MavenProject( project );
-
- if ( workingProject.getArtifact().isSnapshot() )
+ if ( archiveConfiguration.isAddMavenDescriptor() )
{
- workingProject.setVersion(
workingProject.getArtifact().getVersion() );
- }
+ //
----------------------------------------------------------------------
+ // We want to add the metadata for the project to the JAR in two
forms:
+ //
+ // The first form is that of the POM itself. Applications that
wish to
+ // access the POM for an artifact using maven tools they can.
+ //
+ // The second form is that of a properties file containing the
basic
+ // top-level POM elements so that applications that wish to access
+ // POM information without the use of maven tools can do so.
+ //
----------------------------------------------------------------------
+
+ // we have to clone the project instance so we can write out the
pom with the deployment version,
+ // without impacting the main project instance...
+ MavenProject workingProject = new MavenProject( project );
- String groupId = workingProject.getGroupId();
+ if ( workingProject.getArtifact().isSnapshot() )
+ {
+ workingProject.setVersion(
workingProject.getArtifact().getVersion() );
+ }
- String artifactId = workingProject.getArtifactId();
+ String groupId = workingProject.getGroupId();
- File exportReadyPom = writeExportReadyPom( workingProject );
+ String artifactId = workingProject.getArtifactId();
- archiver.addFile( exportReadyPom, "META-INF/maven/" + groupId + "/" +
artifactId + "/pom.xml" );
+ File exportReadyPom = writeExportReadyPom( workingProject );
- //
----------------------------------------------------------------------
- // Create pom.properties file
- //
----------------------------------------------------------------------
+ archiver.addFile( exportReadyPom, "META-INF/maven/" + groupId +
"/" + artifactId + "/pom.xml" );
- Properties p = new Properties();
+ //
----------------------------------------------------------------------
+ // Create pom.properties file
+ //
----------------------------------------------------------------------
- p.setProperty( "groupId", workingProject.getGroupId() );
+ Properties p = new Properties();
- p.setProperty( "artifactId", workingProject.getArtifactId() );
+ p.setProperty( "groupId", workingProject.getGroupId() );
- p.setProperty( "version", workingProject.getVersion() );
+ p.setProperty( "artifactId", workingProject.getArtifactId() );
- File pomPropertiesFile = new File(
workingProject.getFile().getParentFile(), "pom.properties" );
+ p.setProperty( "version", workingProject.getVersion() );
- OutputStream os = new FileOutputStream( pomPropertiesFile );
+ File pomPropertiesFile = new File(
workingProject.getFile().getParentFile(), "pom.properties" );
- p.store( os, "Generated by Maven" );
+ OutputStream os = new FileOutputStream( pomPropertiesFile );
- os.close(); // stream is flushed but not closed by Properties.store()
+ p.store( os, "Generated by Maven" );
- archiver.addFile( pomPropertiesFile, "META-INF/maven/" + groupId + "/"
+ artifactId + "/pom.properties" );
+ os.close(); // stream is flushed but not closed by
Properties.store()
+
+ archiver.addFile( pomPropertiesFile, "META-INF/maven/" + groupId +
"/" + artifactId + "/pom.properties" );
+ }
//
----------------------------------------------------------------------
// Create the manifest