Author: dennisl
Date: Tue Dec  6 13:40:22 2011
New Revision: 1210910

URL: http://svn.apache.org/viewvc?rev=1210910&view=rev
Log:
[MEAR-60] Improve support for skinny war files
Submitted by: Jeroen Ruijgers and Eric Pabst
Reviewed by: Dennis Lundberg

o The original patch by Jeroen was reformatted and rebased to current trunk by 
Eric.
o I made fixes for a couple of failing tests and added an integration test 
project.

Added:
    maven/plugins/trunk/maven-ear-plugin/src/it/skinny-wars/
    maven/plugins/trunk/maven-ear-plugin/src/it/skinny-wars/ear-module/
    maven/plugins/trunk/maven-ear-plugin/src/it/skinny-wars/ear-module/pom.xml  
 (with props)
    maven/plugins/trunk/maven-ear-plugin/src/it/skinny-wars/pom.xml   (with 
props)
    maven/plugins/trunk/maven-ear-plugin/src/it/skinny-wars/verify.bsh   (with 
props)
    maven/plugins/trunk/maven-ear-plugin/src/it/skinny-wars/war-module/
    maven/plugins/trunk/maven-ear-plugin/src/it/skinny-wars/war-module/pom.xml  
 (with props)
    maven/plugins/trunk/maven-ear-plugin/src/it/skinny-wars/war-module/src/
    maven/plugins/trunk/maven-ear-plugin/src/it/skinny-wars/war-module/src/main/
    
maven/plugins/trunk/maven-ear-plugin/src/it/skinny-wars/war-module/src/main/webapp/
    
maven/plugins/trunk/maven-ear-plugin/src/it/skinny-wars/war-module/src/main/webapp/WEB-INF/
    
maven/plugins/trunk/maven-ear-plugin/src/it/skinny-wars/war-module/src/main/webapp/WEB-INF/web.xml
   (with props)
Modified:
    
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/AbstractEarModule.java
    
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/EarModule.java
    
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/EarMojo.java
    
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/JarModule.java
    
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/WebModule.java

Added: 
maven/plugins/trunk/maven-ear-plugin/src/it/skinny-wars/ear-module/pom.xml
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ear-plugin/src/it/skinny-wars/ear-module/pom.xml?rev=1210910&view=auto
==============================================================================
--- maven/plugins/trunk/maven-ear-plugin/src/it/skinny-wars/ear-module/pom.xml 
(added)
+++ maven/plugins/trunk/maven-ear-plugin/src/it/skinny-wars/ear-module/pom.xml 
Tue Dec  6 13:40:22 2011
@@ -0,0 +1,53 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+<project>
+  <modelVersion>4.0.0</modelVersion>
+
+  <groupId>org.apache.maven.its.ear.skinnywars</groupId>
+  <artifactId>ear-module</artifactId>
+  <version>1.0</version>
+  <packaging>ear</packaging>
+
+  <dependencies>
+    <dependency>
+      <groupId>commons-lang</groupId>
+      <artifactId>commons-lang</artifactId>
+      <version>2.5</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.maven.its.ear.skinnywars</groupId>
+      <artifactId>war-module</artifactId>
+      <version>1.0</version>
+      <type>war</type>
+    </dependency>
+  </dependencies>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-ear-plugin</artifactId>
+        <version>@project.version@</version>
+      </plugin>
+    </plugins>
+  </build>
+</project>

Propchange: 
maven/plugins/trunk/maven-ear-plugin/src/it/skinny-wars/ear-module/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: maven/plugins/trunk/maven-ear-plugin/src/it/skinny-wars/pom.xml
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ear-plugin/src/it/skinny-wars/pom.xml?rev=1210910&view=auto
==============================================================================
--- maven/plugins/trunk/maven-ear-plugin/src/it/skinny-wars/pom.xml (added)
+++ maven/plugins/trunk/maven-ear-plugin/src/it/skinny-wars/pom.xml Tue Dec  6 
13:40:22 2011
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+<project>
+  <modelVersion>4.0.0</modelVersion>
+
+  <groupId>org.apache.maven.its.ear.skinnywars</groupId>
+  <artifactId>pom</artifactId>
+  <version>1.0</version>
+  <packaging>pom</packaging>
+
+  <description>Test Skinny WAR generation</description>
+
+  <modules>
+      <module>ear-module</module>
+      <module>war-module</module>
+  </modules>
+</project>

