antoine 2004/01/28 15:24:52 Modified: docs/manual/CoreTasks cvsversion.html src/main/org/apache/tools/ant/taskdefs/cvslib CvsVersion.java Log: got hit by a line ending problem, now this will be the right format Revision Changes Path 1.2 +93 -93 ant/docs/manual/CoreTasks/cvsversion.html Index: cvsversion.html =================================================================== RCS file: /home/cvs/ant/docs/manual/CoreTasks/cvsversion.html,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- cvsversion.html 28 Jan 2004 22:47:13 -0000 1.1 +++ cvsversion.html 28 Jan 2004 23:24:52 -0000 1.2 @@ -1,93 +1,93 @@ -<html> - -<head> -<meta http-equiv="Content-Language" content="en-us"> -<title>CVSVersion Task</title> -<link rel="stylesheet" type="text/css" href="../stylesheets/antmanual.css"> -</head> - -<body> - -<h2><a name="cvs">CvsVersion</a></h2> -<h3>Description</h3> -<p> -This task allows to retrieve a CVS client and server version -</p> -<h3>Parameters</h3> -<table border="1" cellpadding="2" cellspacing="0"> - <tr> - <td valign="top"><b>Attribute</b></td> - <td valign="top"><b>Description</b></td> - <td align="center" valign="top"><b>Required</b></td> - </tr> - <tr> - <td colspan="3">Attributes from parent Cvs task which are meaningful here</td> - </tr> - <tr> - <td valign="top">cvsRoot</td> - <td valign="top">the <code>CVSROOT</code> variable.</td> - <td align="center" valign="top">No</td> - </tr> - <tr> - <td valign="top">cvsRsh</td> - <td valign="top">the <code>CVS_RSH</code> variable.</td> - <td align="center" valign="top">No</td> - </tr> - <tr> - <td valign="top">dest</td> - <td valign="top">directory containing the checked out version of the project</td> - <td align="center" valign="top">No, default is project's basedir.</td> - </tr> - <tr> - <td valign="top">package</td> - <td valign="top">the package/module to check out.</td> - <td align="center" valign="top">No</td> - </tr> - <tr> - <td valign="top">port</td> - <td valign="top">Port used by CVS to communicate with the server.</td> - <td align="center" valign="top">No, default port 2401.</td> - </tr> - <tr> - <td valign="top">passfile</td> - <td valign="top">Password file to read passwords from.</td> - <td align="center" valign="top">No, default file ~/.cvspass.</td> - </tr> - <tr> - <td valign="top">failonerror</td> - <td valign="top">Stop the build process if the command exits with a - return code other than <code>0</code>. Defaults to false</td> - <td align="center" valign="top">No</td> - </tr> - <tr> - <td colspan="3">Specific attributes</td> - </tr> - <tr> - <td valign="top">cvsclientproperty</td> - <td valign="top">Name of a property where the cvsclient version - should be stored</td> - <td align="center" valign="top">No</td> - </tr> - <tr> - <td valign="top">cvsserverproperty</td> - <td valign="top">Name of a property where the cvs server version - should be stored</td> - <td align="center" valign="top">No</td> - </tr> -</table> -<h3>Examples</h3> -<pre> <cvsversion cvsRoot=":pserver:[EMAIL PROTECTED]:/home/cvspublic" - passfile="/home/myself/.cvspass" - cvsserverproperty="apachecvsversion" - cvsclientproperty="localcvsversion" - /></pre> -<p>finds out the cvs client and server versions and stores the versions in the -properties called apachecvsversion and localcvsversion</p> - -<hr> -<p align="center">Copyright © 2004 Apache Software -Foundation. All rights Reserved.</p> - -</body> -</html> - +<html> + +<head> +<meta http-equiv="Content-Language" content="en-us"> +<title>CVSVersion Task</title> +<link rel="stylesheet" type="text/css" href="../stylesheets/antmanual.css"> +</head> + +<body> + +<h2><a name="cvs">CvsVersion</a></h2> +<h3>Description</h3> +<p> +This task allows to retrieve a CVS client and server version +</p> +<h3>Parameters</h3> +<table border="1" cellpadding="2" cellspacing="0"> + <tr> + <td valign="top"><b>Attribute</b></td> + <td valign="top"><b>Description</b></td> + <td align="center" valign="top"><b>Required</b></td> + </tr> + <tr> + <td colspan="3">Attributes from parent Cvs task which are meaningful here</td> + </tr> + <tr> + <td valign="top">cvsRoot</td> + <td valign="top">the <code>CVSROOT</code> variable.</td> + <td align="center" valign="top">No</td> + </tr> + <tr> + <td valign="top">cvsRsh</td> + <td valign="top">the <code>CVS_RSH</code> variable.</td> + <td align="center" valign="top">No</td> + </tr> + <tr> + <td valign="top">dest</td> + <td valign="top">directory containing the checked out version of the project</td> + <td align="center" valign="top">No, default is project's basedir.</td> + </tr> + <tr> + <td valign="top">package</td> + <td valign="top">the package/module to check out.</td> + <td align="center" valign="top">No</td> + </tr> + <tr> + <td valign="top">port</td> + <td valign="top">Port used by CVS to communicate with the server.</td> + <td align="center" valign="top">No, default port 2401.</td> + </tr> + <tr> + <td valign="top">passfile</td> + <td valign="top">Password file to read passwords from.</td> + <td align="center" valign="top">No, default file ~/.cvspass.</td> + </tr> + <tr> + <td valign="top">failonerror</td> + <td valign="top">Stop the build process if the command exits with a + return code other than <code>0</code>. Defaults to false</td> + <td align="center" valign="top">No</td> + </tr> + <tr> + <td colspan="3">Specific attributes</td> + </tr> + <tr> + <td valign="top">cvsclientproperty</td> + <td valign="top">Name of a property where the cvsclient version + should be stored</td> + <td align="center" valign="top">No</td> + </tr> + <tr> + <td valign="top">cvsserverproperty</td> + <td valign="top">Name of a property where the cvs server version + should be stored</td> + <td align="center" valign="top">No</td> + </tr> +</table> +<h3>Examples</h3> +<pre> <cvsversion cvsRoot=":pserver:[EMAIL PROTECTED]:/home/cvspublic" + passfile="/home/myself/.cvspass" + cvsserverproperty="apachecvsversion" + cvsclientproperty="localcvsversion" + /></pre> +<p>finds out the cvs client and server versions and stores the versions in the +properties called apachecvsversion and localcvsversion</p> + +<hr> +<p align="center">Copyright © 2004 Apache Software +Foundation. All rights Reserved.</p> + +</body> +</html> + 1.3 +190 -190 ant/src/main/org/apache/tools/ant/taskdefs/cvslib/CvsVersion.java Index: CvsVersion.java =================================================================== RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/cvslib/CvsVersion.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- CvsVersion.java 28 Jan 2004 22:51:56 -0000 1.2 +++ CvsVersion.java 28 Jan 2004 23:24:52 -0000 1.3 @@ -1,190 +1,190 @@ -/* - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2004 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 acknowlegement: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowlegement may appear in the software itself, - * if and wherever such third-party acknowlegements normally appear. - * - * 4. The names "Ant" and "Apache Software - * Foundation" 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" - * nor may "Apache" appear in their names without prior written - * permission of the Apache Group. - * - * 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/>. - */ -package org.apache.tools.ant.taskdefs.cvslib; - -import org.apache.tools.ant.taskdefs.AbstractCvsTask; - -import java.io.ByteArrayOutputStream; -import java.util.StringTokenizer; - -/** - * this task allows to find out the client and the server version of a - * CVS installation - * - * example usage : - * <cvsversion - * cvsRoot=":pserver:[EMAIL PROTECTED]:/home/cvspublic" - * passfile="c:/programme/cygwin/home/antoine/.cvspass" - * clientversionproperty="apacheclient" - * serverversionproperty="apacheserver" /> - * - * the task can be used also in the API by calling its execute method, - * then calling getServerVersion and/or getClientVersion - * - * @ant.task category="scm" - * @author Antoine Levy-Lambert - * @since ant 1.6.1 - */ -public class CvsVersion extends AbstractCvsTask { - static final long VERSION_1_11_2 = 11102; - static final long MULTIPLY = 100; - private String clientVersion; - private String serverVersion; - private String clientVersionProperty; - private String serverVersionProperty; - /** - * get the CVS client version - * @return CVS client version - */ - public String getClientVersion() { - return clientVersion; - } - /** - * get the CVS server version - * @return CVS server version - */ - public String getServerVersion() { - return serverVersion; - } - /** - * set a property where to store the CVS client version - * @param clientVersionProperty property for CVS client version - */ - public void setClientVersionProperty(String clientVersionProperty) { - this.clientVersionProperty = clientVersionProperty; - } - - /** - * set a property where to store the CVS server version - * @param serverVersionProperty property for CVS server version - */ - public void setServerVersionProperty(String serverVersionProperty) { - this.serverVersionProperty = serverVersionProperty; - } - /** - * find out if the server version supports log with S option - * @return boolean indicating if the server version supports log with S option - */ - public boolean supportsCvsLogWithSOption() { - if (serverVersion == null) { - return false; - } - StringTokenizer mySt = new StringTokenizer(serverVersion, "."); - long versionNumber; - long counter = MULTIPLY * MULTIPLY; - long version = 0; - while (mySt.hasMoreTokens()) { - String s = mySt.nextToken(); - int i = 0; - for (i = 0; i < s.length(); i++) { - if (!Character.isDigit(s.charAt(i))) { - break; - } - } - String s2 = s.substring(0, i); - version = version + counter * Long.parseLong(s2); - if (counter == 1) { - break; - } - counter = counter / MULTIPLY; - } - return (version >= VERSION_1_11_2); - } - /** - * the execute method running CvsVersion - */ - public void execute() { - ByteArrayOutputStream bos = new ByteArrayOutputStream(); - this.setOutputStream(bos); - ByteArrayOutputStream berr = new ByteArrayOutputStream(); - this.setErrorStream(berr); - setCommand("version"); - super.execute(); - String output = bos.toString(); - StringTokenizer st = new StringTokenizer(output); - boolean client = false; - boolean server = false; - boolean cvs = false; - while (st.hasMoreTokens()) { - String currentToken = st.nextToken(); - if (currentToken.equals("Client:")) { - client = true; - } else if (currentToken.equals("Server:")) { - server = true; - } else if (currentToken.equals("(CVS)")) { - cvs = true; - } - if (client && cvs) { - if (st.hasMoreTokens()) { - clientVersion = st.nextToken(); - } - client = false; - cvs = false; - } else if (server && cvs) { - if (st.hasMoreTokens()) { - serverVersion = st.nextToken(); - } - server = false; - cvs = false; - } - - } - if (clientVersionProperty != null) { - getProject().setNewProperty(clientVersionProperty, clientVersion); - } - if (serverVersionProperty != null) { - getProject().setNewProperty(serverVersionProperty, serverVersion); - } - } -} +/* + * The Apache Software License, Version 1.1 + * + * Copyright (c) 2004 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 acknowlegement: + * "This product includes software developed by the + * Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowlegement may appear in the software itself, + * if and wherever such third-party acknowlegements normally appear. + * + * 4. The names "Ant" and "Apache Software + * Foundation" 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" + * nor may "Apache" appear in their names without prior written + * permission of the Apache Group. + * + * 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/>. + */ +package org.apache.tools.ant.taskdefs.cvslib; + +import org.apache.tools.ant.taskdefs.AbstractCvsTask; + +import java.io.ByteArrayOutputStream; +import java.util.StringTokenizer; + +/** + * this task allows to find out the client and the server version of a + * CVS installation + * + * example usage : + * <cvsversion + * cvsRoot=":pserver:[EMAIL PROTECTED]:/home/cvspublic" + * passfile="c:/programme/cygwin/home/antoine/.cvspass" + * clientversionproperty="apacheclient" + * serverversionproperty="apacheserver" /> + * + * the task can be used also in the API by calling its execute method, + * then calling getServerVersion and/or getClientVersion + * + * @ant.task category="scm" + * @author Antoine Levy-Lambert + * @since ant 1.6.1 + */ +public class CvsVersion extends AbstractCvsTask { + static final long VERSION_1_11_2 = 11102; + static final long MULTIPLY = 100; + private String clientVersion; + private String serverVersion; + private String clientVersionProperty; + private String serverVersionProperty; + /** + * get the CVS client version + * @return CVS client version + */ + public String getClientVersion() { + return clientVersion; + } + /** + * get the CVS server version + * @return CVS server version + */ + public String getServerVersion() { + return serverVersion; + } + /** + * set a property where to store the CVS client version + * @param clientVersionProperty property for CVS client version + */ + public void setClientVersionProperty(String clientVersionProperty) { + this.clientVersionProperty = clientVersionProperty; + } + + /** + * set a property where to store the CVS server version + * @param serverVersionProperty property for CVS server version + */ + public void setServerVersionProperty(String serverVersionProperty) { + this.serverVersionProperty = serverVersionProperty; + } + /** + * find out if the server version supports log with S option + * @return boolean indicating if the server version supports log with S option + */ + public boolean supportsCvsLogWithSOption() { + if (serverVersion == null) { + return false; + } + StringTokenizer mySt = new StringTokenizer(serverVersion, "."); + long versionNumber; + long counter = MULTIPLY * MULTIPLY; + long version = 0; + while (mySt.hasMoreTokens()) { + String s = mySt.nextToken(); + int i = 0; + for (i = 0; i < s.length(); i++) { + if (!Character.isDigit(s.charAt(i))) { + break; + } + } + String s2 = s.substring(0, i); + version = version + counter * Long.parseLong(s2); + if (counter == 1) { + break; + } + counter = counter / MULTIPLY; + } + return (version >= VERSION_1_11_2); + } + /** + * the execute method running CvsVersion + */ + public void execute() { + ByteArrayOutputStream bos = new ByteArrayOutputStream(); + this.setOutputStream(bos); + ByteArrayOutputStream berr = new ByteArrayOutputStream(); + this.setErrorStream(berr); + setCommand("version"); + super.execute(); + String output = bos.toString(); + StringTokenizer st = new StringTokenizer(output); + boolean client = false; + boolean server = false; + boolean cvs = false; + while (st.hasMoreTokens()) { + String currentToken = st.nextToken(); + if (currentToken.equals("Client:")) { + client = true; + } else if (currentToken.equals("Server:")) { + server = true; + } else if (currentToken.equals("(CVS)")) { + cvs = true; + } + if (client && cvs) { + if (st.hasMoreTokens()) { + clientVersion = st.nextToken(); + } + client = false; + cvs = false; + } else if (server && cvs) { + if (st.hasMoreTokens()) { + serverVersion = st.nextToken(); + } + server = false; + cvs = false; + } + + } + if (clientVersionProperty != null) { + getProject().setNewProperty(clientVersionProperty, clientVersion); + } + if (serverVersionProperty != null) { + getProject().setNewProperty(serverVersionProperty, serverVersion); + } + } +}
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]