You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm-commits@maven.apache.org by br...@apache.org on 2005/02/17 01:52:19 UTC
cvs commit: maven-scm/maven-scm-providers/maven-scm-provider-svn/src/main/java/org/apache/maven/scm/provider/svn/command SvnCommandLineUtils.java
brett 2005/02/16 16:52:19
Modified: maven-scm-providers/maven-scm-provider-svn/src/main/java/org/apache/maven/scm/provider/svn/command/add
SvnAddCommand.java
maven-scm-providers/maven-scm-provider-svn/src/main/java/org/apache/maven/scm/provider/svn/command/changelog
SvnChangeLogCommand.java
maven-scm-providers/maven-scm-provider-svn/src/main/java/org/apache/maven/scm/provider/svn/command/checkin
SvnCheckInCommand.java
maven-scm-providers/maven-scm-provider-svn/src/main/java/org/apache/maven/scm/provider/svn/command/checkout
SvnCheckOutCommand.java
maven-scm-providers/maven-scm-provider-svn/src/main/java/org/apache/maven/scm/provider/svn/command/diff
SvnDiffCommand.java
maven-scm-providers/maven-scm-provider-svn/src/main/java/org/apache/maven/scm/provider/svn/command/status
SvnStatusCommand.java
maven-scm-providers/maven-scm-provider-svn/src/main/java/org/apache/maven/scm/provider/svn/command/tag
SvnTagCommand.java
maven-scm-providers/maven-scm-provider-svn/src/main/java/org/apache/maven/scm/provider/svn/command/update
SvnUpdateCommand.java
Added: maven-scm-providers/maven-scm-provider-svn/src/main/java/org/apache/maven/scm/provider/svn/command
SvnCommandLineUtils.java
Log:
make --username, --password and --non-interactive global options applied to all
Revision Changes Path
1.5 +10 -12 maven-scm/maven-scm-providers/maven-scm-provider-svn/src/main/java/org/apache/maven/scm/provider/svn/command/add/SvnAddCommand.java
Index: SvnAddCommand.java
===================================================================
RCS file: /home/cvs/maven-scm/maven-scm-providers/maven-scm-provider-svn/src/main/java/org/apache/maven/scm/provider/svn/command/add/SvnAddCommand.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- SvnAddCommand.java 11 Jan 2005 09:49:07 -0000 1.4
+++ SvnAddCommand.java 17 Feb 2005 00:52:19 -0000 1.5
@@ -23,6 +23,8 @@
import org.apache.maven.scm.command.add.AddScmResult;
import org.apache.maven.scm.provider.ScmProviderRepository;
import org.apache.maven.scm.provider.svn.command.SvnCommand;
+import org.apache.maven.scm.provider.svn.command.SvnCommandLineUtils;
+import org.apache.maven.scm.provider.svn.repository.SvnScmProviderRepository;
import org.codehaus.plexus.util.cli.CommandLineException;
import org.codehaus.plexus.util.cli.CommandLineUtils;
import org.codehaus.plexus.util.cli.Commandline;
@@ -52,7 +54,8 @@
throw new ScmException( "You must provide at least one file/directory to add" );
}
- Commandline cl = createCommandLine( fileSet.getBasedir(), fileSet.getFiles() );
+ Commandline cl = createCommandLine( fileSet.getBasedir(), fileSet.getFiles(),
+ (SvnScmProviderRepository) repository );
SvnAddConsumer consumer = new SvnAddConsumer( getLogger() );
@@ -80,23 +83,18 @@
return new AddScmResult( consumer.getAddedFiles() );
}
- public static Commandline createCommandLine( File workingDirectory, File[] files )
+ public static Commandline createCommandLine( File workingDirectory, File[] files,
+ SvnScmProviderRepository repository )
{
- Commandline cl = new Commandline();
-
- cl.setExecutable( "svn" );
-
- cl.setWorkingDirectory( workingDirectory.getAbsolutePath() );
+ Commandline cl = SvnCommandLineUtils.getBaseSvnCommandLine( workingDirectory, repository );
cl.createArgument().setValue( "add" );
cl.createArgument().setValue( "--non-recursive" );
- for ( int i = 0; i < files.length; i++ )
- {
- cl.createArgument().setValue( files[i].getPath().replace( '\\', '/' ) );
- }
+ SvnCommandLineUtils.addFiles( cl, files );
return cl;
}
+
}
1.5 +7 -25 maven-scm/maven-scm-providers/maven-scm-provider-svn/src/main/java/org/apache/maven/scm/provider/svn/command/changelog/SvnChangeLogCommand.java
Index: SvnChangeLogCommand.java
===================================================================
RCS file: /home/cvs/maven-scm/maven-scm-providers/maven-scm-provider-svn/src/main/java/org/apache/maven/scm/provider/svn/command/changelog/SvnChangeLogCommand.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- SvnChangeLogCommand.java 24 Dec 2004 03:04:47 -0000 1.4
+++ SvnChangeLogCommand.java 17 Feb 2005 00:52:19 -0000 1.5
@@ -22,6 +22,7 @@
import org.apache.maven.scm.command.changelog.ChangeLogScmResult;
import org.apache.maven.scm.provider.ScmProviderRepository;
import org.apache.maven.scm.provider.svn.command.SvnCommand;
+import org.apache.maven.scm.provider.svn.command.SvnCommandLineUtils;
import org.apache.maven.scm.provider.svn.repository.SvnScmProviderRepository;
import org.codehaus.plexus.util.cli.Commandline;
@@ -58,22 +59,17 @@
//
// ----------------------------------------------------------------------
- public static Commandline createCommandLine( SvnScmProviderRepository repository, File workingDirectory, String branch, Date startDate, Date endDate )
+ public static Commandline createCommandLine( SvnScmProviderRepository repository, File workingDirectory,
+ String branch, Date startDate, Date endDate )
{
SimpleDateFormat dateFormat = new SimpleDateFormat( DATE_FORMAT );
dateFormat.setTimeZone( TimeZone.getTimeZone( "GMT" ) );
- Commandline cl = new Commandline();
-
- cl.setExecutable( "svn" );
-
- cl.setWorkingDirectory( workingDirectory.getAbsolutePath() );
+ Commandline cl = SvnCommandLineUtils.getBaseSvnCommandLine( workingDirectory, repository );
cl.createArgument().setValue( "log" );
- cl.createArgument().setValue( "--non-interactive" );
-
cl.createArgument().setValue( "-v" );
if ( startDate != null )
@@ -82,8 +78,8 @@
if ( endDate != null )
{
- cl.createArgument().setValue( "{" + dateFormat.format( startDate ) + "}" + ":" +
- "{" + dateFormat.format( endDate ) + "}" );
+ cl.createArgument().setValue( "{" + dateFormat.format( startDate ) + "}" + ":" + "{" + dateFormat.format(
+ endDate ) + "}" );
}
else
{
@@ -99,20 +95,6 @@
}
}
- if ( repository.getUser() != null )
- {
- cl.createArgument().setValue( "--username" );
-
- cl.createArgument().setValue( repository.getUser() );
- }
-
- if ( repository.getPassword() != null )
- {
- cl.createArgument().setValue( "--password" );
-
- cl.createArgument().setValue( repository.getPassword() );
- }
-
cl.createArgument().setValue( repository.getUrl() );
return cl;
1.5 +10 -31 maven-scm/maven-scm-providers/maven-scm-provider-svn/src/main/java/org/apache/maven/scm/provider/svn/command/checkin/SvnCheckInCommand.java
Index: SvnCheckInCommand.java
===================================================================
RCS file: /home/cvs/maven-scm/maven-scm-providers/maven-scm-provider-svn/src/main/java/org/apache/maven/scm/provider/svn/command/checkin/SvnCheckInCommand.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- SvnCheckInCommand.java 3 Jan 2005 03:19:56 -0000 1.4
+++ SvnCheckInCommand.java 17 Feb 2005 00:52:19 -0000 1.5
@@ -21,6 +21,7 @@
import org.apache.maven.scm.command.checkin.AbstractCheckInCommand;
import org.apache.maven.scm.command.checkin.CheckInScmResult;
import org.apache.maven.scm.provider.ScmProviderRepository;
+import org.apache.maven.scm.provider.svn.command.SvnCommandLineUtils;
import org.apache.maven.scm.provider.svn.repository.SvnScmProviderRepository;
import org.codehaus.plexus.util.FileUtils;
import org.codehaus.plexus.util.StringUtils;
@@ -53,9 +54,10 @@
{
FileUtils.fileWrite( messageFile.getAbsolutePath(), message );
}
- catch( IOException ex )
+ catch ( IOException ex )
{
- return new CheckInScmResult( "Error while making a temporary file for the commit message: " + ex.getMessage(), null, false );
+ return new CheckInScmResult(
+ "Error while making a temporary file for the commit message: " + ex.getMessage(), null, false );
}
Commandline cl = createCommandLine( (SvnScmProviderRepository) repo, fileSet, messageFile );
@@ -83,7 +85,7 @@
{
FileUtils.forceDelete( messageFile );
}
- catch( IOException ex )
+ catch ( IOException ex )
{
// ignore
}
@@ -101,41 +103,18 @@
//
// ----------------------------------------------------------------------
- public static Commandline createCommandLine( SvnScmProviderRepository repository, ScmFileSet fileSet, File messageFile )
+ public static Commandline createCommandLine( SvnScmProviderRepository repository, ScmFileSet fileSet,
+ File messageFile )
{
- Commandline cl = new Commandline();
-
- cl.setExecutable( "svn" );
-
- cl.setWorkingDirectory( fileSet.getBasedir().getAbsolutePath() );
+ Commandline cl = SvnCommandLineUtils.getBaseSvnCommandLine( fileSet.getBasedir(), repository );
cl.createArgument().setValue( "commit" );
- cl.createArgument().setValue( "--non-interactive" );
-
- if ( repository.getUser() != null )
- {
- cl.createArgument().setValue( "--username" );
-
- cl.createArgument().setValue( repository.getUser() );
- }
-
- if ( repository.getPassword() != null )
- {
- cl.createArgument().setValue( "--password" );
-
- cl.createArgument().setValue( repository.getPassword() );
- }
-
cl.createArgument().setValue( "--file" );
cl.createArgument().setValue( messageFile.getAbsolutePath() );
- File[] files = fileSet.getFiles();
- for ( int i = 0; i < files.length; i++ )
- {
- cl.createArgument().setValue( files[i].getPath().replace( '\\', '/' ) );
- }
+ SvnCommandLineUtils.addFiles( cl, fileSet.getFiles() );
return cl;
}
1.7 +5 -24 maven-scm/maven-scm-providers/maven-scm-provider-svn/src/main/java/org/apache/maven/scm/provider/svn/command/checkout/SvnCheckOutCommand.java
Index: SvnCheckOutCommand.java
===================================================================
RCS file: /home/cvs/maven-scm/maven-scm-providers/maven-scm-provider-svn/src/main/java/org/apache/maven/scm/provider/svn/command/checkout/SvnCheckOutCommand.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- SvnCheckOutCommand.java 4 Jan 2005 09:44:32 -0000 1.6
+++ SvnCheckOutCommand.java 17 Feb 2005 00:52:19 -0000 1.7
@@ -22,6 +22,7 @@
import org.apache.maven.scm.command.checkout.CheckOutScmResult;
import org.apache.maven.scm.provider.ScmProviderRepository;
import org.apache.maven.scm.provider.svn.command.SvnCommand;
+import org.apache.maven.scm.provider.svn.command.SvnCommandLineUtils;
import org.apache.maven.scm.provider.svn.repository.SvnScmProviderRepository;
import org.codehaus.plexus.util.cli.CommandLineException;
import org.codehaus.plexus.util.cli.CommandLineUtils;
@@ -70,7 +71,7 @@
{
exitCode = CommandLineUtils.executeCommandLine( cl, consumer, stderr );
}
- catch( CommandLineException ex )
+ catch ( CommandLineException ex )
{
throw new ScmException( "Error while executing command.", ex );
}
@@ -90,37 +91,17 @@
public static Commandline createCommandLine( SvnScmProviderRepository repository, File workingDirectory,
String revision, String url )
{
- Commandline cl = new Commandline();
-
- cl.setExecutable( "svn" );
-
- cl.setWorkingDirectory( workingDirectory.getParentFile().getAbsolutePath() );
+ Commandline cl = SvnCommandLineUtils.getBaseSvnCommandLine( workingDirectory, repository );
cl.createArgument().setValue( "checkout" );
- cl.createArgument().setValue( "--non-interactive" );
-
- if ( revision != null)
+ if ( revision != null )
{
cl.createArgument().setValue( "-r" );
cl.createArgument().setValue( revision );
}
- if ( repository.getUser() != null )
- {
- cl.createArgument().setValue( "--username" );
-
- cl.createArgument().setValue( repository.getUser() );
- }
-
- if ( repository.getPassword() != null )
- {
- cl.createArgument().setValue( "--password" );
-
- cl.createArgument().setValue( repository.getPassword() );
- }
-
cl.createArgument().setValue( url );
cl.createArgument().setValue( workingDirectory.getName() );
1.4 +4 -23 maven-scm/maven-scm-providers/maven-scm-provider-svn/src/main/java/org/apache/maven/scm/provider/svn/command/diff/SvnDiffCommand.java
Index: SvnDiffCommand.java
===================================================================
RCS file: /home/cvs/maven-scm/maven-scm-providers/maven-scm-provider-svn/src/main/java/org/apache/maven/scm/provider/svn/command/diff/SvnDiffCommand.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- SvnDiffCommand.java 12 Jan 2005 11:56:52 -0000 1.3
+++ SvnDiffCommand.java 17 Feb 2005 00:52:19 -0000 1.4
@@ -1,7 +1,7 @@
package org.apache.maven.scm.provider.svn.command.diff;
/*
- * Copyright 2003-2004 The Apache Software Foundation.
+ * Copyright 2003-2005 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,6 +22,7 @@
import org.apache.maven.scm.command.diff.DiffScmResult;
import org.apache.maven.scm.provider.ScmProviderRepository;
import org.apache.maven.scm.provider.svn.command.SvnCommand;
+import org.apache.maven.scm.provider.svn.command.SvnCommandLineUtils;
import org.apache.maven.scm.provider.svn.repository.SvnScmProviderRepository;
import org.codehaus.plexus.util.cli.CommandLineException;
import org.codehaus.plexus.util.cli.CommandLineUtils;
@@ -77,16 +78,10 @@
public static Commandline createCommandLine( SvnScmProviderRepository repository, File workingDirectory,
String startRevision, String endRevision )
{
- Commandline cl = new Commandline();
-
- cl.setExecutable( "svn" );
-
- cl.setWorkingDirectory( workingDirectory.getAbsolutePath() );
+ Commandline cl = SvnCommandLineUtils.getBaseSvnCommandLine( workingDirectory, repository );
cl.createArgument().setValue( "diff" );
- cl.createArgument().setValue( "--non-interactive" );
-
if ( startRevision != null )
{
cl.createArgument().setValue( "-r" );
@@ -101,20 +96,6 @@
}
}
- if ( repository.getUser() != null )
- {
- cl.createArgument().setValue( "--username" );
-
- cl.createArgument().setValue( repository.getUser() );
- }
-
- if ( repository.getPassword() != null )
- {
- cl.createArgument().setValue( "--password" );
-
- cl.createArgument().setValue( repository.getPassword() );
- }
-
return cl;
}
}
1.3 +4 -25 maven-scm/maven-scm-providers/maven-scm-provider-svn/src/main/java/org/apache/maven/scm/provider/svn/command/status/SvnStatusCommand.java
Index: SvnStatusCommand.java
===================================================================
RCS file: /home/cvs/maven-scm/maven-scm-providers/maven-scm-provider-svn/src/main/java/org/apache/maven/scm/provider/svn/command/status/SvnStatusCommand.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- SvnStatusCommand.java 18 Jan 2005 08:28:53 -0000 1.2
+++ SvnStatusCommand.java 17 Feb 2005 00:52:19 -0000 1.3
@@ -1,7 +1,7 @@
package org.apache.maven.scm.provider.svn.command.status;
/*
- * Copyright 2003-2004 The Apache Software Foundation.
+ * Copyright 2003-2005 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,13 +22,12 @@
import org.apache.maven.scm.command.status.StatusScmResult;
import org.apache.maven.scm.provider.ScmProviderRepository;
import org.apache.maven.scm.provider.svn.command.SvnCommand;
+import org.apache.maven.scm.provider.svn.command.SvnCommandLineUtils;
import org.apache.maven.scm.provider.svn.repository.SvnScmProviderRepository;
import org.codehaus.plexus.util.cli.CommandLineException;
import org.codehaus.plexus.util.cli.CommandLineUtils;
import org.codehaus.plexus.util.cli.Commandline;
-import java.io.File;
-
/**
* @author <a href="mailto:brett@apache.org">Brett Porter</a>
* @version $Id$
@@ -74,30 +73,10 @@
public static Commandline createCommandLine( SvnScmProviderRepository repository, ScmFileSet fileSet )
{
- Commandline cl = new Commandline();
-
- cl.setExecutable( "svn" );
-
- cl.setWorkingDirectory( fileSet.getBasedir().getAbsolutePath() );
+ Commandline cl = SvnCommandLineUtils.getBaseSvnCommandLine( fileSet.getBasedir(), repository );
cl.createArgument().setValue( "status" );
- cl.createArgument().setValue( "--non-interactive" );
-
- if ( repository.getUser() != null )
- {
- cl.createArgument().setValue( "--username" );
-
- cl.createArgument().setValue( repository.getUser() );
- }
-
- if ( repository.getPassword() != null )
- {
- cl.createArgument().setValue( "--password" );
-
- cl.createArgument().setValue( repository.getPassword() );
- }
-
return cl;
}
}
1.3 +9 -27 maven-scm/maven-scm-providers/maven-scm-provider-svn/src/main/java/org/apache/maven/scm/provider/svn/command/tag/SvnTagCommand.java
Index: SvnTagCommand.java
===================================================================
RCS file: /home/cvs/maven-scm/maven-scm-providers/maven-scm-provider-svn/src/main/java/org/apache/maven/scm/provider/svn/command/tag/SvnTagCommand.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- SvnTagCommand.java 7 Jan 2005 12:26:39 -0000 1.2
+++ SvnTagCommand.java 17 Feb 2005 00:52:19 -0000 1.3
@@ -25,6 +25,7 @@
import org.apache.maven.scm.command.tag.TagScmResult;
import org.apache.maven.scm.provider.ScmProviderRepository;
import org.apache.maven.scm.provider.svn.command.SvnCommand;
+import org.apache.maven.scm.provider.svn.command.SvnCommandLineUtils;
import org.apache.maven.scm.provider.svn.repository.SvnScmProviderRepository;
import org.codehaus.plexus.util.FileUtils;
import org.codehaus.plexus.util.cli.CommandLineException;
@@ -42,7 +43,9 @@
* @version $Id$
* @todo since this is just a copy, use that instead.
*/
-public class SvnTagCommand extends AbstractTagCommand implements SvnCommand
+public class SvnTagCommand
+ extends AbstractTagCommand
+ implements SvnCommand
{
public ScmResult executeTagCommand( ScmProviderRepository repo, ScmFileSet fileSet, String tag )
throws ScmException
@@ -74,12 +77,11 @@
}
catch ( IOException ex )
{
- return new TagScmResult(
- "Error while making a temporary file for the commit message: " + ex.getMessage(), null, false );
+ return new TagScmResult( "Error while making a temporary file for the commit message: " + ex.getMessage(),
+ null, false );
}
- Commandline cl = createCommandLine( repository, fileSet.getBasedir(), tagBase,
- tag, messageFile );
+ Commandline cl = createCommandLine( repository, fileSet.getBasedir(), tagBase, tag, messageFile );
CommandLineUtils.StringStreamConsumer stdout = new CommandLineUtils.StringStreamConsumer();
@@ -132,30 +134,10 @@
private static Commandline createCommandLine( SvnScmProviderRepository repository, File workingDirectory,
String tagBase, String tag, File messageFile )
{
- Commandline cl = new Commandline();
-
- cl.setExecutable( "svn" );
-
- cl.setWorkingDirectory( workingDirectory.getAbsolutePath() );
+ Commandline cl = SvnCommandLineUtils.getBaseSvnCommandLine( workingDirectory, repository );
cl.createArgument().setValue( "copy" );
- cl.createArgument().setValue( "--non-interactive" );
-
- if ( repository.getUser() != null )
- {
- cl.createArgument().setValue( "--username" );
-
- cl.createArgument().setValue( repository.getUser() );
- }
-
- if ( repository.getPassword() != null )
- {
- cl.createArgument().setValue( "--password" );
-
- cl.createArgument().setValue( repository.getPassword() );
- }
-
cl.createArgument().setValue( "--file" );
cl.createArgument().setValue( messageFile.getAbsolutePath() );
1.7 +5 -23 maven-scm/maven-scm-providers/maven-scm-provider-svn/src/main/java/org/apache/maven/scm/provider/svn/command/update/SvnUpdateCommand.java
Index: SvnUpdateCommand.java
===================================================================
RCS file: /home/cvs/maven-scm/maven-scm-providers/maven-scm-provider-svn/src/main/java/org/apache/maven/scm/provider/svn/command/update/SvnUpdateCommand.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- SvnUpdateCommand.java 10 Jan 2005 11:51:29 -0000 1.6
+++ SvnUpdateCommand.java 17 Feb 2005 00:52:19 -0000 1.7
@@ -22,6 +22,7 @@
import org.apache.maven.scm.command.update.UpdateScmResult;
import org.apache.maven.scm.provider.ScmProviderRepository;
import org.apache.maven.scm.provider.svn.command.SvnCommand;
+import org.apache.maven.scm.provider.svn.command.SvnCommandLineUtils;
import org.apache.maven.scm.provider.svn.repository.SvnScmProviderRepository;
import org.codehaus.plexus.util.cli.CommandLineException;
import org.codehaus.plexus.util.cli.CommandLineUtils;
@@ -72,18 +73,13 @@
//
// ----------------------------------------------------------------------
- public static Commandline createCommandLine( SvnScmProviderRepository repository, File workingDirectory, String tag )
+ public static Commandline createCommandLine( SvnScmProviderRepository repository, File workingDirectory,
+ String tag )
{
- Commandline cl = new Commandline();
-
- cl.setExecutable( "svn" );
-
- cl.setWorkingDirectory( workingDirectory.getAbsolutePath() );
+ Commandline cl = SvnCommandLineUtils.getBaseSvnCommandLine( workingDirectory, repository );
cl.createArgument().setValue( "update" );
- cl.createArgument().setValue( "--non-interactive" );
-
if ( tag != null )
{
cl.createArgument().setValue( "-r" );
@@ -91,20 +87,6 @@
cl.createArgument().setValue( tag );
}
- if ( repository.getUser() != null )
- {
- cl.createArgument().setValue( "--username" );
-
- cl.createArgument().setValue( repository.getUser() );
- }
-
- if ( repository.getPassword() != null )
- {
- cl.createArgument().setValue( "--password" );
-
- cl.createArgument().setValue( repository.getPassword() );
- }
-
return cl;
}
}
1.1 maven-scm/maven-scm-providers/maven-scm-provider-svn/src/main/java/org/apache/maven/scm/provider/svn/command/SvnCommandLineUtils.java
Index: SvnCommandLineUtils.java
===================================================================
package org.apache.maven.scm.provider.svn.command;
/*
* Copyright 2003-2005 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import org.apache.maven.scm.provider.svn.repository.SvnScmProviderRepository;
import org.codehaus.plexus.util.cli.Commandline;
import java.io.File;
/**
* Command line construction utility.
*
* @author Brett Porter
* @version $Id: SvnCommandLineUtils.java,v 1.1 2005/02/17 00:52:19 brett Exp $
*/
public class SvnCommandLineUtils
{
public static void addFiles( Commandline cl, File[] files )
{
for ( int i = 0; i < files.length; i++ )
{
cl.createArgument().setValue( files[i].getPath().replace( '\\', '/' ) );
}
}
public static Commandline getBaseSvnCommandLine( File workingDirectory, SvnScmProviderRepository repository )
{
Commandline cl = new Commandline();
cl.setExecutable( "svn" );
cl.setWorkingDirectory( workingDirectory.getAbsolutePath() );
if ( repository.getUser() != null )
{
cl.createArgument().setValue( "--username" );
cl.createArgument().setValue( repository.getUser() );
}
if ( repository.getPassword() != null )
{
cl.createArgument().setValue( "--password" );
cl.createArgument().setValue( repository.getPassword() );
}
cl.createArgument().setValue( "--non-interactive" );
return cl;
}
}