source: release-kits/lirk3/resources/gs3-release-maker/apache-ant-1.6.5/src/main/org/apache/tools/ant/taskdefs/optional/ccm/Continuus.java@ 14982

Last change on this file since 14982 was 14982, checked in by oranfry, 16 years ago

initial import of LiRK3

File size: 3.7 KB
Line 
1/*
2 * Copyright 2001-2004 The Apache Software Foundation
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *
16 */
17
18package org.apache.tools.ant.taskdefs.optional.ccm;
19
20import org.apache.tools.ant.BuildException;
21import org.apache.tools.ant.Project;
22import org.apache.tools.ant.Task;
23import org.apache.tools.ant.taskdefs.Execute;
24import org.apache.tools.ant.taskdefs.ExecuteStreamHandler;
25import org.apache.tools.ant.taskdefs.LogStreamHandler;
26import org.apache.tools.ant.types.Commandline;
27
28
29/**
30 * A base class for creating tasks for executing commands on Continuus 5.1.
31 * <p>
32 * The class extends the task as it operates by executing the ccm.exe program
33 * supplied with Continuus/Synergy. By default the task expects the ccm executable to be
34 * in the path,
35 * you can override this be specifying the ccmdir attribute.
36 * </p>
37 *
38 */
39public abstract class Continuus extends Task {
40
41 private String ccmDir = "";
42 private String ccmAction = "";
43
44 /**
45 * Get the value of ccmAction.
46 * @return value of ccmAction.
47 */
48 public String getCcmAction() {
49 return ccmAction;
50 }
51
52 /**
53 * Set the value of ccmAction.
54 * @param v Value to assign to ccmAction.
55 * @ant.attribute ignore="true"
56 */
57 public void setCcmAction(String v) {
58 this.ccmAction = v;
59 }
60
61
62 /**
63 * Set the directory where the ccm executable is located.
64 *
65 * @param dir the directory containing the ccm executable
66 */
67 public final void setCcmDir(String dir) {
68 ccmDir = Project.translatePath(dir);
69 }
70
71 /**
72 * Builds and returns the command string to execute ccm
73 * @return String containing path to the executable
74 */
75 protected final String getCcmCommand() {
76 String toReturn = ccmDir;
77 if (!toReturn.equals("") && !toReturn.endsWith("/")) {
78 toReturn += "/";
79 }
80
81 toReturn += CCM_EXE;
82
83 return toReturn;
84 }
85
86
87 protected int run(Commandline cmd, ExecuteStreamHandler handler) {
88 try {
89 Execute exe = new Execute(handler);
90 exe.setAntRun(getProject());
91 exe.setWorkingDirectory(getProject().getBaseDir());
92 exe.setCommandline(cmd.getCommandline());
93 return exe.execute();
94 } catch (java.io.IOException e) {
95 throw new BuildException(e, getLocation());
96 }
97 }
98
99 protected int run(Commandline cmd) {
100 return run(cmd, new LogStreamHandler(this, Project.MSG_VERBOSE, Project.MSG_WARN));
101 }
102
103 /**
104 * Constant for the thing to execute
105 */
106 private static final String CCM_EXE = "ccm";
107
108 /**
109 * The 'CreateTask' command
110 */
111 public static final String COMMAND_CREATE_TASK = "create_task";
112 /**
113 * The 'Checkout' command
114 */
115 public static final String COMMAND_CHECKOUT = "co";
116 /**
117 * The 'Checkin' command
118 */
119 public static final String COMMAND_CHECKIN = "ci";
120 /**
121 * The 'Reconfigure' command
122 */
123 public static final String COMMAND_RECONFIGURE = "reconfigure";
124
125 /**
126 * The 'Reconfigure' command
127 */
128 public static final String COMMAND_DEFAULT_TASK = "default_task";
129
130
131}
Note: See TracBrowser for help on using the repository browser.