From b0b047eff958769964ed687117be52822381d553 Mon Sep 17 00:00:00 2001 From: John Dennis Casey Date: Thu, 1 Dec 2005 21:32:42 +0000 Subject: [PATCH] PR: MNG-1650 Submitted By: Allan Ramirez Reviewed By: John Casey Applied patch, with modifications. First, refactored to avoid the use of a member variable for turning POM inclusion on/off. Second, please remember to follow the code formatting rules for Maven, available on the project website. This patch provides a new method for createArchive(..) which includes a flag for turning off POM inclusion from the resulting archive. The default mode used by the original createArchive(..) method is still to include POM information. git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@351476 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/maven/archiver/MavenArchiver.java | 22 +++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/maven-archiver/src/main/java/org/apache/maven/archiver/MavenArchiver.java b/maven-archiver/src/main/java/org/apache/maven/archiver/MavenArchiver.java index 6f3d6e84ac..04436d6857 100644 --- a/maven-archiver/src/main/java/org/apache/maven/archiver/MavenArchiver.java +++ b/maven-archiver/src/main/java/org/apache/maven/archiver/MavenArchiver.java @@ -45,7 +45,7 @@ public class MavenArchiver private JarArchiver archiver; private File archiveFile; - + /** * Return a pre-configured manifest * @@ -215,6 +215,13 @@ public class MavenArchiver public void createArchive( MavenProject project, MavenArchiveConfiguration archiveConfiguration ) throws ArchiverException, ManifestException, IOException, DependencyResolutionRequiredException + { + createArchive( project, archiveConfiguration, false ); + } + + public void createArchive( MavenProject project, MavenArchiveConfiguration archiveConfiguration, + boolean excludePomFiles ) + throws ArchiverException, ManifestException, IOException, DependencyResolutionRequiredException { // we have to clone the project instance so we can write out the pom with the deployment version, // without impacting the main project instance... @@ -246,8 +253,12 @@ public class MavenArchiver File exportReadyPom = writeExportReadyPom( workingProject ); - archiver.addFile( exportReadyPom, "META-INF/maven/" + groupId + "/" + artifactId + "/pom.xml" ); - + if( !excludePomFiles ) + { + archiver.addFile( exportReadyPom, "META-INF/maven/" + groupId + "/" + artifactId + "/pom.xml" ); + } + + // ---------------------------------------------------------------------- // Create pom.properties file // ---------------------------------------------------------------------- @@ -266,7 +277,10 @@ public class MavenArchiver os.close(); // stream is flushed but not closed by Properties.store() - archiver.addFile( pomPropertiesFile, "META-INF/maven/" + groupId + "/" + artifactId + "/pom.properties" ); + if( !excludePomFiles ) + { + archiver.addFile( pomPropertiesFile, "META-INF/maven/" + groupId + "/" + artifactId + "/pom.properties" ); + } } // ----------------------------------------------------------------------