Re: patch for JUnitTask extension

2004-02-20 Thread Stefan Bodewig
On Wed, 11 Feb 2004, Mariano Benitez [EMAIL PROTECTED] wrote:

 The diff was against the 1.6.0 WC, I guess the versions are just the
 same,

No they are not.  I've changed some stuff in CommandlineJava in CVS
HEAD for the new cloneVm feature.  Please take a look at the code to
see whether you'd need any further changes.

Stefan

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: patch for JUnitTask extension

2004-02-20 Thread Mariano Benitez
--- src/main/org/apache/tools/ant/types/CommandlineJava.java2004-02-11 
15:27:15.0 -0300
+++ 
/opt/java/ant/apache-ant-1.6.0/src/main/org/apache/tools/ant/types/CommandlineJava.java
 2004-02-11 15:08:41.0 -0300
@@ -432,7 +432,7 @@
  * Get the VM command parameters, including memory settings
  * @return
  */
-private Commandline getActualVMCommand() {
+protected Commandline getActualVMCommand() {
 Commandline actualVMCommand = (Commandline) vmCommand.clone();
 if (maxMemory != null) {
 if (vmVersion.startsWith(1.1)) {
@@ -567,7 +567,7 @@
  *
  * @since Ant 1.6
  */
-private boolean haveClasspath() {
+protected boolean haveClasspath() {
 Path fullClasspath = classpath != null
 ? classpath.concatSystemClasspath(ignore) : null;
 return fullClasspath != null
@@ -584,7 +584,7 @@
  *
  * @since Ant 1.6
  */
-private boolean haveBootclasspath(boolean log) {
+protected boolean haveBootclasspath(boolean log) {
 if (bootclasspath != null
  bootclasspath.toString().trim().length()  0) {

--- src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java
2004-02-11 15:27:15.0 -0300
+++ 
/opt/java/ant/apache-ant-1.6.0/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java
 2004-02-11 14:43:03.0 -0300
@@ -123,7 +123,7 @@
  */
 public class JUnitTask extends Task {
 
-private CommandlineJava commandline = new CommandlineJava();
+private CommandlineJava commandline;
 private Vector tests = new Vector();
 private Vector batchTests = new Vector();
 private Vector formatters = new Vector();
@@ -338,7 +338,7 @@
  * @since Ant 1.2
  */
 public void setMaxmemory(String max) {
-commandline.setMaxmemory(max);
+getCommandline().setMaxmemory(max);
 }

 /**
@@ -352,7 +352,7 @@
  * @since Ant 1.2
  */
 public void setJvm(String value) {
-commandline.setVm(value);
+getCommandline().setVm(value);
 }

 /**
@@ -365,7 +365,7 @@
  * @since Ant 1.2
  */
 public Commandline.Argument createJvmarg() {
-return commandline.createVmArgument();
+return getCommandline().createVmArgument();
 }

 /**
@@ -390,7 +390,7 @@
  */
 public void addSysproperty(Environment.Variable sysp) {

-commandline.addSysproperty(sysp);
+getCommandline().addSysproperty(sysp);
 }

 /**
@@ -405,7 +405,7 @@
 // see bugzilla report 21684
 String testString = sysp.getContent();
 getProject().log(sysproperty added :  + testString, 
Project.MSG_DEBUG);
-commandline.addSysproperty(sysp);
+getCommandline().addSysproperty(sysp);
 }

 /**
@@ -419,7 +419,7 @@
  * @since Ant 1.6
  */
 public void addSyspropertyset(PropertySet sysp) {
-commandline.addSyspropertyset(sysp);
+getCommandline().addSyspropertyset(sysp);
 }

 /**
@@ -429,7 +429,7 @@
  * @since Ant 1.2
  */
 public Path createClasspath() {
-return commandline.createClasspath(getProject()).createPath();
+return getCommandline().createClasspath(getProject()).createPath();
 }

 /**
@@ -438,7 +438,7 @@
  * @since Ant 1.6
  */
 public Path createBootclasspath() {
-return commandline.createBootclasspath(getProject()).createPath();
+return getCommandline().createBootclasspath(getProject()).createPath();
 }

 /**
@@ -532,10 +532,10 @@
  * @param asserts assertion set
  */
 public void addAssertions(Assertions asserts) {
-if (commandline.getAssertions() != null) {
+if (getCommandline().getAssertions() != null) {
 throw new BuildException(Only one assertion declaration is 
allowed);
 }
-commandline.setAssertions(asserts);
+getCommandline().setAssertions(asserts);
 }

 /**
@@ -557,7 +557,7 @@
  * @since Ant 1.2
  */
 public JUnitTask() throws Exception {
-commandline
+getCommandline()
 
.setClassname(org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner);
 }

@@ -675,7 +675,7 @@
 log(Permissions ignored when running in forked mode!, 
Project.MSG_WARN);
 }

-CommandlineJava cmd = (CommandlineJava) commandline.clone();
+CommandlineJava cmd = (CommandlineJava) getCommandline().clone();

 
cmd.setClassname(org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner);
 cmd.createArgument().setValue(test.getName());
@@ -903,13 +903,13 @@
 + the same VM., Project.MSG_WARN);
 }

-if (commandline.getBootclasspath() != null) {
+if (getCommandline().getBootclasspath() != null) {
 log(bootclasspath is ignored if running in the same VM.,
 Project.MSG_WARN);
 }

 

patch for JUnitTask extension

2004-02-11 Thread Mariano Benitez
This is the patch for JUnitTask and CommandlineJava to make them extensible.
The main change in CommandlineJava is that some methods were made 
protected and in JUnitTask replace the direct usage of commandline for 
an accessor, this way they can both be extended to provide custom 
commandline implementations.

The diff was against the 1.6.0 WC, I guess the versions are just the 
same, If you want me to diff them against the CVS version shout me. :)
MAriano
--- src/main/org/apache/tools/ant/types/CommandlineJava.java2004-02-11 
15:27:15.0 -0300
+++ 
/opt/java/ant/apache-ant-1.6.0/src/main/org/apache/tools/ant/types/CommandlineJava.java
 2004-02-11 15:08:41.0 -0300
@@ -383,6 +383,7 @@
 final ListIterator listIterator = commands.listIterator();
 //fill it
 addCommandsToList(listIterator);
+
 //convert to an array
 return (String[]) commands.toArray(new String[0]);
 }
@@ -395,6 +396,7 @@
 private void addCommandsToList(final ListIterator listIterator) {
 //create the command to run Java, including user specified options
 getActualVMCommand().addCommandToList(listIterator);
+
 // properties are part of the vm options...
 sysProperties.addDefinitionsToList(listIterator);
 //boot classpath
@@ -469,7 +471,7 @@
  * Get the VM command parameters, including memory settings
  * @return
  */
-private Commandline getActualVMCommand() {
+protected Commandline getActualVMCommand() {
 Commandline actualVMCommand = (Commandline) vmCommand.clone();
 if (maxMemory != null) {
 if (vmVersion.startsWith(1.1)) {
@@ -604,7 +606,7 @@
  *
  * @since Ant 1.6
  */
-private boolean haveClasspath() {
+protected boolean haveClasspath() {
 Path fullClasspath = classpath != null
 ? classpath.concatSystemClasspath(ignore) : null;
 return fullClasspath != null
@@ -621,7 +623,7 @@
  *
  * @since Ant 1.6
  */
-private boolean haveBootclasspath(boolean log) {
+protected boolean haveBootclasspath(boolean log) {
 if (bootclasspath != null
  bootclasspath.toString().trim().length()  0) {

--- src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java
2004-02-11 15:27:15.0 -0300
+++ 
/opt/java/ant/apache-ant-1.6.0/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java
 2004-02-11 14:43:03.0 -0300
@@ -160,7 +160,7 @@
  */
 public class JUnitTask extends Task {
 
-private CommandlineJava commandline = new CommandlineJava();
+private CommandlineJava commandline;
 private Vector tests = new Vector();
 private Vector batchTests = new Vector();
 private Vector formatters = new Vector();
@@ -375,7 +375,7 @@
  * @since Ant 1.2
  */
 public void setMaxmemory(String max) {
-commandline.setMaxmemory(max);
+getCommandline().setMaxmemory(max);
 }

 /**
@@ -389,7 +389,7 @@
  * @since Ant 1.2
  */
 public void setJvm(String value) {
-commandline.setVm(value);
+getCommandline().setVm(value);
 }

 /**
@@ -402,7 +402,7 @@
  * @since Ant 1.2
  */
 public Commandline.Argument createJvmarg() {
-return commandline.createVmArgument();
+return getCommandline().createVmArgument();
 }

 /**
@@ -427,7 +427,7 @@
  */
 public void addSysproperty(Environment.Variable sysp) {

-commandline.addSysproperty(sysp);
+getCommandline().addSysproperty(sysp);
 }

 /**
@@ -442,7 +442,7 @@
 // see bugzilla report 21684
 String testString = sysp.getContent();
 getProject().log(sysproperty added :  + testString, 
Project.MSG_DEBUG);
-commandline.addSysproperty(sysp);
+getCommandline().addSysproperty(sysp);
 }

 /**
@@ -456,7 +456,7 @@
  * @since Ant 1.6
  */
 public void addSyspropertyset(PropertySet sysp) {
-commandline.addSyspropertyset(sysp);
+getCommandline().addSyspropertyset(sysp);
 }

 /**
@@ -466,7 +466,7 @@
  * @since Ant 1.2
  */
 public Path createClasspath() {
-return commandline.createClasspath(getProject()).createPath();
+return getCommandline().createClasspath(getProject()).createPath();
 }

 /**
@@ -475,7 +475,7 @@
  * @since Ant 1.6
  */
 public Path createBootclasspath() {
-return commandline.createBootclasspath(getProject()).createPath();
+return getCommandline().createBootclasspath(getProject()).createPath();
 }

 /**
@@ -569,10 +569,10 @@
  * @param asserts assertion set
  */
 public void addAssertions(Assertions asserts) {
-if (commandline.getAssertions() != null) {
+if (getCommandline().getAssertions() != null) {
 throw new BuildException(Only one assertion declaration is 
allowed);
 }
-