Propchange: maven/plugins/trunk/maven-ear-plugin/src/it/skinny-wars/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: maven/plugins/trunk/maven-ear-plugin/src/it/skinny-wars/verify.bsh
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ear-plugin/src/it/skinny-wars/verify.bsh?rev=1210910&view=auto
==============================================================================
--- maven/plugins/trunk/maven-ear-plugin/src/it/skinny-wars/verify.bsh (added)
+++ maven/plugins/trunk/maven-ear-plugin/src/it/skinny-wars/verify.bsh Tue Dec  
6 13:40:22 2011
@@ -0,0 +1,68 @@
+import java.io.*;
+import java.util.*;
+import java.util.jar.*;
+import java.util.regex.*;
+
+File jarFile = new File( basedir, 
"ear-module/target/ear-module-1.0/war-module-1.0.war" );
+System.out.println( "Checking for existence of " + jarFile );
+if ( !jarFile.isFile() )
+{
+    throw new IllegalStateException( "Missing file: " + jarFile );
+}
+
+JarFile jar = new JarFile( jarFile );
+
+String[] includedEntries = {
+    "WEB-INF/web.xml",
+    "META-INF/MANIFEST.MF"
+};
+for ( String included : includedEntries )
+{
+    System.out.println( "Checking for included archive entry " + included );
+    if ( jar.getEntry( included ) == null )
+    {
+        throw new IllegalStateException( "Missing archive entry: " + included 
);
+    }
+}
+
+String[] excludedEntries = {
+    "WEB-INF/lib/commons-lang-2.5.jar"
+};
+for ( String excluded : excludedEntries )
+{
+    System.out.println( "Checking for excluded artifact " + excluded );
+    if ( jar.getEntry( excluded ) != null )
+    {
+        throw new IllegalStateException( "Archive entry should be excluded: " 
+ included );
+    }
+}
+
+jar.close();
+
+
+File jarFile = new File( basedir, "war-module/target/war-module-1.0.war" );
+System.out.println( "Checking for existence of " + jarFile );
+if ( !jarFile.isFile() )
+{
+    throw new IllegalStateException( "Missing file: " + jarFile );
+}
+
+JarFile jar = new JarFile( jarFile );
+
+String[] includedEntries = {
+    "WEB-INF/web.xml",
+    "META-INF/MANIFEST.MF",
+    "WEB-INF/lib/commons-lang-2.5.jar"
+};
+for ( String included : includedEntries )
+{
+    System.out.println( "Checking for included archive entry " + included );
+    if ( jar.getEntry( included ) == null )
+    {
+        throw new IllegalStateException( "Missing archive entry: " + included 
);
+    }
+}
+
+jar.close();
+
+return true;

Propchange: maven/plugins/trunk/maven-ear-plugin/src/it/skinny-wars/verify.bsh
------------------------------------------------------------------------------
    svn:eol-style = native

Added: 
maven/plugins/trunk/maven-ear-plugin/src/it/skinny-wars/war-module/pom.xml
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ear-plugin/src/it/skinny-wars/war-module/pom.xml?rev=1210910&view=auto
==============================================================================
--- maven/plugins/trunk/maven-ear-plugin/src/it/skinny-wars/war-module/pom.xml 
(added)
+++ maven/plugins/trunk/maven-ear-plugin/src/it/skinny-wars/war-module/pom.xml 
Tue Dec  6 13:40:22 2011
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+<project>
+  <modelVersion>4.0.0</modelVersion>
+
+  <groupId>org.apache.maven.its.ear.skinnywars</groupId>
+  <artifactId>war-module</artifactId>
+  <version>1.0</version>
+  <packaging>war</packaging>
+
+  <dependencies>
+    <dependency>
+      <groupId>commons-lang</groupId>
+      <artifactId>commons-lang</artifactId>
+      <version>2.5</version>
+    </dependency>
+  </dependencies>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-war-plugin</artifactId>
+        <version>2.1.1</version>
+      </plugin>
+    </plugins>
+  </build>
+</project>

Propchange: 
maven/plugins/trunk/maven-ear-plugin/src/it/skinny-wars/war-module/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: 
maven/plugins/trunk/maven-ear-plugin/src/it/skinny-wars/war-module/src/main/webapp/WEB-INF/web.xml
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ear-plugin/src/it/skinny-wars/war-module/src/main/webapp/WEB-INF/web.xml?rev=1210910&view=auto
==============================================================================
--- 
maven/plugins/trunk/maven-ear-plugin/src/it/skinny-wars/war-module/src/main/webapp/WEB-INF/web.xml
 (added)
