ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Erik Meade <eme...@geekfarm.org>
Subject [PATCH]? Jcvs taskdef
Date Thu, 01 Jun 2000 05:37:42 GMT
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 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 patch to add the Jcvs taskdef to the defaults.properties 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 ).

This is my first time so please be gentle :)
Erik Meade


--- defaults.properties.orig    Thu Jun 01 00:19:50 2000
+++ defaults.properties Wed May 31 19:09:24 2000
@@ -29,6 +29,7 @@
  filter=org.apache.tools.ant.taskdefs.Filter
  fixcrlf=org.apache.tools.ant.taskdefs.FixCRLF
  rename=org.apache.tools.ant.taskdefs.Rename
+jcvs=org.apache.tools.ant.taskdefs.Jcvs

  # optional tasks
  script=org.apache.tools.ant.taskdefs.optional.Script


/*
  * 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 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.
  * ====================================================================
  *
  * 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;

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

/**
  *
  *
  * @author emeade@geekfarm.org
  */

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 ) {
		System.out.println("[exec] " + message);
	}

	public void	uiDisplayProgramError( String error ) {
		System.out.println("[error] " + error);
	}

	public void uiDisplayResponse( CVSResponse response ) {
	}

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

}


Mime
View raw message