From 68323a96a352fa60237a1007e0b453785f49fb06 Mon Sep 17 00:00:00 2001 From: Stefan Bodewig Date: Fri, 27 Jul 2001 09:14:58 +0000 Subject: [PATCH] New suite of tasks of Continuus. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Submitted by: Beno�t Moussaud Note that I don't use Continuus, so this patch has not been tested for functionality (it compiles and looks OK, that's all I can check). Note 2: I'm not sure whether my assumption =CCMCheckin =ccm.CCMCheckinDefault is correct. git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@269399 13f79535-47bb-0310-9956-ffa450edef68 --- WHATSNEW | 2 +- docs/manual/OptionalTasks/ccm.html | 235 +++++++++++ docs/manual/optionaltasklist.html | 1 + .../tools/ant/taskdefs/defaults.properties | 5 + .../ant/taskdefs/optional/ccm/CCMCheck.java | 184 +++++++++ .../ant/taskdefs/optional/ccm/CCMCheckin.java | 72 ++++ .../optional/ccm/CCMCheckinDefault.java | 71 ++++ .../taskdefs/optional/ccm/CCMCheckout.java | 68 ++++ .../taskdefs/optional/ccm/CCMCreateTask.java | 366 ++++++++++++++++++ .../taskdefs/optional/ccm/CCMReconfigure.java | 202 ++++++++++ .../ant/taskdefs/optional/ccm/Continuus.java | 167 ++++++++ 11 files changed, 1372 insertions(+), 1 deletion(-) create mode 100644 docs/manual/OptionalTasks/ccm.html create mode 100644 src/main/org/apache/tools/ant/taskdefs/optional/ccm/CCMCheck.java create mode 100644 src/main/org/apache/tools/ant/taskdefs/optional/ccm/CCMCheckin.java create mode 100644 src/main/org/apache/tools/ant/taskdefs/optional/ccm/CCMCheckinDefault.java create mode 100644 src/main/org/apache/tools/ant/taskdefs/optional/ccm/CCMCheckout.java create mode 100644 src/main/org/apache/tools/ant/taskdefs/optional/ccm/CCMCreateTask.java create mode 100644 src/main/org/apache/tools/ant/taskdefs/optional/ccm/CCMReconfigure.java create mode 100644 src/main/org/apache/tools/ant/taskdefs/optional/ccm/Continuus.java diff --git a/WHATSNEW b/WHATSNEW index 1992b61be..622073e6c 100644 --- a/WHATSNEW +++ b/WHATSNEW @@ -39,7 +39,7 @@ Other changes: -------------- * New tasks: ear, p4counter, record, cvspass, vsscheckin, vsscheckout, - typedef, sleep, mimemail + typedef, sleep, mimemail, set of tasks for Continuus/Synergy * Ant now uses JAXP 1.1 diff --git a/docs/manual/OptionalTasks/ccm.html b/docs/manual/OptionalTasks/ccm.html new file mode 100644 index 000000000..1425c1940 --- /dev/null +++ b/docs/manual/OptionalTasks/ccm.html @@ -0,0 +1,235 @@ + + + + +Ant + + + + +

Continuus Support

+ + +

These ant tasks are wrapper around Continnus Source Manager. It have been tested + under version 5.1 on Windows 2000.

+
+

CCMCheckin

+

Description

+Task to perform a Checkin command to Continnus +

Parameters

+ + + + + + + + + + + + + + + + + + + + + + + + + + +
AttributeValuesRequired
filePath to the file that the command will operate onYes
commentSpecify a comment.No
taskSpecify the task number used to checkin the file (may use 'default')No
ccmcommandpath to the ccm excutable file. default serach into the PATHNo
+

Examples

+
+
<ccmcheckin file="c:/wa/com/foo/MyFile.java"
+        comment="mycomment" />
+
+
+

Does a Continnuus checkin on the file c:/wa/com/foo/MyFile.java. + Comment attribute mycomment is added as a task comment. The task + used is the one set as the fault.