+++ 
maven/plugins/trunk/maven-ear-plugin/src/it/skinny-wars/war-module/src/main/webapp/WEB-INF/web.xml
 Tue Dec  6 13:40:22 2011
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 
2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd";>
+
+<web-app >
+</web-app>

Propchange: 
maven/plugins/trunk/maven-ear-plugin/src/it/skinny-wars/war-module/src/main/webapp/WEB-INF/web.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: 
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/AbstractEarModule.java
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/AbstractEarModule.java?rev=1210910&r1=1210909&r2=1210910&view=diff
==============================================================================
--- 
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/AbstractEarModule.java
 (original)
+++ 
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/AbstractEarModule.java
 Tue Dec  6 13:40:22 2011
@@ -365,4 +365,13 @@ public abstract class AbstractEarModule
         this.uri = uri;
 
     }
+
+    public boolean changeManifestClasspath()
+    {
+        return true;
+    }
+
+    public String getLibDir() {
+        return null;
+    }
 }

Modified: 
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/EarModule.java
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/EarModule.java?rev=1210910&r1=1210909&r2=1210910&view=diff
==============================================================================
--- 
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/EarModule.java
 (original)
+++ 
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/EarModule.java
 Tue Dec  6 13:40:22 2011
@@ -111,4 +111,8 @@ public interface EarModule
 
     public void setEarExecutionContext( EarExecutionContext 
earExecutionContext );
 
+    public boolean changeManifestClasspath();
+
+    public String getLibDir();
+
 }

Modified: 
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/EarMojo.java
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/EarMojo.java?rev=1210910&r1=1210909&r2=1210910&view=diff
==============================================================================
--- 
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/EarMojo.java
 (original)
+++ 
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/EarMojo.java
 Tue Dec  6 13:40:22 2011
@@ -34,18 +34,26 @@ import org.apache.maven.shared.filtering
 import org.codehaus.plexus.archiver.ArchiverException;
 import org.codehaus.plexus.archiver.UnArchiver;
 import org.codehaus.plexus.archiver.jar.JarArchiver;
+import org.codehaus.plexus.archiver.jar.Manifest;
+import org.codehaus.plexus.archiver.jar.Manifest.Attribute;
+import org.codehaus.plexus.archiver.jar.ManifestException;
 import org.codehaus.plexus.archiver.manager.ArchiverManager;
 import org.codehaus.plexus.archiver.manager.NoSuchArchiverException;
+import org.codehaus.plexus.archiver.zip.ZipArchiver;
+import org.codehaus.plexus.archiver.zip.ZipUnArchiver;
 import org.codehaus.plexus.util.DirectoryScanner;
 import org.codehaus.plexus.util.FileUtils;
 import org.codehaus.plexus.util.StringUtils;
 
 import java.io.File;
+import java.io.FileReader;
 import java.io.IOException;
+import java.io.PrintWriter;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Iterator;
 import java.util.List;
