bodewig 01/04/27 05:36:12
Modified: . WHATSNEW
docs/manual/OptionalTasks pvcstask.html
src/main/org/apache/tools/ant/taskdefs defaults.properties
Added: src/main/org/apache/tools/ant/taskdefs/optional/pvcs
Pvcs.java PvcsProject.java
Removed: src/main/org/apache/tools/ant/taskdefs/optional Pvcs.java
Log:
Moved <pvcs> to a package of its own, added nested element to it to
handle multiple projects in one go.
Submitted by: Frank Wierzbicki <[EMAIL PROTECTED]>
Revision Changes Path
1.103 +5 -1 jakarta-ant/WHATSNEW
Index: WHATSNEW
===================================================================
RCS file: /home/cvs/jakarta-ant/WHATSNEW,v
retrieving revision 1.102
retrieving revision 1.103
diff -u -r1.102 -r1.103
--- WHATSNEW 2001/04/23 16:12:03 1.102
+++ WHATSNEW 2001/04/27 12:36:04 1.103
@@ -13,10 +13,12 @@
* several Zip methods have changed their signature as we now use a Zip
package of our own that handles Unix permissions for directories.
+* The <pvcs> task has been move to a package of its own.
+
Other changes:
--------------
-* New tasks: ear, p4counter, record
+* New tasks: ear, p4counter, record, cvspass
* Ant now uses JAXP 1.1
@@ -41,6 +43,8 @@
* <jar> now has a nested <metainf> element following the same idea as
<war>'s <webinf>.
+
+* <pvcs> can now handle multiple projects.
Fixed bugs:
-----------
1.2 +63 -2 jakarta-ant/docs/manual/OptionalTasks/pvcstask.html
Index: pvcstask.html
===================================================================
RCS file: /home/cvs/jakarta-ant/docs/manual/OptionalTasks/pvcstask.html,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- pvcstask.html 2001/02/23 05:01:54 1.1
+++ pvcstask.html 2001/04/27 12:36:06 1.2
@@ -3,7 +3,6 @@
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Language" content="en-us">
- <meta name="GENERATOR" content="Mozilla/4.76 [en] (X11; U; Linux 2.2.18
i686) [Netscape]">
<title>PVCS task</title>
</head>
<body>
@@ -132,7 +131,36 @@
<td VALIGN=TOP WIDTH="10%">No</td>
</tr>
</table>
+<h3><a name="nested">Nested Elements</a></h3>
+<h3>pvcsproject element</h3>
+<p><code>pvcs</code> supports a nested
+<code><pvcsproject></code> element, that represents a project
+within the PVCS repository to extract files from. By nesting multiple
+<code><pvcsproject></code> elements under the
+<code><pvcs></code> task, multiple projects can be
+specified.</p>
+
+<h3>Parameters</h3>
+
+<table BORDER CELLSPACING=0 CELLPADDING=2 >
+<tr>
+<td VALIGN=TOP WIDTH="12%"><b>Attribute</b></td>
+
+<td VALIGN=TOP WIDTH="78%"><b>Description</b></td>
+
+<td VALIGN=TOP WIDTH="10%"><b>Required</b></td>
+</tr>
+
+<tr>
+<td VALIGN=TOP WIDTH="12%">name</td>
+
+<td VALIGN=TOP WIDTH="78%">The name of the pvcs project</td>
+
+<td VALIGN=TOP WIDTH="10%">Yes</td>
+</tr>
+</table>
+
<h3>
Examples</h3>
The following set-up extracts the latest version of the files in the pvcs
@@ -143,7 +171,7 @@
-->
<br> <!--
===================================================================
-->
-<br> <target name="getlastes">
+<br> <target name="getlatest">
<br> < pvcs
repository="/mnt/pvcs"
pvcsproject="/myprj"/>
<br> </target></ul>
@@ -163,6 +191,39 @@
BUILD SUCCESSFUL
Total time: 19 seconds</pre>
+
+This next example extracts the latest version of the files in the pvcs
+repository from two projects using nested <pvcsproject> elements.
+<ul> <!--
===================================================================
+-->
+<br> <!-- Get latest from myprj and
myprj2
+-->
+<br> <!--
===================================================================
+-->
+<br> <target name="getlatest2">
+<br> <pvcs
repository="/mnt/pvcs">
+<br>
<pvcsproject name="/myprj" />
+<br>
<pvcsproject name="/myprj2" />
+<br> </pvcs>
+<br> </target></ul>
+Now run:
+<p> ant getlatest2
+<p>This will cause the following output to appear:
+<pre> getlatest2:
+ [pvcs] PVCS Version Manager (VMGUI) v6.6.10 (Build
870) for Windows NT/80x86
+ [pvcs] Copyright 1985-2000 MERANT. All rights
reserved.
+ [pvcs] PVCS Version Manager (get) v6.6.10 (Build
870) for Windows NT/80x86
+ [pvcs] Copyright 1985-2000 MERANT. All rights
reserved.
+ [pvcs] c:\myws\myprj\main.java <-
C:\mypvcs\archives\myprj\main.java-arc
+ [pvcs] rev 1.1
+ [pvcs] c:\myws\myprj\apache\tool.java <-
C:\mypvcs\archives\myprj\apache\tool.java-arc
+ [pvcs] rev 1.5
+ [pvcs] c:\myws\myprj2\apache\tool2.java <-
C:\mypvcs\archives\myprj2\apache\tool2.java-arc
+ [pvcs] rev 1.2
+
+ BUILD SUCCESSFUL
+
+ Total time: 22 seconds</pre>
<pre>
</pre>
1.73 +1 -1
jakarta-ant/src/main/org/apache/tools/ant/taskdefs/defaults.properties
Index: defaults.properties
===================================================================
RCS file:
/home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/defaults.properties,v
retrieving revision 1.72
retrieving revision 1.73
diff -u -r1.72 -r1.73
--- defaults.properties 2001/04/27 11:52:54 1.72
+++ defaults.properties 2001/04/27 12:36:08 1.73
@@ -78,7 +78,7 @@
ilasm=org.apache.tools.ant.taskdefs.optional.dotnet.Ilasm
stylebook=org.apache.tools.ant.taskdefs.optional.StyleBook
test=org.apache.tools.ant.taskdefs.optional.Test
-pvcs=org.apache.tools.ant.taskdefs.optional.Pvcs
+pvcs=org.apache.tools.ant.taskdefs.optional.pvcs.Pvcs
p4change=org.apache.tools.ant.taskdefs.optional.perforce.P4Change
p4label=org.apache.tools.ant.taskdefs.optional.perforce.P4Label
p4have=org.apache.tools.ant.taskdefs.optional.perforce.P4Have
1.1
jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/pvcs/Pvcs.java
Index: Pvcs.java
===================================================================
/* ====================================================================
*
* 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/>.
*
* [Additional notices, if required by prior licensing conditions]
*
*/
package org.apache.tools.ant.taskdefs.optional.pvcs;
import java.io.*;
import java.util.Enumeration;
import java.util.Vector;
import java.text.*;
import java.util.Random;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.taskdefs.Execute;
import org.apache.tools.ant.taskdefs.LogOutputStream;
import org.apache.tools.ant.taskdefs.LogStreamHandler;
import org.apache.tools.ant.taskdefs.PumpStreamHandler;
import org.apache.tools.ant.taskdefs.ExecuteStreamHandler;
import org.apache.tools.ant.types.Commandline;
/**
* A task that fetches source files from a PVCS archive
*
* @author Thomas Christensen <[EMAIL PROTECTED]>
*/
public class Pvcs extends org.apache.tools.ant.Task {
private String pvcsbin;
private String repository;
private String pvcsProject;
private Vector pvcsProjects;
private String workspace;
private String force;
private String promotiongroup;
private String label;
private boolean ignorerc;
/**
* Constant for the thing to execute
*/
private static final String PCLI_EXE = "pcli";
/**
* Constant for the PCLI listversionedfiles recursive i a format "get"
understands
*/
private static final String PCLI_LVF_ARGS = "lvf -z -aw";
/**
* Constant for the thing to execute
*/
private static final String GET_EXE = "get";
protected int runCmd(Commandline cmd, ExecuteStreamHandler out) {
try {
Project aProj = getProject();
Execute exe = new Execute(out);
exe.setAntRun(aProj);
exe.setWorkingDirectory(aProj.getBaseDir());
exe.setCommandline(cmd.getCommandline());
return exe.execute();
}
catch (java.io.IOException e) {
String msg = "Failed executing: " + cmd.toString();
throw new BuildException(msg, location);
}
}
private String getExecutable(String exe) {
StringBuffer correctedExe = new StringBuffer();
if(getPvcsbin()!=null)
if(pvcsbin.endsWith(File.separator))
correctedExe.append(pvcsbin);
else
correctedExe.append(pvcsbin).append(File.separator);
return correctedExe.append(exe).toString();
}
/**
* @exception org.apache.tools.ant.BuildException Something is stopping
the build...
*/
public void execute() throws org.apache.tools.ant.BuildException {
Project aProj = getProject();
int result = 0;
if(repository == null || repository.trim().equals(""))
throw new BuildException("Required argument repository not
specified");
// Check workspace exists
// Launch PCLI listversionedfiles -z -aw
// Capture output
// build the command line from what we got the format is
Commandline commandLine = new Commandline();
commandLine.setExecutable(getExecutable(PCLI_EXE));
commandLine.createArgument().setValue("lvf");
commandLine.createArgument().setValue("-z");
commandLine.createArgument().setValue("-aw");
if(getWorkspace()!=null)
commandLine.createArgument().setValue("-sp"+getWorkspace());
commandLine.createArgument().setValue("-pr"+getRepository());
// default pvcs project is "/"
if(getPvcsproject() == null && getPvcsprojects().isEmpty())
pvcsProject = "/";
if(getPvcsproject()!=null)
commandLine.createArgument().setValue(getPvcsproject());
if(!getPvcsprojects().isEmpty()) {
Enumeration e = getPvcsprojects().elements();
while (e.hasMoreElements()) {
String projectName = ((PvcsProject)e.nextElement()).getName();
if (projectName == null || (projectName.trim()).equals(""))
throw new BuildException("name is a required attribute of
pvcsproject");
commandLine.createArgument().setValue(projectName);
}
}
File tmp = null;
try {
tmp = new File("pvcs_ant_"+(new
Random(System.currentTimeMillis())).nextLong()+".log");
result = runCmd(commandLine, new PumpStreamHandler(new
FileOutputStream(tmp), new LogOutputStream(this,Project.MSG_WARN)));
if ( result != 0 && !ignorerc) {
String msg = "Failed executing: " + commandLine.toString();
throw new BuildException(msg, location);
}
if(!tmp.exists())
throw new BuildException("Communication between ant and pvcs
failed");
// Create foldes in workspace
createFolders(tmp);
// Launch get on output captured from PCLI lvf
commandLine.clearArgs();
commandLine.setExecutable(getExecutable(GET_EXE));
if(getForce()!=null && getForce().equals("yes"))
commandLine.createArgument().setValue("-Y");
else
commandLine.createArgument().setValue("-N");
if(getPromotiongroup()!=null)
commandLine.createArgument().setValue("-G"+getPromotiongroup());
else {
if(getLabel()!=null)
commandLine.createArgument().setValue("-r"+getLabel());
}
commandLine.createArgument().setValue("@"+tmp.getAbsolutePath());
result = runCmd(commandLine, new
LogStreamHandler(this,Project.MSG_INFO, Project.MSG_WARN));
if ( result != 0 && !ignorerc) {
String msg = "Failed executing: " + commandLine.toString();
throw new BuildException(msg, location);
}
} catch(FileNotFoundException e) {
String msg = "Failed executing: " + commandLine.toString();
throw new BuildException(e.getMessage(),location);
} catch(IOException e) {
String msg = "Failed executing: " + commandLine.toString();
throw new BuildException(e.getMessage(),location);
} catch(ParseException e) {
String msg = "Failed executing: " + commandLine.toString();
throw new BuildException(e.getMessage(),location);
} finally {
if (tmp != null) {
tmp.delete();
}
}
}
/**
* Parses the file and creates the folders specified in the output section
*/
private void createFolders(File file) throws IOException, ParseException {
BufferedReader in = new BufferedReader(new FileReader(file));
MessageFormat mf = new MessageFormat("{0}({1})");
String line = in.readLine();
while(line != null) {
if(line.startsWith("\"")) {
Object[] objs = mf.parse(line);
String f = (String)objs[1];
// Extract the name of the directory from the filename
File dir = new
File(f.substring(0,f.lastIndexOf(File.separator)));
if(!dir.exists())
dir.mkdirs();
}
line = in.readLine();
}
}
/**
* Get network name of the PVCS repository
* @return String
*/
public String getRepository() {
return repository;
}
/**
* Specifies the network name of the PVCS repository
* @param repo String
*/
public void setRepository(String repo) {
repository = repo;
}
/**
* Get name of the project in the PVCS repository
* @return String
*/
public String getPvcsproject() {
return pvcsProject;
}
/**
* Specifies the name of the project in the PVCS repository
* @param prj String
*/
public void setPvcsproject(String prj) {
pvcsProject = prj;
}
/**
* Get name of the project in the PVCS repository
* @return Vector
*/
public Vector getPvcsprojects() {
return pvcsProjects;
}
/**
* Get name of the workspace to store the retrieved files
* @return String
*/
public String getWorkspace() {
return workspace;
}
/**
* Specifies the name of the workspace to store retrieved files
* @param ws String
*/
public void setWorkspace(String ws) {
workspace = ws;
}
/**
* Get name of the PVCS bin directory
* @return String
*/
public String getPvcsbin() {
return pvcsbin;
}
/**
* Specifies the location of the PVCS bin directory
* @param ws String
*/
public void setPvcsbin(String bin) {
pvcsbin = bin;
}
/**
* Get value of force
* @return String
*/
public String getForce() {
return force;
}
/**
* Specifies the value of the force argument
* @param repo String (yes/no)
*/
public void setForce(String f) {
if(f!=null && f.equalsIgnoreCase("yes"))
force="yes";
else
force = "no";
}
/**
* Get value of promotiongroup
* @return String
*/
public String getPromotiongroup() {
return promotiongroup;
}
/**
* Specifies the name of the promotiongroup argument
* @param repo String
*/
public void setPromotiongroup(String w) {
promotiongroup=w;
}
/**
* Get value of label
* @return String
*/
public String getLabel() {
return label;
}
/**
* Specifies the name of the label argument
* @param repo String
*/
public void setLabel(String l) {
label=l;
}
/**
* Get value of ignorereturncode
* @return String
*/
public String getIgnoreReturnCode() {
if(ignorerc)
return "true";
else
return "false";
}
/**
* If set to true the return value from executing the pvcs
* commands are ignored.
* @param l String "true/false"
*/
public void setIgnoreReturnCode(String l) {
if(l.trim().equalsIgnoreCase("true"))
ignorerc=true;
else
ignorerc=false;
}
/**
* handles <pvcsproject> subelements
* @param PvcsProject
*/
public void addPvcsproject(PvcsProject p) {
pvcsProjects.addElement(p);
}
/**
* Creates a Pvcs object
*/
public Pvcs() {
super();
pvcsProject = null;
pvcsProjects = new Vector();
workspace = null;
repository = null;
pvcsbin = null;
force=null;
promotiongroup=null;
label=null;
ignorerc=false;
}
}
1.1
jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/pvcs/PvcsProject.java
Index: PvcsProject.java
===================================================================
/* ====================================================================
*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 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.taskdefs.optional.pvcs;
import org.apache.tools.ant.Project;
/**
* class to handle <pvcsprojec> elements
*/
public class PvcsProject {
private String name;
public PvcsProject() {
super();
}
public void setName(String name) {
PvcsProject.this.name = name;
}
public String getName() {
return name;
}
}