+
+

CCMCheckout

+

Description

+Task to perform a Checkout command to Continuus +

Parameters

+ + + + + + + + + + + + + + + + + + + + + + + + + + +
AttributeValuesRequired
filePath to the file that the command will operate onYes
commentSpecify a comment.No
taskSpecify the task number used to checkin the file (may use + 'default')No
ccmcommandpath to the ccm excutable file. default serach into the PATHNo
+

Examples

+
+
<ccmcheckin file="c:/wa/com/foo/MyFile.java"
+        comment="mycomment"/>
+
+
+

Does a Continnuus checkout on the file c:/wa/com/foo/MyFile.java. + Comment attribute mycomment is added as a task comment + The used task is the one set as the fault.

+
+

CCMCheckinTask

+

Description

+Task to perform a check in default task command to Continnuus +

Parameters

+ + + + + + + + + + + + + + + + + + + + + +
AttributeValuesRequired
commentSpecify a comment.No
taskSpecify the task number used to checkin the file (may use 'default')No
ccmcommandpath to the ccm excutable file. default serach into the PATHNo
+

Examples

+
+
<ccmcheckintask comment="blahblah/>
+
+
+

Does a Checkin default task on all the checkou-ed filed in the current task.

+
+

CCMReconfigure

+

Description

+Task to perform an reconfigure command to Continuus. +

Parameters

+ + + + + + + + + + + + + + + + + + + + + + + + + + +
AttributeValuesRequired
recurserecurse on subproject (default false)No
verbosedo a verbose reconfigure operation (default false)No
ccmprojectSpecifies the ccm project on which the operation is applied.Yes
ccmcommandpath to the ccm excutable file. default serach into the PATHNo
+

Examples

+
+
<ccmreconfigure ccmproject="ANTCCM_TEST#BMO_1" verbose="true" />
+
+
+
+

Does a Continuus reconfiguree on the project ANTCCM_TEST#BMO_1. +

+
+

CCMCreateTask

+

Description

+Task to perform an create task command to Continuus. +

Parameters

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
AttributeValuesRequired
commentSpecify a comment.No
platformSpecify the target platformNo
ccmcommandpath to the ccm excutable file. default serach into the PATHNo
resolverSpecify the resolverNo
releaseSpecify the CCM releaseNo
subsystemSpecify the subsystemNo
taskSpecify the task number used to checkin the file (may use 'default')No
+

Examples

+
+
<ccmcreatetask resolver="{user.name}" release="ANTCCM_TEST" comment="blahblah" />
+
+
+

Does a Continuus create task for the release ANTCCM_TEST to the + current logged person as the resolver for this task.

+

 

