maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From car...@apache.org
Subject svn commit: r397235 - /maven/sandbox/wagon-scm/src/main/java/org/apache/maven/wagon/providers/scm/ScmWagon.java
Date Wed, 26 Apr 2006 16:56:06 GMT
Author: carlos
Date: Wed Apr 26 09:56:03 2006
New Revision: 397235

URL: http://svn.apache.org/viewcvs?rev=397235&view=rev
Log:
Add files with paths relative to basedir

Modified:
    maven/sandbox/wagon-scm/src/main/java/org/apache/maven/wagon/providers/scm/ScmWagon.java

Modified: maven/sandbox/wagon-scm/src/main/java/org/apache/maven/wagon/providers/scm/ScmWagon.java
URL: http://svn.apache.org/viewcvs/maven/sandbox/wagon-scm/src/main/java/org/apache/maven/wagon/providers/scm/ScmWagon.java?rev=397235&r1=397234&r2=397235&view=diff
==============================================================================
--- maven/sandbox/wagon-scm/src/main/java/org/apache/maven/wagon/providers/scm/ScmWagon.java
(original)
+++ maven/sandbox/wagon-scm/src/main/java/org/apache/maven/wagon/providers/scm/ScmWagon.java
Wed Apr 26 09:56:03 2006
@@ -16,6 +16,9 @@
  * limitations under the License.
  */
 
+import java.io.File;
+import java.io.IOException;
+
 import org.apache.maven.scm.ScmException;
 import org.apache.maven.scm.ScmFileSet;
 import org.apache.maven.scm.ScmResult;
@@ -37,9 +40,6 @@
 import org.codehaus.plexus.util.FileUtils;
 import org.codehaus.plexus.util.StringUtils;
 
-import java.io.File;
-import java.io.IOException;
-
 /**
  * @author <a href="brett@apache.org">Brett Porter</a>
  * @author <a href="evenisse@apache.org">Emmanuel Venisse</a>
@@ -184,7 +184,7 @@
 
             File basedir = scmFile.getParentFile();
 
-            String msg = "Adding " + resourceName + " to repository";
+            String msg = "Wagon: Adding " + scmFile.getName() + " to repository";
 
             ScmProvider scmProvider = scmManager.getProviderByRepository( scmRepository );
 
@@ -228,7 +228,7 @@
 
             if ( !fileAlreadyInScm || scmFile.isDirectory() )
             {
-                int addedFiles = addFiles( scmProvider, scmRepository, basedir, scmFile );
+                int addedFiles = addFiles( scmProvider, scmRepository, basedir, scmFile.getName()
);
                 if ( !fileAlreadyInScm && addedFiles == 0 )
                 {
                     throw new TransferFailedException( "Unable to add file to SCM: " + scmFile
);
@@ -261,17 +261,21 @@
      * Add a file or directory to a SCM repository.
      * If it's a directory all its contents are added recursively.
      * 
+     * TODO this is less than optimal, SCM API should provide a way to add a directory recursively
+     * 
      * @param scmProvider SCM provider
      * @param scmRepository SCM repository
      * @param basedir local directory corresponding to scmRepository
-     * @param scmFile file or directory to add
+     * @param scmFilePath path of the file or directory to add, relative to basedir
      * @throws ScmException
      * @return the number of files added.
      */
-    private int addFiles( ScmProvider scmProvider, ScmRepository scmRepository, File basedir,
File scmFile )
-        throws ScmException
+    private int addFiles( ScmProvider scmProvider, ScmRepository scmRepository, File basedir,
String scmFilePath )
+        throws ScmException, TransferFailedException
     {
-        AddScmResult result = scmProvider.add( scmRepository, new ScmFileSet( basedir, scmFile
) );
+        File scmFile = new File( basedir, scmFilePath );
+
+        AddScmResult result = scmProvider.add( scmRepository, new ScmFileSet( basedir, new
File( scmFilePath ) ) );
 
         int addedFiles = result.getAddedFiles().size();
 
@@ -285,7 +289,7 @@
             {
                 if ( reservedScmFile != null && !reservedScmFile.equals( files[i].getName()
) )
                 {
-                    addedFiles += addFiles( scmProvider, scmRepository, basedir, files[i]
);
+                    addedFiles += addFiles( scmProvider, scmRepository, basedir, scmFilePath
+ "/" + files[i].getName() );
                 }
             }
         }



Mime
View raw message