o MAVEN-289: Apply patch from Eric Weidner to handle local repositories

git-svn-id: https://svn.apache.org/repos/asf/maven/maven-1/plugins/trunk@112967 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
bwalding
2003-02-21 22:00:51 +00:00
parent 0a882b8dac
commit 574f0cbfae
2 changed files with 40 additions and 32 deletions

View File

@@ -83,43 +83,40 @@ import org.apache.tools.ant.types.Commandline;
* @author <a href="mailto:peter@apache.org">Peter Donald</a>
* @author <a href="mailto:pete-apache-dev@kazmier.com">Pete Kazmier</a>
* @version
* $Id: CvsChangeLogGenerator.java,v 1.2 2003/02/17 20:53:42 bwalding Exp $
* $Id: CvsChangeLogGenerator.java,v 1.3 2003/02/21 22:00:50 bwalding Exp $
*/
class CvsChangeLogGenerator extends AbstractChangeLogGenerator
{
/** Log */
private static final Log LOG = LogFactory.getLog(
CvsChangeLogGenerator.class);
private static final Log LOG = LogFactory.getLog(CvsChangeLogGenerator.class);
/**
* @return the cvs command line to be executed.
*/
protected Commandline getScmLogCommand()
protected Commandline getScmLogCommand()
{
if (getConnection() == null)
{
throw new IllegalArgumentException("repository connection string"
+ " not specified");
throw new IllegalArgumentException("repository connection string" + " not specified");
}
String connection = getConnection();
if (connection.length() < 4) {
if (connection.length() < 4)
{
throw new IllegalArgumentException("repository connection string doesn't start with scm<delim>");
}
String inputDelim = connection.substring(3, 4);
StringTokenizer tokenizer = new StringTokenizer(getConnection(), inputDelim);
if (tokenizer.countTokens() < 6)
if (tokenizer.countTokens() < 6)
{
throw new IllegalArgumentException("repository connection string"
+ " contains less than six tokens");
throw new IllegalArgumentException("repository connection string" + " contains less than six tokens");
}
tokenizer.nextToken(); // skip 'scm'
if (!tokenizer.nextToken().equals("cvs"))
{
throw new IllegalArgumentException("repository connection string"
+ " does not specify 'cvs' as the scm");
throw new IllegalArgumentException("repository connection string" + " does not specify 'cvs' as the scm");
}
Commandline command = new Commandline();
@@ -131,12 +128,23 @@ class CvsChangeLogGenerator extends AbstractChangeLogGenerator
// :pserver:anoncvs@cvs.apache.org:/home/cvspublic
// use tokens 3+4+5
StringBuffer connectionBuffer = new StringBuffer(":");
connectionBuffer
.append(tokenizer.nextToken())
.append(":")
.append(tokenizer.nextToken())
.append(":")
.append(tokenizer.nextToken());
String connectionType = tokenizer.nextToken();
if (connectionType.equalsIgnoreCase("local"))
{
// throw away the next token 'user@host'
tokenizer.nextToken();
// use the local repository directory eg. '/home/cvspublic'
connectionBuffer = new StringBuffer(tokenizer.nextToken());
}
else
{
//create the cvsroot as the remote cvsroot
connectionBuffer = new StringBuffer(":");
connectionBuffer.append(connectionType).append(":").append(tokenizer.nextToken()).append(":").append(
tokenizer.nextToken());
}
command.createArgument().setValue(connectionBuffer.toString());
command.createArgument().setValue("log");
@@ -144,7 +152,7 @@ class CvsChangeLogGenerator extends AbstractChangeLogGenerator
{
command.createArgument().setValue(dateRange);
}
return command;
}
@@ -170,17 +178,14 @@ class CvsChangeLogGenerator extends AbstractChangeLogGenerator
* @throws IOException If the handler doesn't wish to handle the
* exception.
*/
protected void handleParserException(IOException ioe)
throws IOException
protected void handleParserException(IOException ioe) throws IOException
{
if (ioe.getMessage().indexOf("CreateProcess") != -1
|| ioe.getMessage().indexOf("cvs: not found") != -1)
if (ioe.getMessage().indexOf("CreateProcess") != -1 || ioe.getMessage().indexOf("cvs: not found") != -1)
{
// can't find CVS on Win32 or Linux...
if (LOG.isWarnEnabled())
if (LOG.isWarnEnabled())
{
LOG.warn("Unable to find cvs executable. "
+ "Changelog will be empty");
LOG.warn("Unable to find cvs executable. " + "Changelog will be empty");
}
}
else

View File

@@ -66,7 +66,7 @@ import junit.framework.TestCase;
/**
* @author <a href="bwalding@jakarta.org">Ben Walding</a>
* @version $Id: CvsChangeLogGeneratorTest.java,v 1.1 2003/02/17 20:53:05 bwalding Exp $
* @version $Id: CvsChangeLogGeneratorTest.java,v 1.2 2003/02/21 22:00:51 bwalding Exp $
*/
class ExposeGenerator extends CvsChangeLogGenerator
{
@@ -79,7 +79,7 @@ class ExposeGenerator extends CvsChangeLogGenerator
/**
* @author <a href="bwalding@jakarta.org">Ben Walding</a>
* @version $Id: CvsChangeLogGeneratorTest.java,v 1.1 2003/02/17 20:53:05 bwalding Exp $
* @version $Id: CvsChangeLogGeneratorTest.java,v 1.2 2003/02/21 22:00:51 bwalding Exp $
*/
public class CvsChangeLogGeneratorTest extends TestCase
{
@@ -116,6 +116,10 @@ public class CvsChangeLogGeneratorTest extends TestCase
new Test(
"scm|cvs|pserver|anoncvs@cvs.apache.org|D:/home/cvspublic|jakarta-turbine-maven|anoncvs",
"cvs|-d|:pserver:anoncvs@cvs.apache.org:D:/home/cvspublic|log",
null),
new Test(
"scm|cvs|local|local|D:/home/cvspublic|jakarta-turbine-maven|anoncvs",
"cvs|-d|D:/home/cvspublic|log",
null)};
public void testParse() throws Throwable
@@ -133,7 +137,6 @@ public class CvsChangeLogGeneratorTest extends TestCase
String[] expected = tokenizerToArray(new EnhancedStringTokenizer(test.args, "|"));
ExposeGenerator eg = new ExposeGenerator();
System.out.println("Processing conn = " + test.conn);
try
{