summaryrefslogtreecommitdiff
path: root/src/main/org/apache/tools/ant/taskdefs/optional/ccm/CCMCreateTask.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/org/apache/tools/ant/taskdefs/optional/ccm/CCMCreateTask.java')
-rw-r--r--src/main/org/apache/tools/ant/taskdefs/optional/ccm/CCMCreateTask.java114
1 files changed, 53 insertions, 61 deletions
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
index 350d673c7..a3d2d468d 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/ccm/CCMCreateTask.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/ccm/CCMCreateTask.java
@@ -38,6 +38,35 @@ import org.apache.tools.ant.util.StringUtils;
* @ant.task name="ccmcreatetask" category="scm"
*/
public class CCMCreateTask extends Continuus implements ExecuteStreamHandler {
+ /**
+ * /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 checkout task with task
+ */
+ public static final String FLAG_TASK = "/task";
private String comment = null;
private String platform = null;
@@ -63,9 +92,9 @@ public class CCMCreateTask extends Continuus implements ExecuteStreamHandler {
* </p>
* @throws BuildException on error
*/
+ @Override
public void execute() throws BuildException {
Commandline commandLine = new Commandline();
- int result = 0;
// build the command line from what we got the format
// as specified in the CCM.EXE help
@@ -74,10 +103,9 @@ public class CCMCreateTask extends Continuus implements ExecuteStreamHandler {
checkOptions(commandLine);
- result = run(commandLine, this);
- if (Execute.isFailure(result)) {
- String msg = "Failed executing: " + commandLine.toString();
- throw new BuildException(msg, getLocation());
+ if (Execute.isFailure(run(commandLine, this))) {
+ throw new BuildException("Failed executing: " + commandLine,
+ getLocation());
}
//create task ok, set this task as the default one
@@ -88,15 +116,12 @@ public class CCMCreateTask extends Continuus implements ExecuteStreamHandler {
log(commandLine.describeCommand(), Project.MSG_DEBUG);
- result = run(commandLine2);
- if (result != 0) {
- String msg = "Failed executing: " + commandLine2.toString();
- throw new BuildException(msg, getLocation());
+ if (run(commandLine2) != 0) {
+ throw new BuildException("Failed executing: " + commandLine2,
+ getLocation());
}
-
}
-
/**
* Check the command line options.
*/
@@ -127,7 +152,6 @@ public class CCMCreateTask extends Continuus implements ExecuteStreamHandler {
} // end of if ()
}
-
/**
* Get the value of comment.
* @return value of comment.
@@ -145,7 +169,6 @@ public class CCMCreateTask extends Continuus implements ExecuteStreamHandler {
this.comment = v;
}
-
/**
* Get the value of platform.
* @return value of platform.
@@ -163,7 +186,6 @@ public class CCMCreateTask extends Continuus implements ExecuteStreamHandler {
this.platform = v;
}
-
/**
* Get the value of resolver.
* @return value of resolver.
@@ -181,7 +203,6 @@ public class CCMCreateTask extends Continuus implements ExecuteStreamHandler {
this.resolver = v;
}
-
/**
* Get the value of release.
* @return value of release.
@@ -216,7 +237,6 @@ public class CCMCreateTask extends Continuus implements ExecuteStreamHandler {
this.subSystem = v;
}
-
/**
* Get the value of task.
* @return value of task.
@@ -235,71 +255,45 @@ public class CCMCreateTask extends Continuus implements ExecuteStreamHandler {
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 checkout task with task
- */
- public static final String FLAG_TASK = "/task";
-
-
// implementation of org.apache.tools.ant.taskdefs.ExecuteStreamHandler interface
/**
*
* @throws IOException on error
*/
+ @Override
public void start() throws IOException {
}
/**
*
*/
+ @Override
public void stop() {
}
/**
*
* @param param1 the output stream
- * @exception java.io.IOException on error
+ * @exception IOException on error
*/
+ @Override
public void setProcessInputStream(OutputStream param1) throws IOException {
}
/**
*
* @param is the input stream
- * @exception java.io.IOException on error
+ * @exception IOException on error
*/
+ @Override
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 ()
+ try (BufferedReader reader = new BufferedReader(new InputStreamReader(is))) {
+ String s = reader.readLine();
+ if (s != null) {
+ log("err " + s, Project.MSG_DEBUG);
+ } // end of if ()
+ }
}
/**
@@ -307,12 +301,11 @@ public class CCMCreateTask extends Continuus implements ExecuteStreamHandler {
* @param is InputStream
* @throws IOException on error
*/
+ @Override
public void setProcessOutputStream(InputStream is) throws IOException {
-
- String buffer = "";
- try {
- BufferedReader reader = new BufferedReader(new InputStreamReader(is));
- buffer = reader.readLine();
+ try (BufferedReader reader =
+ new BufferedReader(new InputStreamReader(is))) {
+ String buffer = reader.readLine();
if (buffer != null) {
log("buffer:" + buffer, Project.MSG_DEBUG);
String taskstring = buffer.substring(buffer.indexOf(' ')).trim();
@@ -323,7 +316,7 @@ public class CCMCreateTask extends Continuus implements ExecuteStreamHandler {
} catch (NullPointerException npe) {
log("error procession stream , null pointer exception", Project.MSG_ERR);
log(StringUtils.getStackTrace(npe), Project.MSG_ERR);
- throw new BuildException(npe.getClass().getName());
+ throw new BuildException(npe);
} catch (Exception e) {
log("error procession stream " + e.getMessage(), Project.MSG_ERR);
throw new BuildException(e.getMessage());
@@ -332,4 +325,3 @@ public class CCMCreateTask extends Continuus implements ExecuteStreamHandler {
}
}
-