ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From peterrei...@apache.org
Subject svn commit: r481970 - /ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/Script.java
Date Sun, 03 Dec 2006 22:55:45 GMT
Author: peterreilly
Date: Sun Dec  3 14:55:44 2006
New Revision: 481970

URL: http://svn.apache.org/viewvc?view=rev&rev=481970
Log:
use helper class, add manager attribute

Modified:
    ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/Script.java

Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/Script.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/Script.java?view=diff&rev=481970&r1=481969&r2=481970
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/Script.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/Script.java Sun Dec  3
14:55:44 2006
@@ -19,9 +19,9 @@
 
 import java.io.File;
 import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Project;
 import org.apache.tools.ant.Task;
-import org.apache.tools.ant.util.optional.ScriptRunner;
-import org.apache.tools.ant.util.ScriptRunnerBase;
+import org.apache.tools.ant.util.ScriptRunnerHelper;
 import org.apache.tools.ant.types.Path;
 import org.apache.tools.ant.types.Reference;
 
@@ -32,40 +32,33 @@
  */
 public class Script extends Task {
 
-    private Path    classpath;
-    private String  language;
-    private File    src;
-    private String  text;
-    private boolean setBeans = true;
+    private ScriptRunnerHelper helper = new ScriptRunnerHelper();
 
     /**
-     * Do the work.
+     * Set the project.
+     * @param project the project that this task belongs to.
+     */
+    public void setProject(Project project) {
+        super.setProject(project);
+        helper.setProjectComponent(this);
+    }
+
+    /**
+     * Run the script using the helper object.
      *
      * @exception BuildException if something goes wrong with the build
      */
     public void execute() throws BuildException {
-        ScriptRunnerBase runner = new ScriptRunner();
-        if (language != null) {
-            runner.setLanguage(language);
-        }
-        if (src != null) {
-            runner.setSrc(src);
-        }
-        if (text != null) {
-            runner.addText(text);
-        }
-        if (classpath != null) {
-            runner.setScriptClassLoader(
-                getProject().createClassLoader(
-                    getClass().getClassLoader(), classpath));
-        }
-        if (setBeans) {
-            runner.bindToComponent(this);
-        } else {
-            runner.bindToComponentMinimum(this);
-        }
+        helper.getScriptRunner().executeScript("ANT");
+    }
 
-        runner.executeScript("ANT");
+    /**
+     * Defines the manager.
+     *
+     * @param manager the scripting manager.
+     */
+    public void setManager(String manager) {
+        helper.setManager(manager);
     }
 
     /**
@@ -74,7 +67,7 @@
      * @param language the scripting language name for the script.
      */
     public void setLanguage(String language) {
-        this.language = language;
+        helper.setLanguage(language);
     }
 
     /**
@@ -83,7 +76,7 @@
      * @param fileName the name of the file containing the script source.
      */
     public void setSrc(String fileName) {
-        this.src = new File(fileName);
+        helper.setSrc(new File(fileName));
     }
 
     /**
@@ -92,7 +85,7 @@
      * @param text a component of the script text to be added.
      */
     public void addText(String text) {
-        this.text = text;
+        helper.addText(text);
     }
 
     /**
@@ -101,7 +94,7 @@
      * @param classpath an Ant Path object containing the search path.
      */
     public void setClasspath(Path classpath) {
-        createClasspath().append(classpath);
+        helper.setClasspath(classpath);
     }
 
     /**
@@ -110,10 +103,7 @@
      * @return an empty Path instance to be configured by Ant.
      */
     public Path createClasspath() {
-        if (this.classpath == null) {
-            this.classpath = new Path(getProject());
-        }
-        return this.classpath.createPath();
+        return helper.createClasspath();
     }
 
     /**
@@ -123,7 +113,7 @@
      *          value.
      */
     public void setClasspathRef(Reference r) {
-        createClasspath().setRefid(r);
+        helper.setClasspathRef(r);
     }
 
     /**
@@ -137,6 +127,6 @@
      * @param setBeans the value to set.
      */
     public void setSetBeans(boolean setBeans) {
-        this.setBeans = setBeans;
+        helper.setSetBeans(setBeans);
     }
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Mime
View raw message