@@ -101,9 +101,9 @@ In particular all targets should have different location values.</p> | |||||
<tr> | <tr> | ||||
<td>setbeans</td> | <td>setbeans</td> | ||||
<td>This attribute controls whether to set variables for all properties, references and targets | <td>This attribute controls whether to set variables for all properties, references and targets | ||||
in the running script. If this attribute is <q>false</q>, only the the <code>project</code> | |||||
and <code>self</code> variables are set. If this attribute is <q>true</q> all the variables | |||||
are set. <em>Since Ant 1.7</em></td> | |||||
in the running script. If this attribute is <q>false</q>, only the <code>project</code> and | |||||
<code>self</code> variables are set. If this attribute is <q>true</q> all the variables are | |||||
set. <em>Since Ant 1.7</em></td> | |||||
<td>No; defaults to <q>true</q></td> | <td>No; defaults to <q>true</q></td> | ||||
</tr> | </tr> | ||||
<tr> | <tr> | ||||
@@ -132,6 +132,14 @@ the <a href="script.html"><code><script></code></a> task.</p> | |||||
</td> | </td> | ||||
<td>No</td> | <td>No</td> | ||||
</tr> | </tr> | ||||
<tr> | |||||
<td>setbeans</td> | |||||
<td>This attribute controls whether to set variables for all properties, references and targets | |||||
in the running script. If this attribute is <q>false</q>, only the <code>project</code> and | |||||
<code>self</code> variables are set. If this attribute is <q>true</q> all the variables are | |||||
set. | |||||
<td>No; default <q>false</q> for backward compatibility</td> | |||||
</tr> | |||||
</table> | </table> | ||||
<h3>Parameters specified as nested elements</h3> | <h3>Parameters specified as nested elements</h3> | ||||
@@ -67,6 +67,13 @@ public class ScriptDef extends DefBase { | |||||
/** The nested element definitions indexed by their names */ | /** The nested element definitions indexed by their names */ | ||||
private Map<String, NestedElement> nestedElementMap; | private Map<String, NestedElement> nestedElementMap; | ||||
/** | |||||
* Create a new {@link ScriptDef}. | |||||
*/ | |||||
public ScriptDef() { | |||||
helper.setSetBeans(false); | |||||
} | |||||
/** | /** | ||||
* Set the project. | * Set the project. | ||||
* @param project the project that this definition belongs to. | * @param project the project that this definition belongs to. | ||||
@@ -75,7 +82,6 @@ public class ScriptDef extends DefBase { | |||||
public void setProject(Project project) { | public void setProject(Project project) { | ||||
super.setProject(project); | super.setProject(project); | ||||
helper.setProjectComponent(this); | helper.setProjectComponent(this); | ||||
helper.setSetBeans(false); | |||||
} | } | ||||
/** | /** | ||||
@@ -447,6 +453,20 @@ public class ScriptDef extends DefBase { | |||||
helper.setEncoding(encoding); | helper.setEncoding(encoding); | ||||
} | } | ||||
/** | |||||
* Set the setbeans attribute. | |||||
* If this is true, <script> will create variables in the | |||||
* script instance for all | |||||
* properties, targets and references of the current project. | |||||
* It this is false, only the project and self variables will | |||||
* be set. | |||||
* The default is true. | |||||
* @param setBeans the value to set. | |||||
*/ | |||||
public void setSetBeans(boolean setBeans) { | |||||
helper.setSetBeans(setBeans); | |||||
} | |||||
/** | /** | ||||
* Sets the script text. | * Sets the script text. | ||||
* | * | ||||
@@ -155,4 +155,14 @@ | |||||
<scripttest foo="bar" /> | <scripttest foo="bar" /> | ||||
</au:expectfailure> | </au:expectfailure> | ||||
</target> | </target> | ||||
<target name="testSetbeans" if="prereqs-ok"> | |||||
<js setbeans="true"> | |||||
project.setNewProperty('property', sourceProperty) | |||||
</js> | |||||
<property name="sourceProperty" value="live" /> | |||||
<scripttest /> | |||||
<assertPropSet /> | |||||
</target> | |||||
</project> | </project> |