+ + + + diff --git a/docs/manual/optionaltasklist.html b/docs/manual/optionaltasklist.html index eeef161e2..fdc854233 100644 --- a/docs/manual/optionaltasklist.html +++ b/docs/manual/optionaltasklist.html @@ -15,6 +15,7 @@ ANTLR
Cab
Clearcase Tasks
+Continuus/Synergy Tasks
Depend
EJB Tasks
FTP
diff --git a/src/main/org/apache/tools/ant/taskdefs/defaults.properties b/src/main/org/apache/tools/ant/taskdefs/defaults.properties index 979219625..25aee4da6 100644 --- a/src/main/org/apache/tools/ant/taskdefs/defaults.properties +++ b/src/main/org/apache/tools/ant/taskdefs/defaults.properties @@ -109,6 +109,11 @@ vsscheckout=org.apache.tools.ant.taskdefs.optional.vss.MSVSSCHECKOUT iplanet-ejbc=org.apache.tools.ant.taskdefs.optional.ejb.IPlanetEjbcTask jdepend=org.apache.tools.ant.taskdefs.optional.jdepend.JDependTask mimemail=org.apache.tools.ant.taskdefs.optional.net.MimeMail +cccheckin=org.apache.tools.ant.taskdefs.optional.ccm.CCMCheckin +cccheckout=org.apache.tools.ant.taskdefs.optional.ccm.CCMCheckout +ccmcheckintask=org.apache.tools.ant.taskdefs.optional.ccm.CCMCheckinDefault +ccmreconfigure=org.apache.tools.ant.taskdefs.optional.ccm.CCMReconfigure +ccmcreatetask=org.apache.tools.ant.taskdefs.optional.ccm.CCMCreateTask # deprecated ant tasks (kept for back compatibility) javadoc2=org.apache.tools.ant.taskdefs.Javadoc diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/ccm/CCMCheck.java b/src/main/org/apache/tools/ant/taskdefs/optional/ccm/CCMCheck.java new file mode 100644 index 000000000..f233faaac --- /dev/null +++ b/src/main/org/apache/tools/ant/taskdefs/optional/ccm/CCMCheck.java @@ -0,0 +1,184 @@ +/* + * 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", "Ant", 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.ccm; + +import org.apache.tools.ant.*; +import org.apache.tools.ant.types.Commandline; +import org.apache.tools.ant.types.Path; + +import java.io.File; + +/** + * Class common to all check commands (checkout, checkin,checkin default task); + * @author Benoit Moussaud benoit.moussaud@criltelecom.com + */ +public class CCMCheck extends Continuus { + + private File _file = null; + private String _comment = null; + private String _task = null; + + public CCMCheck() { + super(); + } + + /** + * Get the value of file. + * @return value of file. + */ + public File getFile() { + return _file; + } + + /** + * Set the value of file. + * @param v Value to assign to file. + */ + public void setFile(File v) { + this._file = v; + } + + /** + * Get the value of comment. + * @return value of comment. + */ + public String getComment() { + return _comment; + } + + /** + * Set the value of comment. + * @param v Value to assign to comment. + */ + public void setComment(String v) { + this._comment = v; + } + + + /** + * Get the value of task. + * @return value of task. + */ + public String getTask() { + return _task; + } + + /** + * Set the value of task. + * @param v Value to assign to task. + */ + public void setTask(String v) { + this._task = v; + } + + + /** + * Executes the task. + *

+ * Builds a command line to execute ccm and then calls Exec's run method + * to execute the command line. + *

