You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by ar...@apache.org on 2006/04/12 10:45:41 UTC

svn commit: r393417 - /maven/plugins/trunk/maven-rar-plugin/src/main/java/org/apache/maven/plugin/rar/RarMojo.java

Author: aramirez
Date: Wed Apr 12 01:45:39 2006
New Revision: 393417

URL: http://svn.apache.org/viewcvs?rev=393417&view=rev
Log:
PR: MRAR-8

-exclude all files defined in the default exclude of DirectoryScanner

Modified:
    maven/plugins/trunk/maven-rar-plugin/src/main/java/org/apache/maven/plugin/rar/RarMojo.java

Modified: maven/plugins/trunk/maven-rar-plugin/src/main/java/org/apache/maven/plugin/rar/RarMojo.java
URL: http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-rar-plugin/src/main/java/org/apache/maven/plugin/rar/RarMojo.java?rev=393417&r1=393416&r2=393417&view=diff
==============================================================================
--- maven/plugins/trunk/maven-rar-plugin/src/main/java/org/apache/maven/plugin/rar/RarMojo.java (original)
+++ maven/plugins/trunk/maven-rar-plugin/src/main/java/org/apache/maven/plugin/rar/RarMojo.java Wed Apr 12 01:45:39 2006
@@ -24,6 +24,7 @@
 import org.apache.maven.artifact.Artifact;
 import org.codehaus.plexus.archiver.jar.JarArchiver;
 import org.codehaus.plexus.util.FileUtils;
+import org.codehaus.plexus.util.DirectoryScanner;
 
 import java.io.File;
 import java.io.IOException;
@@ -45,6 +46,7 @@
 {
     public static final String RA_XML_URI = "META-INF/ra.xml";
 
+    private static final String[] DEFAULT_INCLUDES = {"**/**"};
 
     /**
      * Single directory for extra files to include in the RAR.
@@ -186,10 +188,34 @@
             if ( rarSourceDir.exists() )
             {
                 getLog().info( "Copy rar resources to " + getBuildDir().getAbsolutePath() );
-                FileUtils.copyDirectoryStructure( rarSourceDir, getBuildDir() );
+
+                DirectoryScanner scanner = new DirectoryScanner();
+                scanner.setBasedir( rarSourceDir.getAbsolutePath() );
+                scanner.setIncludes( DEFAULT_INCLUDES );
+                scanner.addDefaultExcludes();
+                scanner.scan();
+
+                String[] dirs = scanner.getIncludedDirectories();
+
+                for ( int j = 0; j < dirs.length; j++ )
+                {
+                    new File( getBuildDir(), dirs[j] ).mkdirs();
+                }
+
+                String[] files = scanner.getIncludedFiles();
+
+                for ( int j = 0; j < files.length; j++ )
+                {
+                    File targetFile = new File( getBuildDir(), files[j] );
+
+                    targetFile.getParentFile().mkdirs();
+
+                    File file = new File( rarSourceDir, files[j] );
+                    FileUtils.copyFileToDirectory( file, targetFile.getParentFile() );
+                }
             }
         }
-        catch ( IOException e )
+        catch ( Exception e )
         {
             throw new MojoExecutionException( "Error copying RAR resources", e );
         }
@@ -243,6 +269,7 @@
     }
 
     private void includeCustomManifestFile()
+        throws IOException
     {
         File customManifestFile = manifestFile;
         if ( !customManifestFile.exists() )
@@ -253,6 +280,8 @@
         {
             getLog().info( "Including custom manifest file[" + customManifestFile + "]" );
             archive.setManifestFile( customManifestFile );
+            File metaInfDir = new File(getBuildDir(), "META-INF");
+            FileUtils.copyFileToDirectory( customManifestFile, metaInfDir );
         }
     }