You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by ol...@apache.org on 2008/09/18 21:31:51 UTC

svn commit: r696776 - in /maven/shared/trunk/maven-filtering: pom.xml src/main/java/org/apache/maven/shared/filtering/DefaultMavenResourcesFiltering.java

Author: olamy
Date: Thu Sep 18 12:31:51 2008
New Revision: 696776

URL: http://svn.apache.org/viewvc?rev=696776&view=rev
Log:
use a private copyDirectoryLayout method to prevent a new directory scan

Modified:
    maven/shared/trunk/maven-filtering/pom.xml
    maven/shared/trunk/maven-filtering/src/main/java/org/apache/maven/shared/filtering/DefaultMavenResourcesFiltering.java

Modified: maven/shared/trunk/maven-filtering/pom.xml
URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-filtering/pom.xml?rev=696776&r1=696775&r2=696776&view=diff
==============================================================================
--- maven/shared/trunk/maven-filtering/pom.xml (original)
+++ maven/shared/trunk/maven-filtering/pom.xml Thu Sep 18 12:31:51 2008
@@ -21,7 +21,7 @@
   <parent>
     <groupId>org.apache.maven.shared</groupId>
     <artifactId>maven-shared-components</artifactId>
-    <version>9</version>
+    <version>10-SNAPSHOT</version>
   </parent>
 
   <prerequisites>
@@ -96,7 +96,7 @@
     <dependency>
       <groupId>org.codehaus.plexus</groupId>
       <artifactId>plexus-utils</artifactId>
-      <version>1.5.7-SNAPSHOT</version>
+      <version>1.5.6</version>
     </dependency>
     <dependency>
       <groupId>org.codehaus.plexus</groupId>
@@ -105,18 +105,4 @@
     </dependency>
   </dependencies>
   
-  <!-- remove when plexus-utils 1.5.7 released -->
-  <repositories>
-    <repository>
-      <id>snapshots.codehaus</id>
-        <url>http://snapshots.repository.codehaus.org/</url>
-        <releases>
-          <enabled>false</enabled>
-        </releases>
-        <snapshots>
-          <enabled>true</enabled>
-        </snapshots>
-      </repository>
-    </repositories>
-  
 </project>

Modified: maven/shared/trunk/maven-filtering/src/main/java/org/apache/maven/shared/filtering/DefaultMavenResourcesFiltering.java
URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-filtering/src/main/java/org/apache/maven/shared/filtering/DefaultMavenResourcesFiltering.java?rev=696776&r1=696775&r2=696776&view=diff
==============================================================================
--- maven/shared/trunk/maven-filtering/src/main/java/org/apache/maven/shared/filtering/DefaultMavenResourcesFiltering.java (original)
+++ maven/shared/trunk/maven-filtering/src/main/java/org/apache/maven/shared/filtering/DefaultMavenResourcesFiltering.java Thu Sep 18 12:31:51 2008
@@ -205,7 +205,7 @@
 
             if ( !resourceDirectory.exists() )
             {
-                // TODO how to log here ?
+                getLogger().info( "skip non existing resourceDirectory " + resourceDirectory.getPath() );
                 continue;
             }
 
@@ -242,14 +242,13 @@
             scanner.addDefaultExcludes();
             scanner.scan();
             
-            if (mavenResourcesExecution.isIncludeEmptyDirs())
+            if ( mavenResourcesExecution.isIncludeEmptyDirs() )
             {
                 try
                 {
-                    FileUtils.copyDirectoryLayout( resourceDirectory, targetPath == null ? outputDirectory
-                                                                                           : new File( outputDirectory,
-                                                                                                       targetPath ),
-                                                      includes, excludes );
+                    File targetDirectory = targetPath == null ? outputDirectory
+                                                             : new File( outputDirectory, targetPath );
+                    copyDirectoryLayout( resourceDirectory, targetDirectory, scanner );
                 }
                 catch ( IOException e )
                 {
@@ -301,5 +300,46 @@
 
     }
     
+    private void copyDirectoryLayout( File sourceDirectory, File destinationDirectory, DirectoryScanner scanner )
+        throws IOException
+    {
+        if ( sourceDirectory == null )
+        {
+            throw new IOException( "source directory can't be null." );
+        }
+
+        if ( destinationDirectory == null )
+        {
+            throw new IOException( "destination directory can't be null." );
+        }
+
+        if ( sourceDirectory.equals( destinationDirectory ) )
+        {
+            throw new IOException( "source and destination are the same directory." );
+        }
+
+        if ( !sourceDirectory.exists() )
+        {
+            throw new IOException( "Source directory doesn't exists (" + sourceDirectory.getAbsolutePath() + ")." );
+        }
+
+        List includedDirectories = Arrays.asList( scanner.getIncludedDirectories() );
+
+        for ( Iterator i = includedDirectories.iterator(); i.hasNext(); )
+        {
+            String name = (String) i.next();
+
+            File source = new File( sourceDirectory, name );
+
+            if ( source.equals( sourceDirectory ) )
+            {
+                continue;
+            }
+
+            File destination = new File( destinationDirectory, name );
+            destination.mkdirs();
+        }
+    }
+    
     
 }