Return-Path: Mailing-List: contact ant-dev-help@jakarta.apache.org; run by ezmlm Delivered-To: mailing list ant-dev@jakarta.apache.org Received: (qmail 4164 invoked from network); 16 Nov 2000 13:28:03 -0000 Received: from mail.osaccess.net (HELO web1.mail.onsiteaccess.net) (209.83.168.38) by locus.apache.org with SMTP; 16 Nov 2000 13:28:03 -0000 Received: from Alan ([216.173.15.242]) by web1.mail.onsiteaccess.net (InterMail vK.4.02.00.10 201-232-116-110 license 5966c05b3ce4c9d877760f650a55a100) with SMTP id <20001116132240.RGYF262.web1@Alan> for ; Thu, 16 Nov 2000 08:22:40 -0500 From: "Alan Zall" To: "ant-dev" Subject: I added a new parameter to the vssget task Date: Thu, 16 Nov 2000 08:27:45 -0500 Message-ID: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_NextPart_000_0012_01C04FA7.187E3170" X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2911.0) X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2919.6700 Importance: Normal X-Spam-Rating: locus.apache.org 1.6.2 0/1000/N This is a multi-part message in MIME format. ------=_NextPart_000_0012_01C04FA7.187E3170 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit I added a new parameter to the vssget task. Currently the task assumes that autoResponse should use the default(-I-). I added the ability to set that to either (-I-Y/-I-N) for a parameter value of "Y/N" respectively. The absence of the parameter defaults to the original functionality of (-I-). Inskey, Inc 400 West Cummings Park Suite 4350 Woburn, MA 01801 Phone 781-497-2353 Fax 781-497-2357 email alan@inskey.com http://www.inskey.com ------=_NextPart_000_0012_01C04FA7.187E3170 Content-Type: application/octet-stream; name="MSVSS.java" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="MSVSS.java" /* * The Apache Software License, Version 1.1 * * Copyright (c) 2000 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 "The Jakarta Project", "Tomcat", 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 apache@apache.org. * * 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. * = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D * * 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 * . */ package org.apache.tools.ant.taskdefs.optional.vss; import org.apache.tools.ant.*; import org.apache.tools.ant.taskdefs.Execute; import org.apache.tools.ant.taskdefs.LogStreamHandler; import org.apache.tools.ant.types.Commandline; import java.io.File; /** * A base class for creating tasks for executing commands on Visual = SourceSafe. *

* The class extends the 'exec' task as it operates by executing the = ss.exe program * supplied with SourceSafe. By default the task expects ss.exe to be in = the path, * you can override this be specifying the ssdir attribute. *

*

* This class provides set and get methods for 'login' and 'vsspath' = attributes. It * also contains constants for the flags that can be passed to SS. *

