epugh 2003/10/29 08:23:33
Modified: src/plugins-build/changelog/xdocs changes.xml
src/plugins-build/changelog/src/test/org/apache/maven/cvslib
CvsChangeLogGeneratorTest.java
src/plugins-build/changelog/src/main/org/apache/maven/cvslib
CvsConnection.java CvsChangeLogGenerator.java
Added: src/plugins-build/changelog/src/test/org/apache/maven/cvslib
CvsConnectionTest.java
Log:
Change so that if the cvslib fails to connect, then fall back to using the cvs
executable.
Revision Changes Path
1.14 +4 -0 maven/src/plugins-build/changelog/xdocs/changes.xml
Index: changes.xml
===================================================================
RCS file: /home/cvs/maven/src/plugins-build/changelog/xdocs/changes.xml,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- changes.xml 28 Oct 2003 10:57:43 -0000 1.13
+++ changes.xml 29 Oct 2003 16:23:33 -0000 1.14
@@ -8,6 +8,10 @@
<body>
<release version="1.4-dev" date="in cvs">
+ <action dev="epugh" type="update">
+ If, using the cvslib, fails, then fall back to using
+ the command line call to the cvs executable.
+ </action>
<action dev="epugh" type="update">
Added java based CVS library using cvslib. Removed
requirement for cvs executable.
1.8 +7 -3
maven/src/plugins-build/changelog/src/test/org/apache/maven/cvslib/CvsChangeLogGeneratorTest.java
Index: CvsChangeLogGeneratorTest.java
===================================================================
RCS file:
/home/cvs/maven/src/plugins-build/changelog/src/test/org/apache/maven/cvslib/CvsChangeLogGeneratorTest.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- CvsChangeLogGeneratorTest.java 29 Oct 2003 14:40:37 -0000 1.7
+++ CvsChangeLogGeneratorTest.java 29 Oct 2003 16:23:33 -0000 1.8
@@ -128,7 +128,11 @@
new Test(
"scm|cvs|local|local|D:/home/cvspublic|maven",
"cvs|-d|D:/home/cvspublic|log",
- null)};
+ null),
+ new Test(
+ "scm:cvs:extssh:[EMAIL PROTECTED]:/home/cvs:maven",
+ "cvs|-d|:extssh:[EMAIL PROTECTED]:/home/cvs|log",
+ null)};
public void testParse() throws Throwable
{
1.1
maven/src/plugins-build/changelog/src/test/org/apache/maven/cvslib/CvsConnectionTest.java
Index: CvsConnectionTest.java
===================================================================
package org.apache.maven.cvslib;
/*
* ==================================================================== The
* Apache Software License, Version 1.1
*
* Copyright (c) 2002 The Apache Software Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met: 1.
* Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer. 2. Redistributions in
* binary form must reproduce the above copyright notice, this list of
* conditions and the following disclaimer in the documentation and/or other
* materials provided with the distribution. 3. The end-user documentation
* included with the redistribution, if any, must include the following
* acknowledgment: "This product includes software developed by the Apache
* Software Foundation (http://www.apache.org/)." Alternately, this
* acknowledgment may appear in the software itself, if and wherever such
* third-party acknowledgments normally appear. 4. The names "Apache" and
* "Apache Software Foundation" and "Apache Maven" must not be used to endorse
* or promote products derived from this software without prior written
* permission. For written permission, please contact [EMAIL PROTECTED] 5.
* Products derived from this software may not be called "Apache", "Apache
* Maven", nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many individuals
* on behalf of the Apache Software Foundation. For more information on the
* Apache Software Foundation, please see <http://www.apache.org/> .
*/
import java.io.File;
import junit.framework.TestCase;
/**
* Test cases for [EMAIL PROTECTED] CvsLogListener}
*
* @author <a href="mailto:[EMAIL PROTECTED]">Eric Pugh</a>
* @version $Id: CvsConnectionTest.java,v 1.1 2003/10/29 16:23:33 epugh Exp $
*/
public class CvsConnectionTest extends TestCase
{
/**
* Create a test with the given name
*
* @param testName the name of the test
*/
public CvsConnectionTest(String testName)
{
super(testName);
}
/**
* Test of making a pserver connection.
*
* @throws Exception when there is an unexpected problem
*/
public void testConnectWithPServer() throws Exception
{
ExposeGenerator eg = new ExposeGenerator();
eg.setConnection(
"scm:cvs:pserver:[EMAIL PROTECTED]:/home/cvspublic:maven");
String args[] = eg.getScmLogCommand().getArguments();
File f = new File(".").getAbsoluteFile();
String localPath = f.toString();
CvsLogListener listener = new CvsLogListener();
CvsConnection.processCommand(args, localPath, listener);
assertTrue(listener.getStdout().length() > 0);
}
/**
* Test of making an ssh connection
*
* @throws Exception when there is an unexpected problem
*/
public void testConnectWithExtSSH() throws Exception
{
ExposeGenerator eg = new ExposeGenerator();
eg.setConnection(
"scm:cvs:extssh:[EMAIL PROTECTED]:/home/pugh/cvsroot:parsys");
String args[] = eg.getScmLogCommand().getArguments();
File f = new File(".").getAbsoluteFile();
String localPath = f.toString();
CvsLogListener listener = new CvsLogListener();
try
{
CvsConnection.processCommand(args, localPath, listener);
fail("should have thrown exception");
}
catch (IllegalArgumentException e)
{
// good
}
}
}
1.4 +91 -113
maven/src/plugins-build/changelog/src/main/org/apache/maven/cvslib/CvsConnection.java
Index: CvsConnection.java
===================================================================
RCS file:
/home/cvs/maven/src/plugins-build/changelog/src/main/org/apache/maven/cvslib/CvsConnection.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- CvsConnection.java 29 Oct 2003 14:40:37 -0000 1.3
+++ CvsConnection.java 29 Oct 2003 16:23:33 -0000 1.4
@@ -1,58 +1,47 @@
package org.apache.maven.cvslib;
-/* ====================================================================
- * The Apache Software License, Version 1.1
- *
- * Copyright (c) 2002 The Apache Software Foundation. All rights
- * reserved.
- *
+/*
+ * ==================================================================== The
+ * Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2002 The Apache Software Foundation. All rights reserved.
+ *
* Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- *
- * 3. The end-user documentation included with the redistribution,
- * if any, must include the following acknowledgment:
- * "This product includes software developed by the
- * Apache Software Foundation (http://www.apache.org/)."
- * Alternately, this acknowledgment may appear in the software itself,
- * if and wherever such third-party acknowledgments normally appear.
- *
- * 4. The names "Apache" and "Apache Software Foundation" and
- * "Apache Maven" must not be used to endorse or promote products
- * derived from this software without prior written permission. For
- * written permission, please contact [EMAIL PROTECTED]
- *
- * 5. Products derived from this software may not be called "Apache",
- * "Apache Maven", nor may "Apache" appear in their name, without
- * prior written permission of the Apache Software Foundation.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
- * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
+ * modification, are permitted provided that the following conditions are met:
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The end-user documentation included with the redistribution, if any,
+ * must include the following acknowledgment: "This product includes software
+ * developed by the Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself, if and
+ * wherever such third-party acknowledgments normally appear.
+ * 4. The names "Apache" and "Apache Software Foundation" and "Apache Maven"
+ * must not be used to endorse or promote products derived from this software
+ * without prior written permission. For written permission, please contact
+ * [EMAIL PROTECTED]
+ * 5. Products derived from this software may not be called "Apache", "Apache
+ * Maven", nor may "Apache" appear in their name, without prior written
+ * permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * <http://www.apache.org/>.
- *
+ *
+ * This software consists of voluntary contributions made by many individuals
+ * on behalf of the Apache Software Foundation. For more information on the
+ * Apache Software Foundation, please see <http://www.apache.org/> .
+ *
* ====================================================================
*/
@@ -80,47 +69,46 @@
/**
* A Cvs connection that simulates a command line interface.
- *
+ *
* @author <a href="mailto:[EMAIL PROTECTED]">Eric Pugh</a>
*/
public class CvsConnection
{
/** Log */
- private static final Log LOG =
- LogFactory.getLog(CvsConnection.class);
+ private static final Log LOG = LogFactory.getLog(CvsConnection.class);
/**
- * The path to the repository on the server
- */
+ * The path to the repository on the server
+ */
private String repository;
/**
- * The local path to use to perform operations (the top level)
- */
+ * The local path to use to perform operations (the top level)
+ */
private String localPath;
/**
- * The connection to the server
- */
+ * The connection to the server
+ */
private Connection connection;
/**
- * The client that manages interactions with the server
- */
+ * The client that manages interactions with the server
+ */
private Client client;
/**
- * The global options being used. GlobalOptions are only global for a
- * particular command.
- */
+ * The global options being used. GlobalOptions are only global for a
+ * particular command.
+ */
private GlobalOptions globalOptions;
/**
- * Execute a configured CVS command
- *
- * @param command the command to execute
- * @throws CommandException if there is an error running the command
- */
+ * Execute a configured CVS command
+ *
+ * @param command the command to execute
+ * @throws CommandException if there is an error running the command
+ */
public void executeCommand(Command command)
throws CommandException, AuthenticationException
{
@@ -143,8 +131,8 @@
}
/**
- * Creates the connection and the client and connects.
- */
+ * Creates the connection and the client and connects.
+ */
private void connect(CVSRoot root, String password)
throws IllegalArgumentException, AuthenticationException
{
@@ -168,13 +156,12 @@
}
}
-
/**
- * Obtain the CVS root, either from the -D option cvs.root or from the CVS
- * directory
- *
- * @return the CVSRoot string
- */
+ * Obtain the CVS root, either from the -D option cvs.root or from the CVS
+ * directory
+ *
+ * @return the CVSRoot string
+ */
private static String getCVSRoot(String workingDir)
{
String root = null;
@@ -219,12 +206,12 @@
}
/**
- * Process global options passed into the application
- *
- * @param args the argument list, complete
- * @param globalOptions the global options structure that will be passed to
- * the command
- */
+ * Process global options passed into the application
+ *
+ * @param args the argument list, complete
+ * @param globalOptions the global options structure that will be passed to
+ * the command
+ */
private static int processGlobalOptions(
String[] args,
GlobalOptions globalOptions)
@@ -247,12 +234,12 @@
}
/**
- * Lookup the password in the .cvspass file. This file is looked for in the
- * user.home directory if the option cvs.passfile is not set
- *
- * @param CVSRoot the CVS root for which the password is being searched
- * @return the password, scrambled
- */
+ * Lookup the password in the .cvspass file. This file is looked for in the
+ * user.home directory if the option cvs.passfile is not set
+ *
+ * @param CVSRoot the CVS root for which the password is being searched
+ * @return the password, scrambled
+ */
private static String lookupPassword(String cvsRoot)
{
File passFile =
@@ -298,23 +285,22 @@
}
if (password == null)
{
- LOG.error(
- "Didn't find password for CVSROOT '" + cvsRoot + "'.");
+ LOG.error("Didn't find password for CVSROOT '" + cvsRoot + "'.");
}
return password;
}
/**
- * Process the CVS command passed in args[] array with all necessary
- * options. The only difference from main() method is, that this method
- * does not exit the JVM and provides command output.
- *
- * @param args The command with options
- */
+ * Process the CVS command passed in args[] array with all necessary
+ * options. The only difference from main() method is, that this method
+ * does not exit the JVM and provides command output.
+ *
+ * @param args The command with options
+ */
public static boolean processCommand(
String[] args,
String localPath,
- CVSListener listener)
+ CVSListener listener) throws Exception
{
// Set up the CVSRoot. Note that it might still be null after this
@@ -385,7 +371,6 @@
return false;
}
-
String password = null;
if (CVSRoot.METHOD_PSERVER.equals(root.getMethod()))
@@ -412,20 +397,13 @@
// command. This is the case for command-line CVS but not
// usually for GUI front-ends
cvsCommand.setLocalPath(localPath);
- try
- {
- cvsCommand.connect(root, password);
- cvsCommand.addListener(listener);
- cvsCommand.executeCommand(c);
- }
- catch (Exception t)
- {
- LOG.error("Error: " + t,t);
- return false;
- }
+
+ cvsCommand.connect(root, password);
+ cvsCommand.addListener(listener);
+ cvsCommand.executeCommand(c);
+
+
return true;
}
-
-
}
1.9 +39 -26
maven/src/plugins-build/changelog/src/main/org/apache/maven/cvslib/CvsChangeLogGenerator.java
Index: CvsChangeLogGenerator.java
===================================================================
RCS file:
/home/cvs/maven/src/plugins-build/changelog/src/main/org/apache/maven/cvslib/CvsChangeLogGenerator.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- CvsChangeLogGenerator.java 29 Oct 2003 14:40:37 -0000 1.8
+++ CvsChangeLogGenerator.java 29 Oct 2003 16:23:33 -0000 1.9
@@ -7,22 +7,21 @@
* Copyright (c) 2002 The Apache Software Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The end-user documentation included with the redistribution, if any,
- * must include the following acknowledgment: "This product includes software
- * developed by the Apache Software Foundation (http://www.apache.org/)."
- * Alternately, this acknowledgment may appear in the software itself, if and
- * wherever such third-party acknowledgments normally appear.
- * 4. The names "Apache" and "Apache Software Foundation" and "Apache Maven"
- * must not be used to endorse or promote products derived from this software
- * without prior written permission. For written permission, please contact
- * [EMAIL PROTECTED]
- * 5. Products derived from this software may not be called "Apache", "Apache
+ * modification, are permitted provided that the following conditions are met: 1.
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer. 2. Redistributions in
+ * binary form must reproduce the above copyright notice, this list of
+ * conditions and the following disclaimer in the documentation and/or other
+ * materials provided with the distribution. 3. The end-user documentation
+ * included with the redistribution, if any, must include the following
+ * acknowledgment: "This product includes software developed by the Apache
+ * Software Foundation (http://www.apache.org/)." Alternately, this
+ * acknowledgment may appear in the software itself, if and wherever such
+ * third-party acknowledgments normally appear. 4. The names "Apache" and
+ * "Apache Software Foundation" and "Apache Maven" must not be used to endorse
+ * or promote products derived from this software without prior written
+ * permission. For written permission, please contact [EMAIL PROTECTED] 5.
+ * Products derived from this software may not be called "Apache", "Apache
* Maven", nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
@@ -65,7 +64,6 @@
* A CVS implementation of the [EMAIL PROTECTED]
org.apache.maven.changelog.ChangeLog}
* interface.
*
- *
* @author Glenn McAllister
* @author <a href="mailto:[EMAIL PROTECTED]">Eric Pugh</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Jeff Martin</a>
@@ -91,10 +89,10 @@
public static final int POS_SCM_MODULE = 5;
/**
- * Execute cvslib client driving the given parser.
- * @todo Currently the output from the logListener is a String, which is
- * then converted to an InputStream. The output of logListener really should
- * be an input stream.
+ * Execute cvslib client driving the given parser. @todo Currently the
+ * output from the logListener is a String, which is then converted to an
+ * InputStream. The output of logListener really should be an input stream.
+ *
* @param parser A [EMAIL PROTECTED] ChangeLogParser parser}to process the scm
* output.
* @return A collection of [EMAIL PROTECTED] ChangeLogEntry entries}parsed
from the
@@ -121,14 +119,29 @@
}
clParser = parser;
- CvsConnection connection = new CvsConnection();
+
String[] args = getScmLogCommand().getArguments();
CvsLogListener logListener = new CvsLogListener();
-
- CvsConnection.processCommand(args,
this.changeLogExecutor.getBasedir().toString(), logListener);
+ try
+ {
+ CvsConnection.processCommand(
+ args,
+ this.changeLogExecutor.getBasedir().toString(),
+ logListener);
+ entries =
+ clParser.parse(
+ new ByteArrayInputStream(
+ logListener.getStdout().toString().getBytes()));
+ }
+ catch (IllegalArgumentException iae)
+ {
+ entries = super.getEntries(parser);
+ }
+ catch (Exception e){
+ LOG.error(e);
+ }
- entries = clParser.parse(new
ByteArrayInputStream(logListener.getStdout().toString().getBytes()));
-
+
return entries;
}
/**
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]