From 3957ddae25e17df961a51621ddc57625a4476878 Mon Sep 17 00:00:00 2001 From: Stefan Bodewig Date: Fri, 27 Apr 2001 12:36:12 +0000 Subject: [PATCH] Moved to a package of its own, added nested element to it to handle multiple projects in one go. Submitted by: Frank Wierzbicki git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@268981 13f79535-47bb-0310-9956-ffa450edef68 --- WHATSNEW | 6 +- docs/manual/OptionalTasks/pvcstask.html | 65 +++++++++++++++- .../tools/ant/taskdefs/defaults.properties | 2 +- .../taskdefs/optional/{ => pvcs}/Pvcs.java | 43 +++++++++-- .../taskdefs/optional/pvcs/PvcsProject.java | 77 +++++++++++++++++++ 5 files changed, 184 insertions(+), 9 deletions(-) rename src/main/org/apache/tools/ant/taskdefs/optional/{ => pvcs}/Pvcs.java (90%) create mode 100644 src/main/org/apache/tools/ant/taskdefs/optional/pvcs/PvcsProject.java diff --git a/WHATSNEW b/WHATSNEW index f6fe64fa0..41166d5f1 100644 --- a/WHATSNEW +++ b/WHATSNEW @@ -13,10 +13,12 @@ Changes that could break older environments: * several Zip methods have changed their signature as we now use a Zip package of our own that handles Unix permissions for directories. +* The 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 @@ -42,6 +44,8 @@ Other changes: * now has a nested element following the same idea as 's . +* can now handle multiple projects. + Fixed bugs: ----------- diff --git a/docs/manual/OptionalTasks/pvcstask.html b/docs/manual/OptionalTasks/pvcstask.html index 4a60f4f07..fc29f8312 100644 --- a/docs/manual/OptionalTasks/pvcstask.html +++ b/docs/manual/OptionalTasks/pvcstask.html @@ -3,7 +3,6 @@ - PVCS task @@ -132,6 +131,35 @@ tag expects the executables to be found using the PATH environment variable.No +

Nested Elements

+ +

pvcsproject element

+

pvcs supports a nested +<pvcsproject> element, that represents a project +within the PVCS repository to extract files from. By nesting multiple +<pvcsproject> elements under the +<pvcs> task, multiple projects can be +specified.

+ +

Parameters

+ + + + + + + + + + + + + + + + + +
AttributeDescriptionRequired
nameThe name of the pvcs projectYes

Examples

@@ -143,7 +171,7 @@ repository. -->
    <!-- =================================================================== --> -
    <target name="getlastes"> +
    <target name="getlatest">
        < pvcs repository="/mnt/pvcs" pvcsproject="/myprj"/>
    </target> @@ -164,6 +192,39 @@ Now run:     Total time: 19 seconds +This next example extracts the latest version of the files in the pvcs +repository from two projects using nested <pvcsproject> elements. +
        <!-- =================================================================== +--> +
        <!-- Get latest from myprj and myprj2                                                                                                      +--> +
        <!-- =================================================================== +--> +
        <target name="getlatest2"> +
            <pvcs repository="/mnt/pvcs"> +
               <pvcsproject name="/myprj" /> +
               <pvcsproject name="/myprj2" /> +
            </pvcs> +
        </target>
+Now run: +

        ant getlatest2 +

This will cause the following output to appear: +

    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
+
 
diff --git a/src/main/org/apache/tools/ant/taskdefs/defaults.properties b/src/main/org/apache/tools/ant/taskdefs/defaults.properties index ea8831e16..deea22fbd 100644 --- a/src/main/org/apache/tools/ant/taskdefs/defaults.properties +++ b/src/main/org/apache/tools/ant/taskdefs/defaults.properties @@ -78,7 +78,7 @@ csc=org.apache.tools.ant.taskdefs.optional.dotnet.CSharp 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 diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/Pvcs.java b/src/main/org/apache/tools/ant/taskdefs/optional/pvcs/Pvcs.java similarity index 90% rename from src/main/org/apache/tools/ant/taskdefs/optional/Pvcs.java rename to src/main/org/apache/tools/ant/taskdefs/optional/pvcs/Pvcs.java index 8fc8f7a28..c88f73cf5 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/Pvcs.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/pvcs/Pvcs.java @@ -55,9 +55,11 @@ * [Additional notices, if required by prior licensing conditions] * */ -package org.apache.tools.ant.taskdefs.optional; +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; @@ -78,6 +80,7 @@ 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; @@ -148,8 +151,22 @@ public class Pvcs extends org.apache.tools.ant.Task { 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 { @@ -163,10 +180,10 @@ public class Pvcs extends org.apache.tools.ant.Task { if(!tmp.exists()) throw new BuildException("Communication between ant and pvcs failed"); - // Create foldes in workspace + // Create foldes in workspace createFolders(tmp); - // Launch get on output captured from PCLI lvf + // Launch get on output captured from PCLI lvf commandLine.clearArgs(); commandLine.setExecutable(getExecutable(GET_EXE)); @@ -256,6 +273,14 @@ public class Pvcs extends org.apache.tools.ant.Task { 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 @@ -362,13 +387,21 @@ public class Pvcs extends org.apache.tools.ant.Task { ignorerc=false; } + /** + * handles <pvcsproject> subelements + * @param PvcsProject + */ + public void addPvcsproject(PvcsProject p) { + pvcsProjects.addElement(p); + } + /** * Creates a Pvcs object - * Default PVCS project is "/" */ public Pvcs() { super(); - pvcsProject = "/"; + pvcsProject = null; + pvcsProjects = new Vector(); workspace = null; repository = null; pvcsbin = null; diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/pvcs/PvcsProject.java b/src/main/org/apache/tools/ant/taskdefs/optional/pvcs/PvcsProject.java new file mode 100644 index 000000000..aceb5b8cb --- /dev/null +++ b/src/main/org/apache/tools/ant/taskdefs/optional/pvcs/PvcsProject.java @@ -0,0 +1,77 @@ +/* ==================================================================== + * + * 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 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 + * . + * + */ + +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; + } +}