]> source.dussan.org Git - archiva.git/commitdiff
put back a corrected custom copyDirectoryStructure that ignores .svn directories
authorBrett Porter <brett@apache.org>
Thu, 6 Jul 2006 05:50:09 +0000 (05:50 +0000)
committerBrett Porter <brett@apache.org>
Thu, 6 Jul 2006 05:50:09 +0000 (05:50 +0000)
git-svn-id: https://svn.apache.org/repos/asf/maven/repository-manager/trunk@419445 13f79535-47bb-0310-9956-ffa450edef68

maven-repository-converter/src/test/java/org/apache/maven/repository/converter/RepositoryConverterTest.java

index c60331de5631da1fcd8a0c2abcf38a25690a2002..d7b83cf7ec5e8c59e650c5d67f80f3e80e8b1af2 100644 (file)
@@ -83,7 +83,7 @@ public class RepositoryConverterTest
         layout = (ArtifactRepositoryLayout) lookup( ArtifactRepositoryLayout.ROLE, "default" );
 
         File targetBase = getTestFile( "target/test-target-repository" );
-        FileUtils.copyDirectoryStructure( getTestFile( "src/test/target-repository" ), targetBase );
+        copyDirectoryStructure( getTestFile( "src/test/target-repository" ), targetBase );
 
         targetRepository =
             factory.createArtifactRepository( "target", targetBase.toURL().toString(), layout, null, null );
@@ -97,6 +97,53 @@ public class RepositoryConverterTest
         reporter = new DefaultArtifactReporter();
     }
 
+    private void copyDirectoryStructure( File sourceDirectory, File destinationDirectory )
+        throws IOException
+    {
+        if ( !sourceDirectory.exists() )
+        {
+            throw new IOException( "Source directory doesn't exists (" + sourceDirectory.getAbsolutePath() + ")." );
+        }
+
+        File[] files = sourceDirectory.listFiles();
+
+        String sourcePath = sourceDirectory.getAbsolutePath();
+
+        for ( int i = 0; i < files.length; i++ )
+        {
+            File file = files[i];
+
+            String dest = file.getAbsolutePath();
+
+            dest = dest.substring( sourcePath.length() + 1 );
+
+            File destination = new File( destinationDirectory, dest );
+
+            if ( file.isFile() )
+            {
+                destination = destination.getParentFile();
+
+                FileUtils.copyFileToDirectory( file, destination );
+            }
+            else if ( file.isDirectory() )
+            {
+                if ( !".svn".equals( file.getName() ) )
+                {
+                    if ( !destination.exists() && !destination.mkdirs() )
+                    {
+                        throw new IOException(
+                            "Could not create destination directory '" + destination.getAbsolutePath() + "'." );
+                    }
+                    copyDirectoryStructure( file, destination );
+                }
+            }
+            else
+            {
+                throw new IOException( "Unknown file type: " + file.getAbsolutePath() );
+            }
+        }
+    }
+
     public void testV4PomConvert()
         throws IOException, RepositoryConversionException
     {