Browse Source

scriptdef += @setbeans

master
Matt Benson 3 years ago
parent
commit
c4552aaaf2
4 changed files with 42 additions and 4 deletions
  1. +3
    -3
      manual/Tasks/script.html
  2. +8
    -0
      manual/Tasks/scriptdef.html
  3. +21
    -1
      src/main/org/apache/tools/ant/taskdefs/optional/script/ScriptDef.java
  4. +10
    -0
      src/tests/antunit/taskdefs/optional/script/scriptdef-test.xml

+ 3
- 3
manual/Tasks/script.html View File

@@ -101,9 +101,9 @@ In particular all targets should have different location values.</p>
<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 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>
</tr>
<tr>


+ 8
- 0
manual/Tasks/scriptdef.html View File

@@ -132,6 +132,14 @@ the <a href="script.html"><code>&lt;script&gt;</code></a> task.</p>
</td>
<td>No</td>
</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>

<h3>Parameters specified as nested elements</h3>


+ 21
- 1
src/main/org/apache/tools/ant/taskdefs/optional/script/ScriptDef.java View File

@@ -67,6 +67,13 @@ public class ScriptDef extends DefBase {
/** The nested element definitions indexed by their names */
private Map<String, NestedElement> nestedElementMap;

/**
* Create a new {@link ScriptDef}.
*/
public ScriptDef() {
helper.setSetBeans(false);
}

/**
* Set the project.
* @param project the project that this definition belongs to.
@@ -75,7 +82,6 @@ public class ScriptDef extends DefBase {
public void setProject(Project project) {
super.setProject(project);
helper.setProjectComponent(this);
helper.setSetBeans(false);
}

/**
@@ -447,6 +453,20 @@ public class ScriptDef extends DefBase {
helper.setEncoding(encoding);
}

/**
* Set the setbeans attribute.
* If this is true, &lt;script&gt; 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.
*


+ 10
- 0
src/tests/antunit/taskdefs/optional/script/scriptdef-test.xml View File

@@ -155,4 +155,14 @@
<scripttest foo="bar" />
</au:expectfailure>
</target>

<target name="testSetbeans" if="prereqs-ok">
<js setbeans="true">
project.setNewProperty('property', sourceProperty)
</js>
<property name="sourceProperty" value="live" />
<scripttest />
<assertPropSet />
</target>

</project>

Loading…
Cancel
Save