* * @author Craig Cottingham * @author Andrew Everitt */ public abstract class MSVSS extends Task { private String m_SSDir =3D ""; private String m_vssLogin =3D null; private String m_vssPath =3D null; /** * Set the directory where ss.exe is located * * @param dir the directory containing ss.exe */ public final void setSsdir(String dir) { m_SSDir =3D project.translatePath(dir); } =20 /** * Builds and returns the command string to execute ss.exe */ public final String getSSCommand() { String toReturn =3D m_SSDir; if ( !toReturn.equals("") && !toReturn.endsWith("\\") ) { toReturn +=3D "\\"; } toReturn +=3D SS_EXE; =20 return toReturn; } /** * Set the login to use when accessing vss. *

* Should be formatted as username,password * * @param login the login string to use */ public final void setLogin(String login) { m_vssLogin =3D login; } /** * @return the appropriate login command if the 'login' attribute = was specified, otherwise an empty string */ public void getLoginCommand(Commandline cmd) { if ( m_vssLogin =3D=3D null ) { return; } else { cmd.createArgument().setValue(FLAG_LOGIN + m_vssLogin); } } /** * Set the path to the item in vss to operate on *

* Ant can't cope with a '$' sign in an attribute so we have to add = it here. * Also we strip off any 'vss://' prefix which is an XMS special and = should probably be removed! * * @param vssPath */ public final void setVsspath(String vssPath) { if ( vssPath.startsWith("vss://") ) { m_vssPath=3D PROJECT_PREFIX + vssPath.substring(5); } else { m_vssPath =3D PROJECT_PREFIX + vssPath; } } /** * @return m_vssPath */ public String getVsspath() { return m_vssPath; } protected int run(Commandline cmd) { try { Execute exe =3D new Execute(new LogStreamHandler(this,=20 = Project.MSG_INFO, = Project.MSG_WARN)); exe.setAntRun(project); exe.setWorkingDirectory(project.getBaseDir()); exe.setCommandline(cmd.getCommandline()); return exe.execute(); } catch (java.io.IOException e) { throw new BuildException(e, location); } } /** * Constant for the thing to execute */ private static final String SS_EXE =3D "ss"; /** */ public static final String PROJECT_PREFIX =3D "$"; /** * The 'Get' command */ public static final String COMMAND_GET =3D "Get"; /** * The 'Checkout' command */ public static final String COMMAND_CHECKOUT =3D "Checkout"; /** * The 'Label' command */ public static final String COMMAND_LABEL =3D "Label"; /** * The 'History' command */ public static final String COMMAND_HISTORY =3D "History"; /** */ public static final String FLAG_LOGIN =3D "-Y"; /** */ public static final String FLAG_OVERRIDE_WORKING_DIR =3D "-GL"; /** */ public static final String FLAG_AUTORESPONSE_DEF =3D "-I-"; /** */ public static final String FLAG_AUTORESPONSE_YES =3D "-I-Y"; /** */ public static final String FLAG_AUTORESPONSE_NO =3D "-I-N"; /** */ public static final String FLAG_RECURSION =3D "-R"; /** */ public static final String FLAG_VERSION =3D "-V"; /** */ public static final String FLAG_VERSION_DATE =3D "-Vd"; /** */ public static final String FLAG_VERSION_LABEL =3D "-VL"; /** */ public static final String FLAG_WRITABLE =3D "-W"; /** */ public static final String VALUE_NO =3D "-N"; /** */ public static final String VALUE_YES =3D "-Y"; } ------=_NextPart_000_0012_01C04FA7.187E3170 Content-Type: application/octet-stream; name="MSVSSGET.java" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="MSVSSGET.java" /* * The Apache Software License, Version 1.1 * * Copyright (c) 2000 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 "The Jakarta Project", "Tomcat", 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 apache@apache.org. * * 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. * = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D * * 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 * . */ package org.apache.tools.ant.taskdefs.optional.vss; import org.apache.tools.ant.*; import org.apache.tools.ant.types.Commandline; import org.apache.tools.ant.types.Path; import java.io.File; /** * Task to perform GET commands to Microsoft Visual Source Safe. *

* The following attributes are interpretted: * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
AttributeValuesRequired
loginusername,passwordNo
vsspathSourceSafe pathYes
localpathOverride the working directory and get to the specified = pathNo
writabletrue or falseNo
recursivetrue or falseNo
versiona version number to getNo
datea date stamp to get atNo
labela label to get forNo
*

Note that only one of version, date or label should be = specified

* * @author Craig Cottingham * @author Andrew Everitt */ public class MSVSSGET extends MSVSS { private String m_LocalPath =3D null; private boolean m_Recursive =3D false; private boolean m_Writable =3D false; private String m_Version =3D null; private String m_Date =3D null; private String m_Label =3D null; private String m_AutoResponse =3D null; /** * Executes the task. *

* Builds a command line to execute ss and then calls Exec's run = method * to execute the command line. */ public void execute() throws BuildException { Commandline commandLine =3D new Commandline(); int result =3D 0; // first off, make sure that we've got a command and a vssdir = ... if (getVsspath() =3D=3D null) { String msg =3D "vsspath attribute must be set!"; throw new BuildException(msg, location); } // now look for illegal combinations of things ... // build the command line from what we got the format is // ss Get VSS items [-G] [-H] [-I-] [-N] [-O] [-R] [-V] [-W] = [-Y] [-?] // as specified in the SS.EXE help commandLine.setExecutable(getSSCommand()); commandLine.createArgument().setValue(COMMAND_GET); // VSS items commandLine.createArgument().setValue(getVsspath()); // -GL getLocalpathCommand(commandLine); // -I- getAutoresponse(commandLine); // -R getRecursiveCommand(commandLine); // -V getVersionCommand(commandLine); // -W getWritableCommand(commandLine); // -Y getLoginCommand(commandLine); result =3D run(commandLine); if ( result !=3D 0 ) { String msg =3D "Failed executing: " + = commandLine.toString(); throw new BuildException(msg, location); } } /** * Set the local path. */ public void setLocalpath(Path localPath) { m_LocalPath =3D localPath.toString(); } /** * Builds and returns the -GL flag command if required *

* The localpath is created if it didn't exist */ public void getLocalpathCommand(Commandline cmd) { if (m_LocalPath =3D=3D null) { return; } else { // make sure m_LocalDir exists, create it if it doesn't File dir =3D project.resolveFile(m_LocalPath); if (!dir.exists()) { boolean done =3D dir.mkdirs(); if (done =3D=3D false) { String msg =3D "Directory " + m_LocalPath + " = creation was not " + "succesful for an unknown reason"; throw new BuildException(msg, location); } project.log("Created dir: " + dir.getAbsolutePath()); } cmd.createArgument().setValue(FLAG_OVERRIDE_WORKING_DIR + = m_LocalPath); } } /** * Set behaviour recursive or non-recursive */ public void setRecursive(boolean recursive) { m_Recursive =3D recursive; } /** * @return the 'recursive' command if the attribute was 'true', = otherwise an empty string */ public void getRecursiveCommand(Commandline cmd) { if ( !m_Recursive ) { return; } else { cmd.createArgument().setValue(FLAG_RECURSION); } } /** * Set behaviour, used in get command to make files that are 'got' = writable */ public final void setWritable(boolean argWritable) { m_Writable =3D argWritable; } /** * @return the 'make writable' command if the attribute was 'true', = otherwise an empty string */ public void getWritableCommand(Commandline cmd) { if ( !m_Writable ) { return; } else { cmd.createArgument().setValue(FLAG_WRITABLE); } } /** * Set the stored version string *

* Note we assume that if the supplied string has the value "null" = that something * went wrong and that the string value got populated from a null = object. This * happens if a ant variable is used e.g. version=3D"${ver_server}" = when ver_server * has not been defined to ant! */ public void setVersion(String version) { if (version.equals("") || version.equals("null") ) { m_Version =3D null; } else { m_Version =3D version; } } /** * Set the stored date string *

* Note we assume that if the supplied string has the value "null" = that something * went wrong and that the string value got populated from a null = object. This * happens if a ant variable is used e.g. date=3D"${date}" when date * has not been defined to ant! */ public void setDate(String date) { if (date.equals("") || date.equals("null") ) { m_Date =3D null; } else { m_Date =3D date; } } /** * Set the labeled version to operate on in SourceSafe *

* Note we assume that if the supplied string has the value "null" = that something * went wrong and that the string value got populated from a null = object. This * happens if a ant variable is used e.g. label=3D"${label_server}" = when label_server * has not been defined to ant! */ public void setLabel(String label) { if ( label.equals("") || label.equals("null") ) { m_Label =3D null; } else { m_Label =3D label; } } /** * Simple order of priority. Returns the first specified of version, = date, label * If none of these was specified returns "" */ public void getVersionCommand(Commandline cmd) { if ( m_Version !=3D null) { cmd.createArgument().setValue(FLAG_VERSION + m_Version); } else if ( m_Date !=3D null) { cmd.createArgument().setValue(FLAG_VERSION_DATE + m_Date); } else if (m_Label !=3D null) { cmd.createArgument().setValue(FLAG_VERSION_LABEL + m_Label); } } =20 public void setAutoresponse(String response){ if ( response.equals("") || response.equals("null") ) { m_AutoResponse =3D null; } else { m_AutoResponse =3D response; } } /** * Checks the value set for the autoResponse. * if it equals "Y" then we return -I-Y * if it equals "N" then we return -I-N * otherwise we return -I */ public void getAutoresponse(Commandline cmd) { if ( m_AutoResponse =3D=3D null) { cmd.createArgument().setValue(FLAG_AUTORESPONSE_DEF); } else if ( m_AutoResponse.equalsIgnoreCase("Y")) { cmd.createArgument().setValue(FLAG_AUTORESPONSE_YES); } else if ( m_AutoResponse.equalsIgnoreCase("N")) { cmd.createArgument().setValue(FLAG_AUTORESPONSE_NO); }else { cmd.createArgument().setValue(FLAG_AUTORESPONSE_DEF); } // end of else =09 } =20 } ------=_NextPart_000_0012_01C04FA7.187E3170--