From 244252d7c9ed28035af96f36dad07288ad111ead Mon Sep 17 00:00:00 2001
From: Stephane Bailliez
* <p4counter name="${p4.counter}" property=${p4.change}"/>
* @author Kirk Wylie
*/
-
+
public class P4Counter extends P4Base {
public String counter = null;
public String property = null;
@@ -96,35 +96,35 @@ public class P4Counter extends P4Base {
public void execute() throws BuildException {
- if((counter == null) || counter.length() == 0) {
+ if ((counter == null) || counter.length() == 0) {
throw new BuildException("No counter specified to retrieve");
}
- if(shouldSetValue && shouldSetProperty) {
+ if (shouldSetValue && shouldSetProperty) {
throw new BuildException("Cannot both set the value of the property and retrieve the value of the property.");
}
String command = "counter " + P4CmdOpts + " " + counter;
- if(!shouldSetProperty) {
+ if (!shouldSetProperty) {
// NOTE kirk@radik.com 04-April-2001 -- If you put in the -s, you
// have to start running through regular expressions here. Much easier
// to just not include the scripting information than to try to add it
// and strip it later.
command = "-s " + command;
}
- if(shouldSetValue) {
+ if (shouldSetValue) {
command += " " + value;
}
- if(shouldSetProperty) {
+ if (shouldSetProperty) {
final Project myProj = project;
P4Handler handler = new P4HandlerAdapter() {
public void process(String line) {
- log("P4Counter retrieved line \""+ line + "\"", Project.MSG_VERBOSE);
+ log("P4Counter retrieved line \"" + line + "\"", Project.MSG_VERBOSE);
try {
value = Integer.parseInt(line);
- myProj.setProperty(property, ""+value);
+ myProj.setProperty(property, "" + value);
} catch (NumberFormatException nfe) {
throw new BuildException("Perforce error. Could not retrieve counter value.");
}
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/perforce/P4Delete.java b/src/main/org/apache/tools/ant/taskdefs/optional/perforce/P4Delete.java
index b3e4147ec..94f6ce606 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/perforce/P4Delete.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/perforce/P4Delete.java
@@ -76,12 +76,12 @@ public class P4Delete extends P4Base {
}
public void execute() throws BuildException {
- if(change != null ) {
- P4CmdOpts = "-c "+change;
+ if (change != null) {
+ P4CmdOpts = "-c " + change;
}
- if(P4View == null) {
- throw new BuildException("No view specified to delete");
+ if (P4View == null) {
+ throw new BuildException("No view specified to delete");
}
- execP4Command("-s delete "+P4CmdOpts+" "+P4View, new SimpleP4OutputHandler(this));
+ execP4Command("-s delete " + P4CmdOpts + " " + P4View, new SimpleP4OutputHandler(this));
}
}
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/perforce/P4Edit.java b/src/main/org/apache/tools/ant/taskdefs/optional/perforce/P4Edit.java
index e80dbfc79..216e60174 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/perforce/P4Edit.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/perforce/P4Edit.java
@@ -69,7 +69,7 @@ import org.apache.tools.ant.BuildException;
* ToDo: Should call reopen if file is already open in one of our changelists perhaps?
*/
- public class P4Edit extends P4Base {
+public class P4Edit extends P4Base {
public String change = null;
@@ -78,12 +78,12 @@ import org.apache.tools.ant.BuildException;
}
public void execute() throws BuildException {
- if(change != null ) {
- P4CmdOpts = "-c "+change;
+ if (change != null) {
+ P4CmdOpts = "-c " + change;
}
- if(P4View == null) {
- throw new BuildException("No view specified to edit");
+ if (P4View == null) {
+ throw new BuildException("No view specified to edit");
}
- execP4Command("-s edit "+P4CmdOpts+" "+P4View, new SimpleP4OutputHandler(this));
+ execP4Command("-s edit " + P4CmdOpts + " " + P4View, new SimpleP4OutputHandler(this));
}
}
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/perforce/P4Handler.java b/src/main/org/apache/tools/ant/taskdefs/optional/perforce/P4Handler.java
index bef5f9843..ffbd5ca62 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/perforce/P4Handler.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/perforce/P4Handler.java
@@ -65,5 +65,6 @@ import org.apache.tools.ant.taskdefs.ExecuteStreamHandler;
public interface P4Handler extends ExecuteStreamHandler {
public void process(String line) throws BuildException;
+
public void setOutput(String line) throws BuildException;
}
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/perforce/P4HandlerAdapter.java b/src/main/org/apache/tools/ant/taskdefs/optional/perforce/P4HandlerAdapter.java
index f6eb1ce86..c95d36718 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/perforce/P4HandlerAdapter.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/perforce/P4HandlerAdapter.java
@@ -54,12 +54,13 @@
package org.apache.tools.ant.taskdefs.optional.perforce;
+import java.io.BufferedReader;
import java.io.IOException;
-import java.io.OutputStream;
import java.io.InputStream;
-import java.io.BufferedReader;
import java.io.InputStreamReader;
+import java.io.OutputStream;
import java.io.SequenceInputStream;
+
import org.apache.tools.ant.BuildException;
public abstract class P4HandlerAdapter implements P4Handler {
@@ -77,29 +78,29 @@ public abstract class P4HandlerAdapter implements P4Handler {
public void start() throws BuildException {
- try{
- //First write any output to P4
- if(p4input != null && p4input.length() >0 && os != null) {
- os.write(p4input.getBytes());
- os.flush();
- os.close();
+ try {
+ //First write any output to P4
+ if (p4input != null && p4input.length() > 0 && os != null) {
+ os.write(p4input.getBytes());
+ os.flush();
+ os.close();
}
- //Now read any input and process
+ //Now read any input and process
- BufferedReader input = new BufferedReader(
- new InputStreamReader(
- new SequenceInputStream(is,es)));
+ BufferedReader input = new BufferedReader(
+ new InputStreamReader(
+ new SequenceInputStream(is, es)));
String line;
- while((line = input.readLine()) != null) {
- process(line);
+ while ((line = input.readLine()) != null) {
+ process(line);
}
input.close();
- }catch(Exception e) {
+ } catch (Exception e) {
throw new BuildException(e);
}
}
@@ -120,5 +121,6 @@ public abstract class P4HandlerAdapter implements P4Handler {
this.is = is;
}
- public void stop(){}
+ public void stop() {
+ }
}
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/perforce/P4Have.java b/src/main/org/apache/tools/ant/taskdefs/optional/perforce/P4Have.java
index 89771cce3..10f2c7283 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/perforce/P4Have.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/perforce/P4Have.java
@@ -62,7 +62,7 @@ import org.apache.tools.ant.BuildException;
/** P4Have - lists files currently on client.
- *
+ *
* P4Have simply dumps the current file version info into
* the Ant log (or stdout).
* @author Les Hughes
@@ -70,6 +70,6 @@ import org.apache.tools.ant.BuildException;
public class P4Have extends P4Base {
public void execute() throws BuildException {
- execP4Command("have "+P4CmdOpts+" "+P4View, new SimpleP4OutputHandler(this));
+ execP4Command("have " + P4CmdOpts + " " + P4View, new SimpleP4OutputHandler(this));
}
}
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/perforce/P4Label.java b/src/main/org/apache/tools/ant/taskdefs/optional/perforce/P4Label.java
index 429cfd342..a39eca4e1 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/perforce/P4Label.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/perforce/P4Label.java
@@ -58,12 +58,12 @@
package org.apache.tools.ant.taskdefs.optional.perforce;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Project;
-import java.util.Date;
-import java.text.SimpleDateFormat;
-
/** P4Label - create a Perforce Label.
*
@@ -93,41 +93,41 @@ public class P4Label extends P4Base {
this.desc = desc;
}
- public void setLock(String lock) {
+ public void setLock(String lock) {
this.lock = lock;
- }
+ }
public void execute() throws BuildException {
- log("P4Label exec:",Project.MSG_INFO);
+ log("P4Label exec:", Project.MSG_INFO);
- if(P4View == null || P4View.length() < 1) {
+ if (P4View == null || P4View.length() < 1) {
log("View not set, assuming //depot/...", Project.MSG_WARN);
P4View = "//depot/...";
}
- if(desc == null || desc.length() < 1) {
+ if (desc == null || desc.length() < 1) {
log("Label Description not set, assuming 'AntLabel'", Project.MSG_WARN);
desc = "AntLabel";
}
- if(lock != null && !lock.equalsIgnoreCase("locked")) {
- log("lock attribute invalid - ignoring",Project.MSG_WARN);
+ if (lock != null && !lock.equalsIgnoreCase("locked")) {
+ log("lock attribute invalid - ignoring", Project.MSG_WARN);
}
- if(name == null || name.length() < 1) {
- SimpleDateFormat formatter = new SimpleDateFormat ("yyyy.MM.dd-hh:mm");
+ if (name == null || name.length() < 1) {
+ SimpleDateFormat formatter = new SimpleDateFormat("yyyy.MM.dd-hh:mm");
Date now = new Date();
- name = "AntLabel-"+formatter.format(now);
- log("name not set, assuming '"+name+"'", Project.MSG_WARN);
+ name = "AntLabel-" + formatter.format(now);
+ log("name not set, assuming '" + name + "'", Project.MSG_WARN);
}
//We have to create a unlocked label first
String newLabel =
- "Label: "+name+"\n"+
- "Description: "+desc+"\n"+
- "Options: unlocked\n"+
- "View: "+P4View+"\n";
+ "Label: " + name + "\n" +
+ "Description: " + desc + "\n" +
+ "Options: unlocked\n" +
+ "View: " + P4View + "\n";
P4Handler handler = new P4HandlerAdapter() {
public void process(String line) {
@@ -139,19 +139,19 @@ public class P4Label extends P4Base {
execP4Command("label -i", handler);
- execP4Command("labelsync -l "+name, new P4HandlerAdapter() {
+ execP4Command("labelsync -l " + name, new P4HandlerAdapter() {
public void process(String line) {
log(line, Project.MSG_VERBOSE);
}
});
- log("Created Label "+name+" ("+desc+")", Project.MSG_INFO);
+ log("Created Label " + name + " (" + desc + ")", Project.MSG_INFO);
//Now lock if required
- if (lock != null && lock.equalsIgnoreCase("locked")) {
+ if (lock != null && lock.equalsIgnoreCase("locked")) {
- log("Modifying lock status to 'locked'",Project.MSG_INFO);
+ log("Modifying lock status to 'locked'", Project.MSG_INFO);
final StringBuffer labelSpec = new StringBuffer();
@@ -159,24 +159,23 @@ public class P4Label extends P4Base {
//Replace Options
//Submit back to Perforce
- handler = new P4HandlerAdapter() {
- public void process(String line) {
+ handler = new P4HandlerAdapter() {
+ public void process(String line) {
log(line, Project.MSG_VERBOSE);
- if(util.match("/^Options:/",line)) {
- line = "Options: "+lock;
+ if (util.match("/^Options:/", line)) {
+ line = "Options: " + lock;
}
- labelSpec.append(line+"\n");
+ labelSpec.append(line + "\n");
}
};
+ execP4Command("label -o " + name, handler);
+ log(labelSpec.toString(), Project.MSG_DEBUG);
- execP4Command("label -o "+name, handler);
- log(labelSpec.toString(),Project.MSG_DEBUG);
-
- log("Now locking label...",Project.MSG_VERBOSE);
+ log("Now locking label...", Project.MSG_VERBOSE);
handler = new P4HandlerAdapter() {
public void process(String line) {
log(line, Project.MSG_VERBOSE);
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/perforce/P4Reopen.java b/src/main/org/apache/tools/ant/taskdefs/optional/perforce/P4Reopen.java
index e659638df..618cae448 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/perforce/P4Reopen.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/perforce/P4Reopen.java
@@ -64,12 +64,13 @@ import org.apache.tools.ant.BuildException;
*
* @author Les Hughes
*/
+
public class P4Reopen extends P4Base {
private String toChange = "";
public void setToChange(String toChange) throws BuildException {
- if(toChange == null && !toChange.equals("")) {
+ if (toChange == null && !toChange.equals("")) {
throw new BuildException("P4Reopen: tochange cannot be null or empty");
}
@@ -77,9 +78,9 @@ public class P4Reopen extends P4Base {
}
public void execute() throws BuildException {
- if(P4View == null) {
+ if (P4View == null) {
throw new BuildException("No view specified to reopen");
}
- execP4Command("-s reopen -c "+toChange+" "+P4View, new SimpleP4OutputHandler(this));
+ execP4Command("-s reopen -c " + toChange + " " + P4View, new SimpleP4OutputHandler(this));
}
}
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/perforce/P4Revert.java b/src/main/org/apache/tools/ant/taskdefs/optional/perforce/P4Revert.java
index 49141cb29..ac61a0c9d 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/perforce/P4Revert.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/perforce/P4Revert.java
@@ -64,13 +64,14 @@ import org.apache.tools.ant.BuildException;
*
* @author Les Hughes
*/
+
public class P4Revert extends P4Base {
private String revertChange = null;
private boolean onlyUnchanged = false;
public void setChange(String revertChange) throws BuildException {
- if(revertChange == null && !revertChange.equals("")) {
+ if (revertChange == null && !revertChange.equals("")) {
throw new BuildException("P4Revert: change cannot be null or empty");
}
@@ -78,7 +79,7 @@ public class P4Revert extends P4Base {
}
- public void setRevertOnlyUnchanged(boolean onlyUnchanged) {
+ public void setRevertOnlyUnchanged(boolean onlyUnchanged) {
this.onlyUnchanged = onlyUnchanged;
}
@@ -92,14 +93,14 @@ public class P4Revert extends P4Base {
* The whole process also accepts a p4 filespec
*/
String p4cmd = "-s revert";
- if(onlyUnchanged) {
- p4cmd+=" -a";
+ if (onlyUnchanged) {
+ p4cmd += " -a";
}
if (revertChange != null) {
- p4cmd += " -c "+revertChange;
+ p4cmd += " -c " + revertChange;
}
- execP4Command(p4cmd+" "+P4View, new SimpleP4OutputHandler(this));
+ execP4Command(p4cmd + " " + P4View, new SimpleP4OutputHandler(this));
}
}
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/perforce/P4Submit.java b/src/main/org/apache/tools/ant/taskdefs/optional/perforce/P4Submit.java
index 94add98e6..8b1cf4302 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/perforce/P4Submit.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/perforce/P4Submit.java
@@ -81,14 +81,15 @@ public class P4Submit extends P4Base {
public void setChange(String change) {
this.change = change;
}
+
public void execute() throws BuildException {
- if(change != null) {
- execP4Command("submit -c "+change,
- new P4HandlerAdapter() {
- public void process(String line) {
- log(line, Project.MSG_VERBOSE);
+ if (change != null) {
+ execP4Command("submit -c " + change,
+ new P4HandlerAdapter() {
+ public void process(String line) {
+ log(line, Project.MSG_VERBOSE);
+ }
}
- }
);
} else {
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/perforce/P4Sync.java b/src/main/org/apache/tools/ant/taskdefs/optional/perforce/P4Sync.java
index 78ddf89e4..a6283f9aa 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/perforce/P4Sync.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/perforce/P4Sync.java
@@ -62,7 +62,7 @@ import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Project;
/** P4Sync - synchronise client space to a perforce depot view.
- * The API allows additional functionality of the "p4 sync" command
+ * The API allows additional functionality of the "p4 sync" command
* (such as "p4 sync -f //...#have" or other exotic invocations).