+import java.util.zip.ZipException;
 
 /**
  * Builds J2EE Enterprise Archive (EAR) files.
@@ -194,6 +202,20 @@ public class EarMojo
     private JarArchiver jarArchiver;
 
     /**
+     * The Zip archiver.
+     *
+     * @component role="org.codehaus.plexus.archiver.Archiver" role-hint="zip"
+     */
+    private ZipArchiver zipArchiver;
+
+    /**
+     * The Zip Un archiver.
+     *
+     * @component role="org.codehaus.plexus.archiver.UnArchiver" 
role-hint="zip"
+     */
+    private ZipUnArchiver zipUnArchiver;
+
+    /**
      * The archive configuration to use.
      * See <a 
href="http://maven.apache.org/shared/maven-archiver/index.html";>Maven Archiver 
Reference</a>.
      *
@@ -257,7 +279,7 @@ public class EarMojo
                 if ( !EarModuleFactory.standardArtifactTypes.contains( type ) )
                 {
                     throw new MojoExecutionException(
-                        "Invalid type[" + type + "] supported types are " + 
EarModuleFactory.standardArtifactTypes );
+                        "Invalid type [" + type + "] supported types are " + 
EarModuleFactory.standardArtifactTypes );
                 }
             }
             getLog().debug( "Initialized unpack types " + unpackTypesList );
@@ -289,7 +311,7 @@ public class EarMojo
                 if ( destinationFile.getCanonicalPath().equals( 
sourceFile.getCanonicalPath() ) )
                 {
                     getLog().info(
-                        "Skipping artifact[" + module + "], as it already 
exists at[" + module.getUri() + "]" );
+                        "Skipping artifact [" + module + "], as it already 
exists at [" + module.getUri() + "]" );
                     continue;
                 }
 
@@ -299,22 +321,32 @@ public class EarMojo
                     ( module.shouldUnpack() == null || 
module.shouldUnpack().booleanValue() ) ) ||
                     ( module.shouldUnpack() != null && 
module.shouldUnpack().booleanValue() ) )
                 {
-                    getLog().info( "Copying artifact[" + module + "] to[" + 
module.getUri() + "] (unpacked)" );
+                    getLog().info( "Copying artifact [" + module + "] to [" + 
module.getUri() + "] (unpacked)" );
                     // Make sure that the destination is a directory to avoid 
plexus nasty stuff :)
                     destinationFile.mkdirs();
                     unpack( sourceFile, destinationFile );
+
+                    if ( module.changeManifestClasspath() )
+                    {
+                        changeManifestClasspath( module, destinationFile );
+                    }
                 }
                 else
                 {
                     if ( sourceFile.lastModified() > 
destinationFile.lastModified() )
                     {
-                        getLog().info( "Copying artifact[" + module + "] to[" 
+ module.getUri() + "]" );
+                        getLog().info( "Copying artifact [" + module + "] to 
[" + module.getUri() + "]" );
                         FileUtils.copyFile( sourceFile, destinationFile );
+
+                        if ( module.changeManifestClasspath() )
+                        {
+                            changeManifestClasspath( module, destinationFile );
+                        }
                     }
                     else
                     {
                         getLog().debug(
-                            "Skipping artifact[" + module + "], as it is 
already up to date at[" + module.getUri() +
+                            "Skipping artifact [" + module + "], as it is 
already up to date at [" + module.getUri() +
                                 "]" );
                     }
                 }
@@ -398,7 +430,7 @@ public class EarMojo
             File earFile = getEarFile( outputDirectory, finalName, classifier 
);
             final MavenArchiver archiver = new EarMavenArchiver( getModules() 
);
             final JarArchiver jarArchiver = getJarArchiver();
-            getLog().debug( "Jar archiver implementation[" + 
jarArchiver.getClass().getName() + "]" );
+            getLog().debug( "Jar archiver implementation [" + 
jarArchiver.getClass().getName() + "]" );
             archiver.setArchiver( jarArchiver );
             archiver.setOutputFile( earFile );
 
@@ -485,7 +517,7 @@ public class EarMojo
         }
         else
         {
-            getLog().info( "Including custom manifest file[" + manifestFile + 
"]" );
+            getLog().info( "Including custom manifest file [" + manifestFile + 
"]" );
             archive.setManifestFile( manifestFile );
         }
     }
@@ -601,10 +633,142 @@ public class EarMojo
             }
             catch ( MavenFilteringException e )
             {
-                getLog().error( "fail to build filering wrappers " + 
e.getMessage() );
+                getLog().error( "Fail to build filtering wrappers " + 
e.getMessage() );
                 throw new MojoExecutionException( e.getMessage(), e );
             }
         }
         return filterWrappers;
     }
+
+    private void changeManifestClasspath( EarModule module, File original )
+            throws MojoFailureException
+    {
+        try
+        {
+            File workDirectory;
+
+            // Handle the case that the destination might be a directory 
(project-038)
+            if( original.isFile() )
+            {
+                // Create a temporary work directory
+                workDirectory = new File( new File(
+                        generatedDescriptorLocation, "temp" ), 
module.getArtifact()
+                        .getArtifactId() );
+                workDirectory.mkdirs();
+                getLog().debug( "Created a temporary work directory: " + 
workDirectory.getAbsolutePath() );
+
+                // Unpack the archive to a temporary work directory
+                zipUnArchiver.setSourceFile( original );
+                zipUnArchiver.setDestDirectory( workDirectory );
+                zipUnArchiver.extract();
+            }
+            else
+            {
+                workDirectory = original;
+            }
+
+            // Create a META-INF/MANIFEST.MF file if it doesn't exist 
(project-038)
+            File metaInfDirectory = new File( workDirectory, "META-INF" );
+            boolean newMetaInfCreated = metaInfDirectory.mkdirs();
+            if( newMetaInfCreated )
+            {
+                getLog().debug( "This project did not have a META-INF 
directory before, so a new directory was created." );
+            }
+            File manifestFile = new File( metaInfDirectory, "MANIFEST.MF" );
+            boolean newManifestCreated = manifestFile.createNewFile();
+            if( newManifestCreated )
+            {
+                getLog().debug( "This project did not have a 
META-INF/MANIFEST.MF file before, so a new file was created." );
+            }
+
+            // Read the manifest from disk
+            Manifest mf = new Manifest( new FileReader( manifestFile ) );
+            Attribute classPath = mf.getMainSection()
+                    .getAttribute( "Class-Path" );
+            List classPathElements = new ArrayList();
+
+            if ( classPath != null )
+            {
+                classPathElements.addAll( Arrays.asList( classPath.getValue()
+                        .split( " " ) ) );
+            } else
+            {
+                classPath = new Attribute( "Class-Path", "" );
+                mf.getMainSection().addConfiguredAttribute( classPath );
+            }
+
+            // Modify the classpath entries in the manifest
+            for ( Iterator iter = getModules().iterator(); iter.hasNext(); )
+            {
+                Object o = iter.next();
+
+                if ( o instanceof JarModule )
+                {
+                    JarModule jm = ( JarModule ) o;
+
+                    if ( module.getLibDir() != null )
+                    {
+                        File artifact = new File( new File(
+                                workDirectory, module.getLibDir() ),
+                                jm.getBundleFileName() );
+
+                        if ( artifact.exists() )
+                        {
+                            if ( !artifact.delete() )
+                            {
+                                getLog().error(
+                                        "Could not delete '" + artifact + "'" 
);
+                            }
+                        }
+                    }
+
+                    if ( classPathElements.contains( jm.getBundleFileName() ) )
+                    {
+                        classPathElements.set( classPathElements.indexOf( jm
+                                .getBundleFileName() ), jm.getUri() );
+                    }
+                    else
+                    {
+                        classPathElements.add( jm.getUri() );
+                    }
+                }
+            }
+            classPath.setValue( StringUtils.join( 
classPathElements.iterator(), " " ) );
+
+            // Write the manifest to disk
+            PrintWriter pw = new PrintWriter( manifestFile );
+            mf.write( pw );
+            pw.close();
+
+            if( original.isFile() )
+            {
+                // Pack up the archive again from the work directory
+                if ( !original.delete() )
+                {
+                    getLog().error( "Could not delete original artifact file " 
+ original );
+                }
+
+                getLog().debug( "Zipping module" );
+                zipArchiver.setDestFile( original );
+                zipArchiver.addDirectory( workDirectory );
+                zipArchiver.createArchive();
+            }
+        }
+        catch ( ManifestException e )
+        {
+            throw new MojoFailureException( e.getMessage() );
+        }
+        catch ( ZipException e )
+        {
+            throw new MojoFailureException( e.getMessage() );
+        }
+        catch ( IOException e )
+        {
+            throw new MojoFailureException( e.getMessage() );
+        }
+        catch ( ArchiverException e )
+        {
+            throw new MojoFailureException( e.getMessage() );
+        }
+    }
 }

Modified: 
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/JarModule.java
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/JarModule.java?rev=1210910&r1=1210909&r2=1210910&view=diff
==============================================================================
--- 
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/JarModule.java
 (original)
+++ 
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/JarModule.java
 Tue Dec  6 13:40:22 2011
@@ -97,4 +97,8 @@ public class JarModule
             this.bundleDir = defaultLibBundleDir;
         }
     }
+
+    public boolean changeManifestClasspath() {
+        return false;
+    }
 }

Modified: 
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/WebModule.java
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/WebModule.java?rev=1210910&r1=1210909&r2=1210910&view=diff
==============================================================================
--- 
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/WebModule.java
 (original)
+++ 
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/WebModule.java
 Tue Dec  6 13:40:22 2011
@@ -117,4 +117,8 @@ public class WebModule
         }
         return "/" + a.getArtifactId();
     }
+
+    public String getLibDir() {
+        return "WEB-INF/lib";
+    }
 }


Reply via email to