ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From peterrei...@apache.org
Subject svn commit: r481971 - /ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/script/ScriptDef.java
Date Sun, 03 Dec 2006 22:56:41 GMT
Author: peterreilly
Date: Sun Dec  3 14:56:40 2006
New Revision: 481971

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

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

Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/script/ScriptDef.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/script/ScriptDef.java?view=diff&rev=481971&r1=481970&r2=481971
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/script/ScriptDef.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/script/ScriptDef.java Sun
Dec  3 14:56:40 2006
@@ -36,7 +36,8 @@
 import java.io.File;
 
 import org.apache.tools.ant.util.ClasspathUtils;
-import org.apache.tools.ant.util.optional.ScriptRunner;
+import org.apache.tools.ant.util.ScriptRunnerBase;
+import org.apache.tools.ant.util.ScriptRunnerHelper;
 
 /**
  * Define a task using a script
@@ -44,8 +45,15 @@
  * @since Ant 1.6
  */
 public class ScriptDef extends DefBase {
+    /**
+     * script runner helper
+     */
+    private ScriptRunnerHelper helper = new ScriptRunnerHelper();
+    /**
+     * script runner.
+     */
     /** Used to run the script */
-    private ScriptRunner runner = new ScriptRunner();
+    private ScriptRunnerBase   runner = null;
 
     /** the name by which this script will be activated */
     private String name;
@@ -63,6 +71,16 @@
     private Map nestedElementMap;
 
     /**
+     * Set the project.
+     * @param project the project that this def belows to.
+     */
+    public void setProject(Project project) {
+        super.setProject(project);
+        helper.setProjectComponent(this);
+        helper.setSetBeans(false);
+    }
+
+    /**
      * set the name under which this script will be activated in a build
      * file
      *
@@ -174,11 +192,19 @@
                 + "name the script");
         }
 
-        if (runner.getLanguage() == null) {
+        if (helper.getLanguage() == null) {
             throw new BuildException("<scriptdef> requires a language attribute "
                 + "to specify the script language");
         }
 
+        // Check if need to set the loader
+        if (getAntlibClassLoader() != null || hasCpDelegate()) {
+            helper.setClassLoader(createLoader());
+        }
+
+        // Now create the scriptRunner
+        runner = helper.getScriptRunner();
+
         attributeSet = new HashSet();
         for (Iterator i = attributes.iterator(); i.hasNext();) {
             Attribute attribute = (Attribute) i.next();
@@ -321,6 +347,14 @@
         runner.executeScript("scriptdef_" + name);
     }
 
+    /**
+     * Defines the manager.
+     *
+     * @param manager the scripting manager.
+     */
+    public void setManager(String manager) {
+        helper.setManager(manager);
+    }
 
     /**
      * Defines the language (required).
@@ -328,7 +362,7 @@
      * @param language the scripting language name for the script.
      */
     public void setLanguage(String language) {
-        runner.setLanguage(language);
+        helper.setLanguage(language);
     }
 
     /**
@@ -337,7 +371,7 @@
      * @param file the file containing the script source.
      */
     public void setSrc(File file) {
-        runner.setSrc(file);
+        helper.setSrc(file);
     }
 
     /**
@@ -346,7 +380,7 @@
      * @param text a component of the script text to be added.
      */
     public void addText(String text) {
-        runner.addText(text);
+        helper.addText(text);
     }
 }
 



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


Mime
View raw message