KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > tools > ant > taskdefs > optional > ccm > Continuus


1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  */

18
19 package org.apache.tools.ant.taskdefs.optional.ccm;
20
21 import org.apache.tools.ant.BuildException;
22 import org.apache.tools.ant.Project;
23 import org.apache.tools.ant.Task;
24 import org.apache.tools.ant.taskdefs.Execute;
25 import org.apache.tools.ant.taskdefs.ExecuteStreamHandler;
26 import org.apache.tools.ant.taskdefs.LogStreamHandler;
27 import org.apache.tools.ant.types.Commandline;
28 import org.apache.tools.ant.util.FileUtils;
29
30
31 /**
32  * A base class for creating tasks for executing commands on Continuus 5.1.
33  * <p>
34  * The class extends the task as it operates by executing the ccm.exe program
35  * supplied with Continuus/Synergy. By default the task expects the ccm executable to be
36  * in the path,
37  * you can override this be specifying the ccmdir attribute.
38  * </p>
39  *
40  */

41 public abstract class Continuus extends Task {
42
43     private String JavaDoc ccmDir = "";
44     private String JavaDoc ccmAction = "";
45
46     /**
47      * Get the value of ccmAction.
48      * @return value of ccmAction.
49      */

50     public String JavaDoc getCcmAction() {
51         return ccmAction;
52     }
53
54     /**
55      * Set the value of ccmAction.
56      * @param v Value to assign to ccmAction.
57      * @ant.attribute ignore="true"
58      */

59     public void setCcmAction(String JavaDoc v) {
60         this.ccmAction = v;
61     }
62
63
64     /**
65      * Set the directory where the ccm executable is located.
66      *
67      * @param dir the directory containing the ccm executable
68      */

69     public final void setCcmDir(String JavaDoc dir) {
70         ccmDir = FileUtils.translatePath(dir);
71     }
72
73     /**
74      * Builds and returns the command string to execute ccm
75      * @return String containing path to the executable
76      */

77     protected final String JavaDoc getCcmCommand() {
78         String JavaDoc toReturn = ccmDir;
79         if (!toReturn.equals("") && !toReturn.endsWith("/")) {
80             toReturn += "/";
81         }
82
83         toReturn += CCM_EXE;
84
85         return toReturn;
86     }
87
88
89     /**
90      * Run the command.
91      * @param cmd the command line
92      * @param handler an execute stream handler
93      * @return the exit status of the command
94      */

95     protected int run(Commandline cmd, ExecuteStreamHandler handler) {
96         try {
97             Execute exe = new Execute(handler);
98             exe.setAntRun(getProject());
99             exe.setWorkingDirectory(getProject().getBaseDir());
100             exe.setCommandline(cmd.getCommandline());
101             return exe.execute();
102         } catch (java.io.IOException JavaDoc e) {
103             throw new BuildException(e, getLocation());
104         }
105     }
106
107     /**
108      * Run the command.
109      * @param cmd the command line
110      * @return the exit status of the command
111      */

112     protected int run(Commandline cmd) {
113         return run(cmd, new LogStreamHandler(this, Project.MSG_VERBOSE, Project.MSG_WARN));
114     }
115
116     /**
117      * Constant for the thing to execute
118      */

119     private static final String JavaDoc CCM_EXE = "ccm";
120
121     /**
122      * The 'CreateTask' command
123      */

124     public static final String JavaDoc COMMAND_CREATE_TASK = "create_task";
125     /**
126      * The 'Checkout' command
127      */

128     public static final String JavaDoc COMMAND_CHECKOUT = "co";
129     /**
130      * The 'Checkin' command
131      */

132     public static final String JavaDoc COMMAND_CHECKIN = "ci";
133     /**
134      * The 'Reconfigure' command
135      */

136     public static final String JavaDoc COMMAND_RECONFIGURE = "reconfigure";
137
138     /**
139      * The 'Reconfigure' command
140      */

141     public static final String JavaDoc COMMAND_DEFAULT_TASK = "default_task";
142
143
144 }
145
Popular Tags