+ */ + public void execute() throws BuildException { + Commandline commandLine = new Commandline(); + Project aProj = getProject(); + int result = 0; + + // build the command line from what we got the format is + // ccm co /t .. files + // as specified in the CLEARTOOL.EXE help + commandLine.setExecutable(getCcmCommand()); + commandLine.createArgument().setValue(getCcmAction()); + + checkOptions(commandLine); + + result = run(commandLine); + if ( result != 0 ) { + String msg = "Failed executing: " + commandLine.toString(); + throw new BuildException(msg, location); + } + } + + + /** + * Check the command line options. + */ + private void checkOptions(Commandline cmd) { + if (getComment() != null) { + cmd.createArgument().setValue(FLAG_COMMENT); + cmd.createArgument().setValue(getComment()); + } + + if ( getTask() != null) { + cmd.createArgument().setValue(FLAG_TASK); + cmd.createArgument().setValue(getTask()); + } // end of if () + + if ( getFile() != null ) { + cmd.createArgument().setValue(_file.getAbsolutePath()); + } // end of if () + } + + /** + * -comment flag -- comment to attach to the file + */ + public static final String FLAG_COMMENT = "/comment"; + + /** + * -task flag -- associate checckout task with task + */ + public static final String FLAG_TASK = "/task"; +} + diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/ccm/CCMCheckin.java b/src/main/org/apache/tools/ant/taskdefs/optional/ccm/CCMCheckin.java new file mode 100644 index 000000000..8d9c4dd48 --- /dev/null +++ b/src/main/org/apache/tools/ant/taskdefs/optional/ccm/CCMCheckin.java @@ -0,0 +1,72 @@ +/* + * 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", "Ant", 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.ccm; + +import java.util.Date; + +/** + * Task to perform Checkin command to Continuus + * @author Benoit Moussaud benoit.moussaud@criltelecom.com + */ +public class CCMCheckin extends CCMCheck { + + public CCMCheckin() { + super(); + setCcmAction(COMMAND_CHECKIN); + setComment("Checkin "+ new Date()); + } + +} + diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/ccm/CCMCheckinDefault.java b/src/main/org/apache/tools/ant/taskdefs/optional/ccm/CCMCheckinDefault.java new file mode 100644 index 000000000..13b9b99cf --- /dev/null +++ b/src/main/org/apache/tools/ant/taskdefs/optional/ccm/CCMCheckinDefault.java @@ -0,0 +1,71 @@ +/* + * 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", "Ant", 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.ccm; + +/** + * Task to perform Checkin Default task command to Continuus + * @author Benoit Moussaud benoit.moussaud@criltelecom.com + */ +public class CCMCheckinDefault extends CCMCheck { + + public CCMCheckinDefault(){ + super(); + setCcmAction(COMMAND_CHECKIN); + setTask(DEFAULT_TASK); + } + + public static final String DEFAULT_TASK = "default"; +} + diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/ccm/CCMCheckout.java b/src/main/org/apache/tools/ant/taskdefs/optional/ccm/CCMCheckout.java new file mode 100644 index 000000000..2c354655c --- /dev/null +++ b/src/main/org/apache/tools/ant/taskdefs/optional/ccm/CCMCheckout.java @@ -0,0 +1,68 @@ +/* + * 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", "Ant", 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.ccm; + +/** + * Task to perform Checkout command to Continuus + * @author Benoit Moussaud benoit.moussaud@criltelecom.com + */ +public class CCMCheckout extends CCMCheck { + + public CCMCheckout(){ + super(); + setCcmAction(COMMAND_CHECKOUT); + } +} + diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/ccm/CCMCreateTask.java b/src/main/org/apache/tools/ant/taskdefs/optional/ccm/CCMCreateTask.java new file mode 100644 index 000000000..809ef4bfb --- /dev/null +++ b/src/main/org/apache/tools/ant/taskdefs/optional/ccm/CCMCreateTask.java @@ -0,0 +1,366 @@ +/* + * 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", "Ant", 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.ccm; + + +import java.io.BufferedReader; +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.OutputStream; +import java.lang.NullPointerException; +import org.apache.tools.ant.*; +import org.apache.tools.ant.taskdefs.ExecuteStreamHandler; +import org.apache.tools.ant.types.Commandline; +import org.apache.tools.ant.types.Path; + +/** + * Task allows to create new ccm task and set it as the default + * @author Benoit Moussaud benoit.moussaud@criltelecom.com + */ +public class CCMCreateTask extends Continuus implements ExecuteStreamHandler { + + private String comment = null; + private String platform = null; + private String resolver = null; + private String release = null; + private String subSystem = null; + private String task = null; + + public CCMCreateTask() { + super(); + setCcmAction(COMMAND_CREATE_TASK); + } + + + /** + * Executes the task. + *

+ * Builds a command line to execute ccm and then calls Exec's run method + * to execute the command line. + *

+ */ + public void execute() throws BuildException { + Commandline commandLine = new Commandline(); + Project aProj = getProject(); + int result = 0; + + // build the command line from what we got the format + // as specified in the CCM.EXE help + commandLine.setExecutable(getCcmCommand()); + commandLine.createArgument().setValue(getCcmAction()); + + checkOptions(commandLine); + + result = run(commandLine,this); + if ( result != 0 ) { + String msg = "Failed executing: " + commandLine.toString(); + throw new BuildException(msg, location); + } + + //create task ok, set this task as the default one + Commandline commandLine2 = new Commandline(); + commandLine2.setExecutable(getCcmCommand()); + commandLine2.createArgument().setValue(COMMAND_DEFAULT_TASK); + commandLine2.createArgument().setValue(getTask()); + + log(commandLine.toString(),Project.MSG_DEBUG); + + result = run(commandLine2); + if ( result != 0 ) { + String msg = "Failed executing: " + commandLine2.toString(); + throw new BuildException(msg, location); + } + + } + + + /** + * Check the command line options. + */ + private void checkOptions(Commandline cmd) { + if (getComment() != null) { + cmd.createArgument().setValue(FLAG_COMMENT); + cmd.createArgument().setValue("\""+getComment()+"\""); + } + + if ( getPlatform() != null) { + cmd.createArgument().setValue(FLAG_PLATFORM); + cmd.createArgument().setValue(getPlatform()); + } // end of if () + + if ( getResolver() != null) { + cmd.createArgument().setValue(FLAG_RESOLVER); + cmd.createArgument().setValue(getResolver()); + } // end of if () + + if ( getSubSystem() != null) { + cmd.createArgument().setValue(FLAG_SUBSYSTEM); + cmd.createArgument().setValue("\""+getSubSystem()+"\""); + } // end of if () + + if ( getRelease() != null ) { + cmd.createArgument().setValue(FLAG_RELEASE); + cmd.createArgument().setValue(getRelease()); + } // end of if () + } + + + /** + * Get the value of comment. + * @return value of comment. + */ + public String getComment() { + return comment; + } + + /** + * Set the value of comment. + * @param v Value to assign to comment. + */ + public void setComment(String v) { + this.comment = v; + } + + + /** + * Get the value of platform. + * @return value of platform. + */ + public String getPlatform() { + return platform; + } + + /** + * Set the value of platform. + * @param v Value to assign to platform. + */ + public void setPlatform(String v) { + this.platform = v; + } + + + /** + * Get the value of resolver. + * @return value of resolver. + */ + public String getResolver() { + return resolver; + } + + /** + * Set the value of resolver. + * @param v Value to assign to resolver. + */ + public void setResolver(String v) { + this.resolver = v; + } + + + /** + * Get the value of release. + * @return value of release. + */ + public String getRelease() { + return release; + } + + /** + * Set the value of release. + * @param v Value to assign to release. + */ + public void setRelease(String v) { + this.release = v; + } + + /** + * Get the value of subSystem. + * @return value of subSystem. + */ + public String getSubSystem() { + return subSystem; + } + + /** + * Set the value of subSystem. + * @param v Value to assign to subSystem. + */ + public void setSubSystem(String v) { + this.subSystem = v; + } + + + /** + * Get the value of task. + * @return value of task. + */ + public String getTask() { + return task; + } + + /** + * Set the value of task. + * @param v Value to assign to task. + */ + public void setTask(String v) { + this.task = v; + } + + /** + * /comment -- comments associated to the task + */ + public static final String FLAG_COMMENT = "/synopsis"; + + /** + * /platform flag -- target platform + */ + public static final String FLAG_PLATFORM = "/plat"; + + /** + * /resolver flag + */ + public static final String FLAG_RESOLVER = "/resolver"; + + /** + * /release flag + */ + public static final String FLAG_RELEASE = "/release"; + + /** + * /release flag + */ + public static final String FLAG_SUBSYSTEM = "/subsystem"; + + /** + * -task flag -- associate checckout task with task + */ + public static final String FLAG_TASK = "/task"; + + + // implementation of org.apache.tools.ant.taskdefs.ExecuteStreamHandler interface + + /** + * + * @exception java.io.IOException + */ + public void start() throws IOException { + } + + /** + * + */ + public void stop(){ + } + + /** + * + * @param param1 + * @exception java.io.IOException + */ + public void setProcessInputStream(OutputStream param1) throws IOException { + } + + /** + * + * @param param1 + * @exception java.io.IOException + */ + public void setProcessErrorStream(InputStream is) throws IOException { + BufferedReader reader = new BufferedReader(new InputStreamReader(is)); + String s = reader.readLine(); + if ( s != null) + { + log("err "+s,Project.MSG_DEBUG); + } // end of if () + } + + /** + * read the output stream to retrieve the new task number. + * @param is InputStream + * @exception java.io.IOException + */ + public void setProcessOutputStream(InputStream is) throws IOException { + + String buffer = ""; + try + { + BufferedReader reader = new BufferedReader(new InputStreamReader(is)); + buffer = reader.readLine(); + if ( buffer != null) + { + log("buffer:" +buffer,Project.MSG_DEBUG); + String taskstring = buffer.substring(buffer.indexOf(' ')).trim(); + taskstring = taskstring.substring(0,taskstring.lastIndexOf(' ')).trim(); + setTask(taskstring); + log("task is "+getTask(),Project.MSG_DEBUG); + } // end of if () + } + catch ( NullPointerException npe) + { + log("error procession stream , null pointer exception",Project.MSG_ERR); + npe.printStackTrace(); + throw new BuildException(npe.getClass().getName()); + } // end of catch + catch (Exception e) + { + log("error procession stream "+e.getMessage(),Project.MSG_ERR); + throw new BuildException(e.getMessage()); + } // end of try-catch + + } + +} + diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/ccm/CCMReconfigure.java b/src/main/org/apache/tools/ant/taskdefs/optional/ccm/CCMReconfigure.java new file mode 100644 index 000000000..a8867046d --- /dev/null +++ b/src/main/org/apache/tools/ant/taskdefs/optional/ccm/CCMReconfigure.java @@ -0,0 +1,202 @@ +/* + * 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", "Ant", 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.ccm; + + +import java.io.BufferedReader; +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.OutputStream; +import org.apache.tools.ant.*; +import org.apache.tools.ant.types.Commandline; +import org.apache.tools.ant.types.Path; + +/** + * Task allows to reconfigure a project, recurcively or not + * @author Benoit Moussaud benoit.moussaud@criltelecom.com + */ +public class CCMReconfigure extends Continuus { + + private String project = null; + private boolean recurse = false; + private boolean verbose = false; + + public CCMReconfigure() { + super(); + setCcmAction(COMMAND_RECONFIGURE); + } + + + /** + * Executes the task. + *

+ * Builds a command line to execute ccm and then calls Exec's run method + * to execute the command line. + *

+ */ + public void execute() throws BuildException { + Commandline commandLine = new Commandline(); + Project aProj = getProject(); + int result = 0; + + // build the command line from what we got the format + // as specified in the CCM.EXE help + commandLine.setExecutable(getCcmCommand()); + commandLine.createArgument().setValue(getCcmAction()); + + checkOptions(commandLine); + + result = run(commandLine); + if ( result != 0 ) { + String msg = "Failed executing: " + commandLine.toString(); + throw new BuildException(msg, location); + } + } + + + /** + * Check the command line options. + */ + private void checkOptions(Commandline cmd) { + + if ( isRecurse() == true) { + cmd.createArgument().setValue(FLAG_RECURSE); + } // end of if () + + if ( isVerbose() == true) { + cmd.createArgument().setValue(FLAG_VERBOSE); + } // end of if () + + if (getCcmProject() != null) { + cmd.createArgument().setValue(FLAG_PROJECT); + cmd.createArgument().setValue(getCcmProject()); + } + + } + + /** + * Get the value of project. + * @return value of project. + */ + public String getCcmProject() { + return project; + } + + /** + * Set the value of project. + * @param v Value to assign to project. + */ + public void setCcmProject(String v) { + this.project = v; + } + + + /** + * Get the value of recurse. + * @return value of recurse. + */ + public boolean isRecurse() { + return recurse; + } + + /** + * Set the value of recurse. + * @param v Value to assign to recurse. + */ + public void setRecurse(boolean v) { + this.recurse = v; + } + + + + /** + * Get the value of verbose. + * @return value of verbose. + */ + public boolean isVerbose() + { + return verbose; + } + + /** + * Set the value of verbose. + * @param v Value to assign to verbose. + */ + public void setVerbose(boolean v) + { + this.verbose = v; + } + + + /** + * /recurse -- + */ + public static final String FLAG_RECURSE = "/recurse"; + + /** + * /recurse -- + */ + public static final String FLAG_VERBOSE = "/verbose"; + + + /** + * /project flag -- target project + */ + public static final String FLAG_PROJECT = "/project"; + +} + diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/ccm/Continuus.java b/src/main/org/apache/tools/ant/taskdefs/optional/ccm/Continuus.java new file mode 100644 index 000000000..e73749b06 --- /dev/null +++ b/src/main/org/apache/tools/ant/taskdefs/optional/ccm/Continuus.java @@ -0,0 +1,167 @@ +/* + * 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", "Ant", 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.ccm; + +import org.apache.tools.ant.*; +import org.apache.tools.ant.taskdefs.Execute; +import org.apache.tools.ant.taskdefs.LogStreamHandler; +import org.apache.tools.ant.taskdefs.ExecuteStreamHandler; +import org.apache.tools.ant.types.Commandline; + +import java.io.File; + +/** + * A base class for creating tasks for executing commands on Continuus 5.1 + *

+ * The class extends the task as it operates by executing the ccm.exe program + * supplied with Continuus/Synergy. By default the task expects the ccm executable to be + * in the path, + * you can override this be specifying the ccmdir attribute. + *

+ * + * @author Benoit Moussaud benoit.moussaud@criltelecom.com + */ +public abstract class Continuus extends Task { + + private String _ccmDir = ""; + private String _ccmAction = ""; + + /** + * Get the value of ccmAction. + * @return value of ccmAction. + */ + public String getCcmAction() { + return _ccmAction; + } + + /** + * Set the value of ccmAction. + * @param v Value to assign to ccmAction. + */ + public void setCcmAction(String v) { + this._ccmAction = v; + } + + + /** + * Set the directory where the ccm executable is located + * @param dir the directory containing the ccm executable + */ + public final void setCcmDir(String dir) { + _ccmDir = project.translatePath(dir); + } + + /** + * Builds and returns the command string to execute ccm + * @return String containing path to the executable + */ + protected final String getCcmCommand() { + String toReturn = _ccmDir; + if ( !toReturn.equals("") && !toReturn.endsWith("/") ) { + toReturn += "/"; + } + + toReturn += CCM_EXE; + + return toReturn; + } + + + protected int run(Commandline cmd, ExecuteStreamHandler handler) { + try { + Execute exe = new Execute(handler); + exe.setAntRun(getProject()); + exe.setWorkingDirectory(getProject().getBaseDir()); + exe.setCommandline(cmd.getCommandline()); + return exe.execute(); + } + catch (java.io.IOException e) { + throw new BuildException(e, location); + } + } + + protected int run(Commandline cmd) { + return run(cmd,new LogStreamHandler(this, Project.MSG_VERBOSE, Project.MSG_WARN)); + } + + /** + * Constant for the thing to execute + */ + private static final String CCM_EXE = "ccm"; + + /** + * The 'CreateTask' command + */ + public static final String COMMAND_CREATE_TASK = "create_task"; + /** + * The 'Checkout' command + */ + public static final String COMMAND_CHECKOUT = "co"; + /** + * The 'Checkin' command + */ + public static final String COMMAND_CHECKIN = "ci"; + /** + * The 'Reconfigure' command + */ + public static final String COMMAND_RECONFIGURE = "reconfigure"; + + /** + * The 'Reconfigure' command + */ + public static final String COMMAND_DEFAULT_TASK = "default_task"; + + +}