From 30804e163a9e0a8b73f7ae5b6764eb1550d65d6f Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Mon, 22 Aug 2005 10:08:55 +0000 Subject: [PATCH] Now allowing custom manifest file to be set in the generated EAR file. git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@234462 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/maven/plugin/ear/EarMojo.java | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/maven-plugins/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/EarMojo.java b/maven-plugins/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/EarMojo.java index 195b8ab1b0..d52a6dc7b2 100644 --- a/maven-plugins/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/EarMojo.java +++ b/maven-plugins/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/EarMojo.java @@ -50,7 +50,6 @@ public class EarMojo * The location of the manifest file to be used within the ear file. * * @parameter expression="${basedir}/src/main/application/META-INF/MANIFEST.MF" - * @TODO handle this field */ private String manifestLocation; @@ -113,7 +112,7 @@ public class EarMojo if ( !sourceFile.isFile() ) { - throw new MojoExecutionException( "Cannot copy a directory: " + sourceFile.getAbsolutePath() + + throw new MojoExecutionException( "Cannot copy a directory: " + sourceFile.getAbsolutePath() + "; Did you package/install " + module.getArtifact().getId() + "?" ); } @@ -154,6 +153,9 @@ public class EarMojo MavenArchiver archiver = new MavenArchiver(); archiver.setOutputFile( earFile ); + // Include custom manifest if necessary + includeCustomManifestFile(); + archiver.getArchiver().addDirectory( getBuildDir() ); archiver.createArchive( getProject(), archive ); @@ -169,4 +171,18 @@ public class EarMojo { return new File( buildDir, uri ); } + + private void includeCustomManifestFile() + { + File customManifestFile = new File( manifestLocation ); + if ( !customManifestFile.exists() ) + { + // Does not exist so will use default + } + else + { + getLog().info( "Including custom manifest file[" + customManifestFile + "]" ); + archive.setManifestFile( customManifestFile ); + } + } }