From 8bf664b1c5512651c2da77cef1eed73a8c493b32 Mon Sep 17 00:00:00 2001 From: Peter Donald Date: Sun, 16 Dec 2001 05:51:13 +0000 Subject: [PATCH] No need for there to be a initialize method. Now that tasks are initialized and executed in one sweep initialize functions could just be done at the start of an execute call. git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@270210 13f79535-47bb-0310-9956-ffa450edef68 --- .../src/main/org/apache/tools/ant/Task.java | 10 --------- .../tools/ant/taskdefs/optional/ANTLR.java | 16 ++++---------- .../taskdefs/optional/junit/JUnitTask.java | 21 ++++++++----------- .../taskdefs/optional/perforce/P4Base.java | 11 ++++++++-- .../taskdefs/optional/sound/SoundTask.java | 6 ------ .../src/todo/org/apache/tools/ant/Task.java | 10 --------- .../tools/ant/taskdefs/optional/ANTLR.java | 16 ++++---------- .../taskdefs/optional/junit/JUnitTask.java | 21 ++++++++----------- .../taskdefs/optional/perforce/P4Base.java | 11 ++++++++-- .../taskdefs/optional/sound/SoundTask.java | 6 ------ 10 files changed, 44 insertions(+), 84 deletions(-) diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/Task.java b/proposal/myrmidon/src/main/org/apache/tools/ant/Task.java index 1ba3a1a9d..49304d5c6 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/Task.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/Task.java @@ -26,16 +26,6 @@ public abstract class Task { } - /** - * Called by the project to let the task initialize properly. - * - * @throws TaskException if someting goes wrong with the build - */ - public void initialize() - throws TaskException - { - } - /** * Log a mesage with the give priority. * diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ANTLR.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ANTLR.java index cd3adc916..b050223f6 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ANTLR.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ANTLR.java @@ -112,6 +112,10 @@ public class ANTLR extends Task public void execute() throws TaskException { + //Adds the jars or directories containing Antlr this should make the forked + //JVM work without having to specify it directly. + addClasspathEntry( "/antlr/Tool.class" ); + validateAttributes(); //TODO: use ANTLR to parse the grammer file to do this. @@ -140,18 +144,6 @@ public class ANTLR extends Task } } - /** - * Adds the jars or directories containing Antlr this should make the forked - * JVM work without having to specify it directly. - * - * @exception TaskException Description of Exception - */ - public void initialize() - throws TaskException - { - addClasspathEntry( "/antlr/Tool.class" ); - } - /** * Search for the given resource and add the directory or archive that * contains it to the classpath.

diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java index 7d1c6901e..3c26e4211 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java @@ -379,6 +379,15 @@ public class JUnitTask extends Task public void execute() throws TaskException { + /* + * Adds the jars or directories containing Ant, this task and JUnit to the + * classpath - this should make the forked JVM work without having to + * specify them directly. + */ + addClasspathEntry( "/junit/framework/TestCase.class" ); + addClasspathEntry( "/org/apache/tools/ant/Task.class" ); + addClasspathEntry( "/org/apache/tools/ant/taskdefs/optional/junit/JUnitTestRunner.class" ); + Enumeration list = getIndividualTests(); while( list.hasMoreElements() ) { @@ -390,18 +399,6 @@ public class JUnitTask extends Task } } - /** - * Adds the jars or directories containing Ant, this task and JUnit to the - * classpath - this should make the forked JVM work without having to - * specify them directly. - */ - public void initialize() - { - addClasspathEntry( "/junit/framework/TestCase.class" ); - addClasspathEntry( "/org/apache/tools/ant/Task.class" ); - addClasspathEntry( "/org/apache/tools/ant/taskdefs/optional/junit/JUnitTestRunner.class" ); - } - /** * Get the default output for a formatter. * diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/perforce/P4Base.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/perforce/P4Base.java index 509c7bc65..e9bb2ac32 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/perforce/P4Base.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/perforce/P4Base.java @@ -93,9 +93,8 @@ public abstract class P4Base extends org.apache.tools.ant.Task this.P4View = P4View; } - public void initialize() + private void prepare() { - util = new Perl5Util(); //Get default P4 settings from environment - Mark would have done something cool with @@ -115,6 +114,14 @@ public abstract class P4Base extends org.apache.tools.ant.Task execP4Command( command, null ); } + public void execute() + throws TaskException + { + //Setup task before executing it + prepare(); + super.execute(); + } + /** * Execute P4 command assembled by subclasses. * diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/sound/SoundTask.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/sound/SoundTask.java index a4ae5024d..77214fd3f 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/sound/SoundTask.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/sound/SoundTask.java @@ -79,15 +79,9 @@ public class SoundTask extends Task } - public void initialize() - { - } - /** * A class to be extended by any BuildAlert's that require the output of * sound. - * - * @author RT */ public class BuildAlert { diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/Task.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/Task.java index 1ba3a1a9d..49304d5c6 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/Task.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/Task.java @@ -26,16 +26,6 @@ public abstract class Task { } - /** - * Called by the project to let the task initialize properly. - * - * @throws TaskException if someting goes wrong with the build - */ - public void initialize() - throws TaskException - { - } - /** * Log a mesage with the give priority. * diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ANTLR.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ANTLR.java index cd3adc916..b050223f6 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ANTLR.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ANTLR.java @@ -112,6 +112,10 @@ public class ANTLR extends Task public void execute() throws TaskException { + //Adds the jars or directories containing Antlr this should make the forked + //JVM work without having to specify it directly. + addClasspathEntry( "/antlr/Tool.class" ); + validateAttributes(); //TODO: use ANTLR to parse the grammer file to do this. @@ -140,18 +144,6 @@ public class ANTLR extends Task } } - /** - * Adds the jars or directories containing Antlr this should make the forked - * JVM work without having to specify it directly. - * - * @exception TaskException Description of Exception - */ - public void initialize() - throws TaskException - { - addClasspathEntry( "/antlr/Tool.class" ); - } - /** * Search for the given resource and add the directory or archive that * contains it to the classpath.

diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java index 7d1c6901e..3c26e4211 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java @@ -379,6 +379,15 @@ public class JUnitTask extends Task public void execute() throws TaskException { + /* + * Adds the jars or directories containing Ant, this task and JUnit to the + * classpath - this should make the forked JVM work without having to + * specify them directly. + */ + addClasspathEntry( "/junit/framework/TestCase.class" ); + addClasspathEntry( "/org/apache/tools/ant/Task.class" ); + addClasspathEntry( "/org/apache/tools/ant/taskdefs/optional/junit/JUnitTestRunner.class" ); + Enumeration list = getIndividualTests(); while( list.hasMoreElements() ) { @@ -390,18 +399,6 @@ public class JUnitTask extends Task } } - /** - * Adds the jars or directories containing Ant, this task and JUnit to the - * classpath - this should make the forked JVM work without having to - * specify them directly. - */ - public void initialize() - { - addClasspathEntry( "/junit/framework/TestCase.class" ); - addClasspathEntry( "/org/apache/tools/ant/Task.class" ); - addClasspathEntry( "/org/apache/tools/ant/taskdefs/optional/junit/JUnitTestRunner.class" ); - } - /** * Get the default output for a formatter. * diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/perforce/P4Base.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/perforce/P4Base.java index 509c7bc65..e9bb2ac32 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/perforce/P4Base.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/perforce/P4Base.java @@ -93,9 +93,8 @@ public abstract class P4Base extends org.apache.tools.ant.Task this.P4View = P4View; } - public void initialize() + private void prepare() { - util = new Perl5Util(); //Get default P4 settings from environment - Mark would have done something cool with @@ -115,6 +114,14 @@ public abstract class P4Base extends org.apache.tools.ant.Task execP4Command( command, null ); } + public void execute() + throws TaskException + { + //Setup task before executing it + prepare(); + super.execute(); + } + /** * Execute P4 command assembled by subclasses. * diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/sound/SoundTask.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/sound/SoundTask.java index a4ae5024d..77214fd3f 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/sound/SoundTask.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/sound/SoundTask.java @@ -79,15 +79,9 @@ public class SoundTask extends Task } - public void initialize() - { - } - /** * A class to be extended by any BuildAlert's that require the output of * sound. - * - * @author RT */ public class BuildAlert {