You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by pe...@apache.org on 2004/07/07 10:32:02 UTC
cvs commit: ant/src/main/org/apache/tools/ant/taskdefs/optional/script ScriptDefBase.java ScriptDef.java
peterreilly 2004/07/07 01:32:02
Modified: docs/manual/OptionalTasks scriptdef.html
src/main/org/apache/tools/ant/taskdefs/optional/script
ScriptDefBase.java ScriptDef.java
Log:
add a "self" reference for scriptdef
Revision Changes Path
1.6 +9 -6 ant/docs/manual/OptionalTasks/scriptdef.html
Index: scriptdef.html
===================================================================
RCS file: /home/cvs/ant/docs/manual/OptionalTasks/scriptdef.html,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- scriptdef.html 23 Apr 2004 14:26:47 -0000 1.5
+++ scriptdef.html 7 Jul 2004 08:32:02 -0000 1.6
@@ -41,11 +41,14 @@
to use "someattribute" to retrieve the attribute's value from the
<code>attributes</code> collection.</p>
+ <p>The name "self" (<i>since Ant 1.6.3</i>) is a pre-defined reference to the script def task instance.
+ It can be used for logging purposes</p>
<p>The name "project" is a pre-defined reference to the Ant Project. For
more information on writing scripts, please refer to the
<a href="script.html"><script></a> task
</p>
+
<h3>Parameters</h3>
<table border="1" cellpadding="2" cellspacing="0">
<tr>
@@ -133,9 +136,9 @@
<element name="path" type="path"/>
<![CDATA[
- project.log("Hello from script");
- project.log("Attribute attr1 = " + attributes.get("attr1"));
- project.log("First fileset basedir = "
+ self.log("Hello from script");
+ self.log("Attribute attr1 = " + attributes.get("attr1"));
+ self.log("First fileset basedir = "
+ elements.get("fileset").get(0).getDir(project));
]]>
@@ -159,9 +162,9 @@
<element name="fileset" type="fileset"/>
<![CDATA[
filesets = elements.get("fileset");
- project.log("Number of filesets = " + filesets.size());
+ self.log("Number of filesets = " + filesets.size());
for (i = 0; i < filesets.size(); ++i) {
- project.log("fileset " + i + " basedir = "
+ self.log("fileset " + i + " basedir = "
+ filesets.get(i).getDir(project));
}
]]>
@@ -192,4 +195,4 @@
Reserved.</p>
</body>
-</html>
\ No newline at end of file
+</html>
1.11 +1 -1 ant/src/main/org/apache/tools/ant/taskdefs/optional/script/ScriptDefBase.java
Index: ScriptDefBase.java
===================================================================
RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/optional/script/ScriptDefBase.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- ScriptDefBase.java 9 Mar 2004 16:48:35 -0000 1.10
+++ ScriptDefBase.java 7 Jul 2004 08:32:02 -0000 1.11
@@ -44,7 +44,7 @@
* control to it
*/
public void execute() {
- getScript().executeScript(attributes, nestedElementMap);
+ getScript().executeScript(attributes, nestedElementMap, this);
}
private ScriptDef getScript() {
1.14 +18 -1 ant/src/main/org/apache/tools/ant/taskdefs/optional/script/ScriptDef.java
Index: ScriptDef.java
===================================================================
RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/optional/script/ScriptDef.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- ScriptDef.java 23 Apr 2004 14:18:15 -0000 1.13
+++ ScriptDef.java 7 Jul 2004 08:32:02 -0000 1.14
@@ -307,13 +307,30 @@
* Execute the script.
*
* @param attributes collection of attributes
- *
* @param elements a list of nested element values.
+ * @deprecated use executeScript(attribute, elements, instance) instead
*/
public void executeScript(Map attributes, Map elements) {
runner.addBean("attributes", attributes);
runner.addBean("elements", elements);
runner.addBean("project", getProject());
+ runner.executeScript("scriptdef_" + name);
+ }
+
+ /**
+ * Execute the script.
+ * This is called by the script instance to execute the script for this
+ * definition.
+ *
+ * @param attributes collection of attributes
+ * @param elements a list of nested element values.
+ * @param instance the script instance
+ */
+ public void executeScript(Map attributes, Map elements, ScriptDefBase instance) {
+ runner.addBean("attributes", attributes);
+ runner.addBean("elements", elements);
+ runner.addBean("project", getProject());
+ runner.addBean("self", self);
runner.executeScript("scriptdef_" + name);
}
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org