Author: sagara
Date: Sun Dec  4 09:13:06 2011
New Revision: 1210082

URL: http://svn.apache.org/viewvc?rev=1210082&view=rev
Log:
Applied the patch for AXIS2-5206.

Modified:
    
axis/axis2/java/core/trunk/modules/tool/axis2-aar-maven-plugin/src/main/java/org/apache/axis2/maven2/aar/AbstractAarMojo.java

Modified: 
axis/axis2/java/core/trunk/modules/tool/axis2-aar-maven-plugin/src/main/java/org/apache/axis2/maven2/aar/AbstractAarMojo.java
URL: 
http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/tool/axis2-aar-maven-plugin/src/main/java/org/apache/axis2/maven2/aar/AbstractAarMojo.java?rev=1210082&r1=1210081&r2=1210082&view=diff
==============================================================================
--- 
axis/axis2/java/core/trunk/modules/tool/axis2-aar-maven-plugin/src/main/java/org/apache/axis2/maven2/aar/AbstractAarMojo.java
 (original)
+++ 
axis/axis2/java/core/trunk/modules/tool/axis2-aar-maven-plugin/src/main/java/org/apache/axis2/maven2/aar/AbstractAarMojo.java
 Sun Dec  4 09:13:06 2011
@@ -24,6 +24,8 @@ import org.apache.maven.artifact.resolve
 import org.apache.maven.plugin.AbstractMojo;
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.project.MavenProject;
+import org.codehaus.plexus.archiver.ArchiverException;
+import org.codehaus.plexus.archiver.jar.JarArchiver;
 import org.codehaus.plexus.util.DirectoryScanner;
 import org.codehaus.plexus.util.FileUtils;
 
@@ -240,16 +242,29 @@ public abstract class AbstractAarMojo
      *                                       TO DO: Remove this method when 
Maven moves to
      *                                       plexus-utils version 1.4
      */
-    private void copyFileIfModified(File source, File destination)
-            throws IOException {
-        // TO DO: Remove this method and use the method in WarFileUtils when 
Maven 2 changes
-        // to plexus-utils 1.2.
-        if (destination.lastModified() < source.lastModified()) {
-            FileUtils.copyFile(source.getCanonicalFile(), destination);
-            // preserve timestamp
-            destination.setLastModified(source.lastModified());
-        }
-    }
+       private void copyFileIfModified(File source, File destination)
+                       throws IOException {
+               // TO DO: Remove this method and use the method in WarFileUtils 
when
+               // Maven 2 changes
+               // to plexus-utils 1.2.
+               if (destination.lastModified() < source.lastModified()) {
+                       if (source.isDirectory()) {
+                               JarArchiver jarArchiver = new JarArchiver();
+                               try {
+                                       jarArchiver.setDestFile(destination);
+                                       
jarArchiver.addDirectory(source.getCanonicalFile());
+                                       jarArchiver.createArchive();
+                               } catch (ArchiverException e) {
+                                       // wrap ArchiverException in IOException
+                                       throw new IOException(e);
+                               }
+                       } else {
+                               FileUtils.copyFile(source.getCanonicalFile(), 
destination);
+                               // preserve timestamp
+                               
destination.setLastModified(source.lastModified());
+                       }
+               }
+       }
 
     private void copyFileSet(FileSet fileSet, File targetDirectory)
             throws IOException {


Reply via email to