Code reformatting
git-svn-id: https://svn.apache.org/repos/asf/maven/maven-1/plugins/trunk@392030 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
1dd0ce2335
commit
22f65786e2
@ -21,16 +21,16 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.apache.maven.scm.provider.cvslib.CvsScmProvider;
|
|
||||||
import org.apache.maven.scm.provider.cvslib.repository.CvsScmProviderRepository;
|
|
||||||
import org.apache.maven.scm.provider.svn.SvnScmProvider;
|
|
||||||
import org.apache.maven.scm.provider.svn.repository.SvnScmProviderRepository;
|
|
||||||
import org.apache.maven.scm.provider.clearcase.ClearCaseScmProvider;
|
import org.apache.maven.scm.provider.clearcase.ClearCaseScmProvider;
|
||||||
import org.apache.maven.scm.provider.clearcase.repository.ClearCaseScmProviderRepository;
|
import org.apache.maven.scm.provider.clearcase.repository.ClearCaseScmProviderRepository;
|
||||||
|
import org.apache.maven.scm.provider.cvslib.CvsScmProvider;
|
||||||
|
import org.apache.maven.scm.provider.cvslib.repository.CvsScmProviderRepository;
|
||||||
import org.apache.maven.scm.provider.perforce.PerforceScmProvider;
|
import org.apache.maven.scm.provider.perforce.PerforceScmProvider;
|
||||||
import org.apache.maven.scm.provider.perforce.repository.PerforceScmProviderRepository;
|
import org.apache.maven.scm.provider.perforce.repository.PerforceScmProviderRepository;
|
||||||
import org.apache.maven.scm.provider.starteam.StarteamScmProvider;
|
import org.apache.maven.scm.provider.starteam.StarteamScmProvider;
|
||||||
import org.apache.maven.scm.provider.starteam.repository.StarteamScmProviderRepository;
|
import org.apache.maven.scm.provider.starteam.repository.StarteamScmProviderRepository;
|
||||||
|
import org.apache.maven.scm.provider.svn.SvnScmProvider;
|
||||||
|
import org.apache.maven.scm.provider.svn.repository.SvnScmProviderRepository;
|
||||||
import org.apache.maven.scm.repository.ScmRepositoryException;
|
import org.apache.maven.scm.repository.ScmRepositoryException;
|
||||||
import org.apache.maven.util.EnhancedStringTokenizer;
|
import org.apache.maven.util.EnhancedStringTokenizer;
|
||||||
|
|
||||||
@ -42,7 +42,8 @@ import org.apache.maven.util.EnhancedStringTokenizer;
|
|||||||
* @author <a href="mailto:aheritier@apache.org">Arnaud Heritier</a>
|
* @author <a href="mailto:aheritier@apache.org">Arnaud Heritier</a>
|
||||||
* @version $Id$
|
* @version $Id$
|
||||||
*/
|
*/
|
||||||
public final class ScmUtil {
|
public final class ScmUtil
|
||||||
|
{
|
||||||
/**
|
/**
|
||||||
* Get the SCM type.
|
* Get the SCM type.
|
||||||
*
|
*
|
||||||
@ -50,8 +51,10 @@ public final class ScmUtil {
|
|||||||
* the scm connection to analyse.
|
* the scm connection to analyse.
|
||||||
* @return the scm type : cvs, svn , ...
|
* @return the scm type : cvs, svn , ...
|
||||||
*/
|
*/
|
||||||
public String getScmType(final String scmConnection) {
|
public String getScmType( final String scmConnection )
|
||||||
if (isValid(scmConnection)) {
|
{
|
||||||
|
if ( isValid( scmConnection ) )
|
||||||
|
{
|
||||||
return splitSCMConnection( scmConnection )[1];
|
return splitSCMConnection( scmConnection )[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -72,28 +75,34 @@ public final class ScmUtil {
|
|||||||
* username override if non-empty.
|
* username override if non-empty.
|
||||||
* @return CVS root.
|
* @return CVS root.
|
||||||
*/
|
*/
|
||||||
public String getCvsConnection(String conn, String username) {
|
public String getCvsConnection( String conn, String username )
|
||||||
|
{
|
||||||
String[] tokens = splitSCMConnection( conn );
|
String[] tokens = splitSCMConnection( conn );
|
||||||
|
|
||||||
if (!tokens[1].equals("cvs")) {
|
if ( !tokens[1].equals( "cvs" ) )
|
||||||
|
{
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
String separator = getSCMConnectionSeparator( conn );
|
String separator = getSCMConnectionSeparator( conn );
|
||||||
|
|
||||||
if (tokens[3].indexOf('@') >= 0) {
|
if ( tokens[3].indexOf( '@' ) >= 0 )
|
||||||
if (username.length() == 0) {
|
{
|
||||||
username = tokens[3].substring(0, tokens[3].indexOf('@'))
|
if ( username.length() == 0 )
|
||||||
|
{
|
||||||
|
username =
|
||||||
|
tokens[3].substring( 0, tokens[3].indexOf( '@' ) )
|
||||||
+ separator;
|
+ separator;
|
||||||
}
|
}
|
||||||
|
|
||||||
tokens[3] = username + "@"
|
tokens[3] =
|
||||||
|
username + "@"
|
||||||
+ tokens[3].substring( tokens[3].indexOf( '@' ) + 1 );
|
+ tokens[3].substring( tokens[3].indexOf( '@' ) + 1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
String result = tokens[0] + ":" + tokens[1] + separator + tokens[2]
|
String result =
|
||||||
+ separator + tokens[3] + separator + tokens[4] + separator
|
tokens[0] + ":" + tokens[1] + separator + tokens[2] + separator
|
||||||
+ tokens[5];
|
+ tokens[3] + separator + tokens[4] + separator + tokens[5];
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -105,11 +114,14 @@ public final class ScmUtil {
|
|||||||
* six token connection string
|
* six token connection string
|
||||||
* @return CVS module.
|
* @return CVS module.
|
||||||
*/
|
*/
|
||||||
public String getCvsModule(String conn) {
|
public String getCvsModule( String conn )
|
||||||
if (isValid(conn)) {
|
{
|
||||||
|
if ( isValid( conn ) )
|
||||||
|
{
|
||||||
String[] tokens = splitSCMConnection( conn );
|
String[] tokens = splitSCMConnection( conn );
|
||||||
|
|
||||||
if (!tokens[1].equals("cvs")) {
|
if ( !tokens[1].equals( "cvs" ) )
|
||||||
|
{
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -128,14 +140,18 @@ public final class ScmUtil {
|
|||||||
* the repository connection
|
* the repository connection
|
||||||
* @return CVS root.
|
* @return CVS root.
|
||||||
*/
|
*/
|
||||||
public String getSvnConnection(String conn) {
|
public String getSvnConnection( String conn )
|
||||||
if (conn != null && conn.length() > 8
|
{
|
||||||
|
if ( ( conn != null ) && ( conn.length() > 8 )
|
||||||
&& "svn".equals( conn.substring( 4, 7 ) ) )
|
&& "svn".equals( conn.substring( 4, 7 ) ) )
|
||||||
|
{
|
||||||
return conn.substring( 8 );
|
return conn.substring( 8 );
|
||||||
else {
|
}
|
||||||
System.err
|
else
|
||||||
.println("Your subversion connection does not seem to be valid: "
|
{
|
||||||
+ conn);
|
System.err.println(
|
||||||
|
"Your subversion connection does not seem to be valid: " + conn );
|
||||||
|
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -151,7 +167,6 @@ public final class ScmUtil {
|
|||||||
*/
|
*/
|
||||||
public String anonymousAccessCVS( String connection )
|
public String anonymousAccessCVS( String connection )
|
||||||
{
|
{
|
||||||
|
|
||||||
char delim = getSCMConnectionSeparator( connection ).charAt( 0 );
|
char delim = getSCMConnectionSeparator( connection ).charAt( 0 );
|
||||||
|
|
||||||
CvsScmProvider cvsProvider = new CvsScmProvider();
|
CvsScmProvider cvsProvider = new CvsScmProvider();
|
||||||
@ -159,17 +174,23 @@ public final class ScmUtil {
|
|||||||
|
|
||||||
String scmSpecificUrl = connection.substring( 8 );
|
String scmSpecificUrl = connection.substring( 8 );
|
||||||
|
|
||||||
try {
|
try
|
||||||
cvsRepo = (CvsScmProviderRepository) cvsProvider
|
{
|
||||||
|
cvsRepo =
|
||||||
|
(CvsScmProviderRepository) cvsProvider
|
||||||
.makeProviderScmRepository( scmSpecificUrl, delim );
|
.makeProviderScmRepository( scmSpecificUrl, delim );
|
||||||
} catch (ScmRepositoryException e) {
|
}
|
||||||
System.err
|
catch ( ScmRepositoryException e )
|
||||||
.println("Your developerConnection does not seem to be valid: "
|
{
|
||||||
|
System.err.println(
|
||||||
|
"Your developerConnection does not seem to be valid: "
|
||||||
+ e.getMessage() );
|
+ e.getMessage() );
|
||||||
|
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
StringBuffer command = new StringBuffer();
|
StringBuffer command = new StringBuffer();
|
||||||
|
|
||||||
command.append( "cvs -d " ).append( cvsRepo.getCvsRoot() ).append( " login" );
|
command.append( "cvs -d " ).append( cvsRepo.getCvsRoot() ).append( " login" );
|
||||||
command.append( "\n" );
|
command.append( "\n" );
|
||||||
command.append( "cvs -z3 -d " ).append( cvsRepo.getCvsRoot() );
|
command.append( "cvs -z3 -d " ).append( cvsRepo.getCvsRoot() );
|
||||||
@ -189,7 +210,6 @@ public final class ScmUtil {
|
|||||||
*/
|
*/
|
||||||
public String developerAccessCVS( String devConnection )
|
public String developerAccessCVS( String devConnection )
|
||||||
{
|
{
|
||||||
|
|
||||||
char delim = getSCMConnectionSeparator( devConnection ).charAt( 0 );
|
char delim = getSCMConnectionSeparator( devConnection ).charAt( 0 );
|
||||||
|
|
||||||
CvsScmProvider cvsProvider = new CvsScmProvider();
|
CvsScmProvider cvsProvider = new CvsScmProvider();
|
||||||
@ -197,24 +217,32 @@ public final class ScmUtil {
|
|||||||
|
|
||||||
String scmSpecificUrl = devConnection.substring( 8 );
|
String scmSpecificUrl = devConnection.substring( 8 );
|
||||||
|
|
||||||
try {
|
try
|
||||||
cvsRepo = (CvsScmProviderRepository) cvsProvider
|
{
|
||||||
|
cvsRepo =
|
||||||
|
(CvsScmProviderRepository) cvsProvider
|
||||||
.makeProviderScmRepository( scmSpecificUrl, delim );
|
.makeProviderScmRepository( scmSpecificUrl, delim );
|
||||||
} catch (ScmRepositoryException e) {
|
}
|
||||||
System.err
|
catch ( ScmRepositoryException e )
|
||||||
.println("Your developerConnection does not seem to be valid: "
|
{
|
||||||
|
System.err.println(
|
||||||
|
"Your developerConnection does not seem to be valid: "
|
||||||
+ e.getMessage() );
|
+ e.getMessage() );
|
||||||
|
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Safety: remove the username if present
|
// Safety: remove the username if present
|
||||||
String cvsRoot = StringUtils.replace( cvsRepo.getCvsRoot(), cvsRepo.getUser(), "username" );
|
String cvsRoot =
|
||||||
|
StringUtils.replace( cvsRepo.getCvsRoot(), cvsRepo.getUser(),
|
||||||
|
"username" );
|
||||||
|
|
||||||
StringBuffer command = new StringBuffer();
|
StringBuffer command = new StringBuffer();
|
||||||
|
|
||||||
command.append( "export CVS_RSH=ssh" );
|
command.append( "export CVS_RSH=ssh" );
|
||||||
command.append( "\n" );
|
command.append( "\n" );
|
||||||
command.append( "cvs -z3 -d " ).append( cvsRoot ).append( " co " ).append( cvsRepo.getModule() );
|
command.append( "cvs -z3 -d " ).append( cvsRoot ).append( " co " )
|
||||||
|
.append( cvsRepo.getModule() );
|
||||||
|
|
||||||
return command.toString();
|
return command.toString();
|
||||||
}
|
}
|
||||||
@ -228,9 +256,9 @@ public final class ScmUtil {
|
|||||||
* @param checkoutDirectoryName The checkout directory.
|
* @param checkoutDirectoryName The checkout directory.
|
||||||
* @see <a href="http://svnbook.red-bean.com/">http://svnbook.red-bean.com/</a>
|
* @see <a href="http://svnbook.red-bean.com/">http://svnbook.red-bean.com/</a>
|
||||||
*/
|
*/
|
||||||
public String anonymousAccessSVN( String connection, String checkoutDirectoryName )
|
public String anonymousAccessSVN( String connection,
|
||||||
|
String checkoutDirectoryName )
|
||||||
{
|
{
|
||||||
|
|
||||||
char delim = getSCMConnectionSeparator( connection ).charAt( 0 );
|
char delim = getSCMConnectionSeparator( connection ).charAt( 0 );
|
||||||
|
|
||||||
SvnScmProvider svnProvider = new SvnScmProvider();
|
SvnScmProvider svnProvider = new SvnScmProvider();
|
||||||
@ -238,18 +266,25 @@ public final class ScmUtil {
|
|||||||
|
|
||||||
String scmSpecificUrl = connection.substring( 8 );
|
String scmSpecificUrl = connection.substring( 8 );
|
||||||
|
|
||||||
try {
|
try
|
||||||
svnRepo = (SvnScmProviderRepository) svnProvider
|
{
|
||||||
|
svnRepo =
|
||||||
|
(SvnScmProviderRepository) svnProvider
|
||||||
.makeProviderScmRepository( scmSpecificUrl, delim );
|
.makeProviderScmRepository( scmSpecificUrl, delim );
|
||||||
} catch (ScmRepositoryException e) {
|
}
|
||||||
System.err
|
catch ( ScmRepositoryException e )
|
||||||
.println("Your developerConnection does not seem to be valid: "
|
{
|
||||||
|
System.err.println(
|
||||||
|
"Your developerConnection does not seem to be valid: "
|
||||||
+ e.getMessage() );
|
+ e.getMessage() );
|
||||||
|
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
StringBuffer command = new StringBuffer();
|
StringBuffer command = new StringBuffer();
|
||||||
command.append( "svn checkout " ).append( svnRepo.getUrl() ).append( " " ).append( checkoutDirectoryName );
|
|
||||||
|
command.append( "svn checkout " ).append( svnRepo.getUrl() )
|
||||||
|
.append( " " ).append( checkoutDirectoryName );
|
||||||
|
|
||||||
return command.toString();
|
return command.toString();
|
||||||
}
|
}
|
||||||
@ -264,9 +299,9 @@ public final class ScmUtil {
|
|||||||
* @param checkoutDirectoryName The checkout directory.
|
* @param checkoutDirectoryName The checkout directory.
|
||||||
* @see <a href="http://svnbook.red-bean.com/">http://svnbook.red-bean.com/</a>
|
* @see <a href="http://svnbook.red-bean.com/">http://svnbook.red-bean.com/</a>
|
||||||
*/
|
*/
|
||||||
public String developerAccessSVN( String devConnection, String checkoutDirectoryName )
|
public String developerAccessSVN( String devConnection,
|
||||||
|
String checkoutDirectoryName )
|
||||||
{
|
{
|
||||||
|
|
||||||
char delim = getSCMConnectionSeparator( devConnection ).charAt( 0 );
|
char delim = getSCMConnectionSeparator( devConnection ).charAt( 0 );
|
||||||
|
|
||||||
SvnScmProvider svnProvider = new SvnScmProvider();
|
SvnScmProvider svnProvider = new SvnScmProvider();
|
||||||
@ -274,24 +309,29 @@ public final class ScmUtil {
|
|||||||
|
|
||||||
String scmSpecificUrl = devConnection.substring( 8 );
|
String scmSpecificUrl = devConnection.substring( 8 );
|
||||||
|
|
||||||
try {
|
try
|
||||||
svnRepo = (SvnScmProviderRepository) svnProvider
|
{
|
||||||
|
svnRepo =
|
||||||
|
(SvnScmProviderRepository) svnProvider
|
||||||
.makeProviderScmRepository( scmSpecificUrl, delim );
|
.makeProviderScmRepository( scmSpecificUrl, delim );
|
||||||
} catch (ScmRepositoryException e) {
|
}
|
||||||
System.err
|
catch ( ScmRepositoryException e )
|
||||||
.println("Your developerConnection does not seem to be valid: "
|
{
|
||||||
|
System.err.println(
|
||||||
|
"Your developerConnection does not seem to be valid: "
|
||||||
+ e.getMessage() );
|
+ e.getMessage() );
|
||||||
|
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
StringBuffer command = new StringBuffer();
|
StringBuffer command = new StringBuffer();
|
||||||
|
|
||||||
command.append( "svn checkout " ).append( svnRepo.getUrl() ).append( " " ).append( checkoutDirectoryName );
|
command.append( "svn checkout " ).append( svnRepo.getUrl() )
|
||||||
|
.append( " " ).append( checkoutDirectoryName );
|
||||||
|
|
||||||
return command.toString();
|
return command.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create the documentation to provide an developer access with a
|
* Create the documentation to provide an developer access with a
|
||||||
* <code>Perforce</code> SCM. For example, generate the following command
|
* <code>Perforce</code> SCM. For example, generate the following command
|
||||||
@ -307,7 +347,8 @@ public final class ScmUtil {
|
|||||||
* @see <a
|
* @see <a
|
||||||
* href="http://www.perforce.com/perforce/doc.051/manuals/cmdref/index.html">http://www.perforce.com/perforce/doc.051/manuals/cmdref/index.html</>
|
* href="http://www.perforce.com/perforce/doc.051/manuals/cmdref/index.html">http://www.perforce.com/perforce/doc.051/manuals/cmdref/index.html</>
|
||||||
*/
|
*/
|
||||||
public String developerAccessPerforce(String devConnection) {
|
public String developerAccessPerforce( String devConnection )
|
||||||
|
{
|
||||||
StringBuffer command = new StringBuffer();
|
StringBuffer command = new StringBuffer();
|
||||||
char delim = getSCMConnectionSeparator( devConnection ).charAt( 0 );
|
char delim = getSCMConnectionSeparator( devConnection ).charAt( 0 );
|
||||||
|
|
||||||
@ -316,23 +357,33 @@ public final class ScmUtil {
|
|||||||
|
|
||||||
String scmSpecificUrl = devConnection.substring( 13 );
|
String scmSpecificUrl = devConnection.substring( 13 );
|
||||||
|
|
||||||
try {
|
try
|
||||||
perforceRepo = (PerforceScmProviderRepository) perforceProvider
|
{
|
||||||
|
perforceRepo =
|
||||||
|
(PerforceScmProviderRepository) perforceProvider
|
||||||
.makeProviderScmRepository( scmSpecificUrl, delim );
|
.makeProviderScmRepository( scmSpecificUrl, delim );
|
||||||
} catch (ScmRepositoryException e) {
|
}
|
||||||
System.err
|
catch ( ScmRepositoryException e )
|
||||||
.println("Your developerConnection does not seem to be valid: "
|
{
|
||||||
|
System.err.println(
|
||||||
|
"Your developerConnection does not seem to be valid: "
|
||||||
+ e.getMessage() );
|
+ e.getMessage() );
|
||||||
|
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
command.append( "p4" );
|
command.append( "p4" );
|
||||||
if (!StringUtils.isEmpty(perforceRepo.getHost())) {
|
|
||||||
|
if ( !StringUtils.isEmpty( perforceRepo.getHost() ) )
|
||||||
|
{
|
||||||
command.append( " -H " ).append( perforceRepo.getHost() );
|
command.append( " -H " ).append( perforceRepo.getHost() );
|
||||||
}
|
}
|
||||||
if (perforceRepo.getPort() > 0) {
|
|
||||||
|
if ( perforceRepo.getPort() > 0 )
|
||||||
|
{
|
||||||
command.append( " -p " + perforceRepo.getPort() );
|
command.append( " -p " + perforceRepo.getPort() );
|
||||||
}
|
}
|
||||||
|
|
||||||
command.append( " -u username" );
|
command.append( " -u username" );
|
||||||
command.append( " -P password" );
|
command.append( " -P password" );
|
||||||
command.append( " " );
|
command.append( " " );
|
||||||
@ -360,8 +411,8 @@ public final class ScmUtil {
|
|||||||
*
|
*
|
||||||
* @param devConnection
|
* @param devConnection
|
||||||
*/
|
*/
|
||||||
public String developerAccessStarteam(String devConnection) {
|
public String developerAccessStarteam( String devConnection )
|
||||||
|
{
|
||||||
StringBuffer command = new StringBuffer();
|
StringBuffer command = new StringBuffer();
|
||||||
char delim = getSCMConnectionSeparator( devConnection ).charAt( 0 );
|
char delim = getSCMConnectionSeparator( devConnection ).charAt( 0 );
|
||||||
|
|
||||||
@ -370,20 +421,28 @@ public final class ScmUtil {
|
|||||||
|
|
||||||
String scmSpecificUrl = devConnection.substring( 13 );
|
String scmSpecificUrl = devConnection.substring( 13 );
|
||||||
|
|
||||||
try {
|
try
|
||||||
starteamRepo = (StarteamScmProviderRepository) starteamProvider
|
{
|
||||||
|
starteamRepo =
|
||||||
|
(StarteamScmProviderRepository) starteamProvider
|
||||||
.makeProviderScmRepository( scmSpecificUrl, delim );
|
.makeProviderScmRepository( scmSpecificUrl, delim );
|
||||||
} catch (ScmRepositoryException e) {
|
}
|
||||||
System.err
|
catch ( ScmRepositoryException e )
|
||||||
.println("Your developerConnection does not seem to be valid: "
|
{
|
||||||
|
System.err.println(
|
||||||
|
"Your developerConnection does not seem to be valid: "
|
||||||
+ e.getMessage() );
|
+ e.getMessage() );
|
||||||
|
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Safety: remove the username/password if present
|
// Safety: remove the username/password if present
|
||||||
String fullUrl = StringUtils.replace(starteamRepo.getFullUrl(),
|
String fullUrl =
|
||||||
|
StringUtils.replace( starteamRepo.getFullUrl(),
|
||||||
starteamRepo.getUser(), "username" );
|
starteamRepo.getUser(), "username" );
|
||||||
fullUrl = StringUtils.replace(fullUrl, starteamRepo.getPassword(),
|
|
||||||
|
fullUrl =
|
||||||
|
StringUtils.replace( fullUrl, starteamRepo.getPassword(),
|
||||||
"password" );
|
"password" );
|
||||||
|
|
||||||
command.append( "stcmd co -x -nologo -stop -p " );
|
command.append( "stcmd co -x -nologo -stop -p " );
|
||||||
@ -407,8 +466,8 @@ public final class ScmUtil {
|
|||||||
*
|
*
|
||||||
* @param devConnection
|
* @param devConnection
|
||||||
*/
|
*/
|
||||||
public String developerAccessClearCase(String devConnection) {
|
public String developerAccessClearCase( String devConnection )
|
||||||
|
{
|
||||||
StringBuffer command = new StringBuffer();
|
StringBuffer command = new StringBuffer();
|
||||||
char delim = getSCMConnectionSeparator( devConnection ).charAt( 0 );
|
char delim = getSCMConnectionSeparator( devConnection ).charAt( 0 );
|
||||||
|
|
||||||
@ -417,18 +476,23 @@ public final class ScmUtil {
|
|||||||
|
|
||||||
String scmSpecificUrl = devConnection.substring( 14 );
|
String scmSpecificUrl = devConnection.substring( 14 );
|
||||||
|
|
||||||
try {
|
try
|
||||||
clearCaseRepo = (ClearCaseScmProviderRepository) clearCaseProvider
|
{
|
||||||
|
clearCaseRepo =
|
||||||
|
(ClearCaseScmProviderRepository) clearCaseProvider
|
||||||
.makeProviderScmRepository( scmSpecificUrl, delim );
|
.makeProviderScmRepository( scmSpecificUrl, delim );
|
||||||
} catch (ScmRepositoryException e) {
|
}
|
||||||
System.err
|
catch ( ScmRepositoryException e )
|
||||||
.println("Your developerConnection does not seem to be valid: "
|
{
|
||||||
|
System.err.println(
|
||||||
|
"Your developerConnection does not seem to be valid: "
|
||||||
+ e.getMessage() );
|
+ e.getMessage() );
|
||||||
|
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
command.append("cleartool checkout ").append(
|
command.append( "cleartool checkout " ).append( clearCaseRepo
|
||||||
clearCaseRepo.getViewName("id"));
|
.getViewName( "id" ) );
|
||||||
|
|
||||||
return command.toString();
|
return command.toString();
|
||||||
}
|
}
|
||||||
@ -439,17 +503,21 @@ public final class ScmUtil {
|
|||||||
* @param connection
|
* @param connection
|
||||||
* @return A string array of SCM parts
|
* @return A string array of SCM parts
|
||||||
*/
|
*/
|
||||||
public String[] splitSCMConnection(String connection) {
|
public String[] splitSCMConnection( String connection )
|
||||||
if (connection == null) {
|
{
|
||||||
|
if ( connection == null )
|
||||||
|
{
|
||||||
throw new NullPointerException( "repository connection is null" );
|
throw new NullPointerException( "repository connection is null" );
|
||||||
}
|
}
|
||||||
|
|
||||||
if (connection.length() < 5) {
|
if ( connection.length() < 5 )
|
||||||
|
{
|
||||||
throw new IllegalArgumentException(
|
throw new IllegalArgumentException(
|
||||||
"repository connection is too short" );
|
"repository connection is too short" );
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!connection.startsWith("scm:")) {
|
if ( !connection.startsWith( "scm:" ) )
|
||||||
|
{
|
||||||
throw new IllegalArgumentException(
|
throw new IllegalArgumentException(
|
||||||
"repository connection must start with scm:" );
|
"repository connection must start with scm:" );
|
||||||
}
|
}
|
||||||
@ -459,22 +527,30 @@ public final class ScmUtil {
|
|||||||
// If the tokenizer is going to work correctly then the character
|
// If the tokenizer is going to work correctly then the character
|
||||||
// following "scm" must be the same as the delimiter, which is not
|
// following "scm" must be the same as the delimiter, which is not
|
||||||
// always the case. Therefor we give it a modified connection.
|
// always the case. Therefor we give it a modified connection.
|
||||||
String modifiedConnection = "scm" + delimiter + connection.substring(4);
|
String modifiedConnection =
|
||||||
|
"scm" + delimiter + connection.substring( 4 );
|
||||||
|
|
||||||
EnhancedStringTokenizer tok = new EnhancedStringTokenizer(
|
EnhancedStringTokenizer tok =
|
||||||
modifiedConnection, delimiter);
|
new EnhancedStringTokenizer( modifiedConnection, delimiter );
|
||||||
|
|
||||||
String[] tokens = tokenizerToArray( tok );
|
String[] tokens = tokenizerToArray( tok );
|
||||||
|
|
||||||
// for a valid repository, it should be scm:<provider> at least
|
// for a valid repository, it should be scm:<provider> at least
|
||||||
if ((tokens.length >= 1) && tokens[1].equals("cvs")) {
|
if ( ( tokens.length >= 1 ) && tokens[1].equals( "cvs" ) )
|
||||||
if ((tokens.length >= 2) && tokens[2].equals("local")) {
|
{
|
||||||
if (tokens.length == 6) {
|
if ( ( tokens.length >= 2 ) && tokens[2].equals( "local" ) )
|
||||||
if ((tokens[3].length() > 0) && !tokens[3].equals("local")) {
|
{
|
||||||
|
if ( tokens.length == 6 )
|
||||||
|
{
|
||||||
|
if ( ( tokens[3].length() > 0 )
|
||||||
|
&& !tokens[3].equals( "local" ) )
|
||||||
|
{
|
||||||
throw new IllegalArgumentException(
|
throw new IllegalArgumentException(
|
||||||
"cvs local repository connection string must specify 5 tokens, or an empty 3rd token if 6" );
|
"cvs local repository connection string must specify 5 tokens, or an empty 3rd token if 6" );
|
||||||
}
|
}
|
||||||
} else if (tokens.length == 5) {
|
}
|
||||||
|
else if ( tokens.length == 5 )
|
||||||
|
{
|
||||||
String[] newTokens = new String[6];
|
String[] newTokens = new String[6];
|
||||||
|
|
||||||
newTokens[0] = tokens[0];
|
newTokens[0] = tokens[0];
|
||||||
@ -484,13 +560,16 @@ public final class ScmUtil {
|
|||||||
newTokens[4] = tokens[3];
|
newTokens[4] = tokens[3];
|
||||||
newTokens[5] = tokens[4];
|
newTokens[5] = tokens[4];
|
||||||
tokens = newTokens;
|
tokens = newTokens;
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
throw new IllegalArgumentException(
|
throw new IllegalArgumentException(
|
||||||
"cvs local repository connection string doesn't contain five tokens" );
|
"cvs local repository connection string doesn't contain five tokens" );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tokens.length != 6) {
|
if ( tokens.length != 6 )
|
||||||
|
{
|
||||||
throw new IllegalArgumentException(
|
throw new IllegalArgumentException(
|
||||||
"cvs repository connection string doesn't contain six tokens" );
|
"cvs repository connection string doesn't contain six tokens" );
|
||||||
}
|
}
|
||||||
@ -505,14 +584,19 @@ public final class ScmUtil {
|
|||||||
* @param connection
|
* @param connection
|
||||||
* @return String that can be either ":" or "|"
|
* @return String that can be either ":" or "|"
|
||||||
*/
|
*/
|
||||||
public String getSCMConnectionSeparator(String connection) {
|
public String getSCMConnectionSeparator( String connection )
|
||||||
if (connection == null) {
|
{
|
||||||
|
if ( connection == null )
|
||||||
|
{
|
||||||
throw new NullPointerException( "repository connection is null" );
|
throw new NullPointerException( "repository connection is null" );
|
||||||
}
|
}
|
||||||
|
|
||||||
if (connection.indexOf("|") != -1) {
|
if ( connection.indexOf( "|" ) != -1 )
|
||||||
|
{
|
||||||
return "|";
|
return "|";
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
return ":";
|
return ":";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -524,10 +608,12 @@ public final class ScmUtil {
|
|||||||
* @param tok
|
* @param tok
|
||||||
* @return String[]
|
* @return String[]
|
||||||
*/
|
*/
|
||||||
public String[] tokenizerToArray(EnhancedStringTokenizer tok) {
|
public String[] tokenizerToArray( EnhancedStringTokenizer tok )
|
||||||
|
{
|
||||||
List l = new ArrayList();
|
List l = new ArrayList();
|
||||||
|
|
||||||
while (tok.hasMoreTokens()) {
|
while ( tok.hasMoreTokens() )
|
||||||
|
{
|
||||||
l.add( tok.nextToken() );
|
l.add( tok.nextToken() );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -543,8 +629,10 @@ public final class ScmUtil {
|
|||||||
* POM value to test.
|
* POM value to test.
|
||||||
* @return Is the value valid.
|
* @return Is the value valid.
|
||||||
*/
|
*/
|
||||||
protected boolean isValid(String value) {
|
protected boolean isValid( String value )
|
||||||
if ((value != null) && !value.trim().equals("")) {
|
{
|
||||||
|
if ( ( value != null ) && !value.trim().equals( "" ) )
|
||||||
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user