I don't feel that this is as backward compatible as I
mentioned at first.  A spec I need is currently
unavailable, so until I can see the spec please keep
this in mind.

Thanks,
Erik

At 03:57 PM 6/1/2000 -0500, you wrote:
Good stuff, let me do this again:

I noticed this comment in Cvs taskdef:
// XXX: we should use JCVS (www.ice.com/JCVS) instead of command line
// execution so that we don't rely on having native CVS stuff around (SM)


So took a stab at it and started a optional Jcvs taskdef, which uses Tim's
com.ice.cvsc package.
( http://www.gjt.org/servlets/JCVSlet/zip/ice/com/ice/cvsc/cvsc.zip )

I've included a two patchs. One to add the Jcvs taskdef to the defaults.properties.
( as an optional taskdef ). Another to update the build.xml ( to check for the
existence of the com.ice.cvsc. classes ) as well as the Jcvs.java file.


Jcvs is backwards compatible with Cvs, except for the "-r" option. ( Because I
didn't implement it, not because it is unimplementable ).

Thanks to Conor and Glen for the feedback!
Erik Meade


--- build.xml.orig Thu Jun 01 14:58:34 2000 +++ build.xml Thu Jun 01 14:58:14 2000 @@ -37,6 +37,7 @@ <target name="check_for_optional_packages"> <available property="bsf.present" classname="com.ibm.bsf.BSFManager" /> <available property="netrexx.present" classname="netrexx.lang.Rexx" /> + <available property="cvsc.present" classname="com.ice.cvsc.CVSProject" /> </target>

<!-- =================================================================== -->
@@ -60,6 +61,7 @@
optimize="on" >
<exclude name="**/Script.java" unless="bsf.present" />
<exclude name="**/NetRexxC.java" unless="netrexx.present" />
+ <exclude name="**/Jcvs.java" unless="cvsc.present" />
</javac>


     <copydir src="${src.dir}" dest="${build.classes}">



--- defaults.properties.orig    Thu Jun 01 00:19:50 2000
+++ defaults.properties Thu Jun 01 14:50:36 2000
@@ -34,6 +34,7 @@
 script=org.apache.tools.ant.taskdefs.optional.Script
 netrexxc=org.apache.tools.ant.taskdefs.optional.NetRexxC
 renameext=org.apache.tools.ant.taskdefs.optional.RenameExtensions
+jcvs=org.apache.tools.ant.taskdefs.Jcvs

 # deprecated ant tasks (kept for back compatibility)
 javadoc2=org.apache.tools.ant.taskdefs.Javadoc


/* * The Apache Software License, Version 1.1 * * Copyright (c) 1999 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 [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.optional.taskdefs;

import com.ice.cvsc.*;
import java.io.File;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.taskdefs.Exec;

/**
 *
 *
 * @author [EMAIL PROTECTED]
 */

public class Jcvs extends Exec implements CVSUserInterface {

        String userName;
        String password = "anoncvs";
        String hostName;
        String repository;
        String rootDirectory;
        String localDirectory;
        String tempDirectory;

    boolean isPServer = true;
    int connMethod = CVSRequest.METHOD_INETD;
    int cvsPort = 2401;

    public void execute() throws BuildException {
                if (tempDirectory == null) {
                        tempDirectory = System.getProperty("java.io.tmpdir");
                }

                if (localDirectory == null) {
                        localDirectory = ".";
                }

CVSRequest request = new CVSRequest();
boolean parsed = request.parseControlString(":co:N:ANP:deou:");


                CVSEntryVector entries = new CVSEntryVector();

                CVSArgumentVector arguments = new CVSArgumentVector();
                arguments.appendArgument(repository);

CVSClient client = new CVSClient(hostName, cvsPort );
CVSProject project = new CVSProject(client);
project.setUserName(userName);
project.setTempDirectory(tempDirectory);
project.setRepository(repository);
project.setRootDirectory(rootDirectory);
project.setLocalRootDirectory(localDirectory);
project.setPServer(isPServer);
project.setConnectionMethod(connMethod);
project.setPassword(CVSScramble.scramblePassword( password, 'A' ));
project.establishRootEntry(rootDirectory);


                request.setPServer(isPServer);
                request.setUserName(userName);
                request.setPassword(project.getPassword());
                request.setConnectionMethod(connMethod);
                request.setPort(cvsPort);
                request.setHostName(hostName);
                request.setRepository(repository);
                request.setRootDirectory(rootDirectory);
                request.setRootRepository(rootDirectory);
                request.setLocalDirectory(localDirectory);
                request.responseHandler = project;
                request.traceRequest = CVSProject.overTraceRequest;
                request.traceResponse = CVSProject.overTraceResponse;
                request.traceTCPData = CVSProject.overTraceTCP;
                request.traceProcessing = CVSProject.overTraceProcessing;
                request.setEntries(entries);
                request.appendArguments(arguments);
                request.setUserInterface(this);

                CVSResponse response = client.processCVSRequest(request);
                response.deleteTempFiles();
        }

    public void setDest(String dest) {
                setDir(dest);
    }

    public void setHostName(String hostName) {
                this.hostName = hostName;
    }

    public void setLocalDir(String localDir) {
                this.localDirectory = localDir;
    }

    public void setPassword(String password) {
                this.password = password;
    }

        public void setPort(int port) {
                cvsPort = port;
        }

    public void setRepository(String repository) {
                this.repository = repository;
    }

    public void setRootDir(String rootDir) {
                rootDirectory = rootDir;
    }

    public void setTempDir(String tempDir) {
                tempDirectory = tempDir;
    }

    public void setUserName(String userName) {
                this.userName = userName;
    }

        // For backward compatabitly with Cvs.
    public void setCvsRoot(String root) {
                // XXX: handle non isPServer
                if (root.startsWith(":pserver:")) {
                        isPServer = true;
                        // strip off the :pserver:
                        root = root.substring(9);
                }

                int atIndex = root.indexOf("@");
                int cvsrootIndex = root.indexOf(":");

                userName = root.substring(0, atIndex);
                hostName = root.substring(atIndex + 1, cvsrootIndex);
                rootDirectory = root.substring(cvsrootIndex + 1);
    }

    public void setPackage(String p) {
                repository = p;
    }

        // XXX: Need to handle this in the Jcvs way
    public void setTag(String p) {
        // Check if not real tag => set it to null
        if (p != null) {
            if (p.trim().equals(""))
                p = null;
        }
//        this.tag = p;
    }

        //
        // CVS USER INTERFACE METHODS
        //

        public void uiDisplayProgressMsg( String message ) {
                project.log( message, "jcvs", project.MSG_VERBOSE );
        }

        public void     uiDisplayProgramError( String error ) {
        project.log( error, "jvcs:error", project.MSG_ERR );
    }

        public void uiDisplayResponse( CVSResponse response ) {
        }

        //
        // END OF CVS USER INTERFACE METHODS
        //

}



Reply via email to