Steve or anyone else: Let me know if you feel this change is too risky; it just seemed intuitive to me.
br, Matt --- [EMAIL PROTECTED] wrote: > Author: mbenson > Date: Thu Jun 28 08:14:04 2007 > New Revision: 551592 > > URL: > http://svn.apache.org/viewvc?view=rev&rev=551592 > Log: > <scriptcondition> now prefers evaluation > result/return value over value property. > > Modified: > ant/core/trunk/WHATSNEW > > ant/core/trunk/src/main/org/apache/tools/ant/types/optional/AbstractScriptComponent.java > > ant/core/trunk/src/main/org/apache/tools/ant/types/optional/ScriptCondition.java > > ant/core/trunk/src/tests/antunit/types/scriptcondition-test.xml > > Modified: ant/core/trunk/WHATSNEW > URL: > http://svn.apache.org/viewvc/ant/core/trunk/WHATSNEW?view=diff&rev=551592&r1=551591&r2=551592 > ============================================================================== > --- ant/core/trunk/WHATSNEW (original) > +++ ant/core/trunk/WHATSNEW Thu Jun 28 08:14:04 2007 > @@ -14,6 +14,8 @@ > been modified to encode outgoing (InputStream) > content as well as encoding > incoming (OutputStream) content. > > +* <scriptcondition> now prefers evaluation > result/return value over value property. > + > Fixed bugs: > ----------- > * Regression: Locator fails with URI encoding > problem when spaces in path > > Modified: > ant/core/trunk/src/main/org/apache/tools/ant/types/optional/AbstractScriptComponent.java > URL: > http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/types/optional/AbstractScriptComponent.java?view=diff&rev=551592&r1=551591&r2=551592 > ============================================================================== > --- > ant/core/trunk/src/main/org/apache/tools/ant/types/optional/AbstractScriptComponent.java > (original) > +++ > ant/core/trunk/src/main/org/apache/tools/ant/types/optional/AbstractScriptComponent.java > Thu Jun 28 08:14:04 2007 > @@ -17,6 +17,8 @@ > */ > package org.apache.tools.ant.types.optional; > > +import java.io.File; > + > import org.apache.tools.ant.Project; > import org.apache.tools.ant.ProjectComponent; > import org.apache.tools.ant.types.Path; > @@ -24,9 +26,6 @@ > import org.apache.tools.ant.util.ScriptRunnerBase; > import > org.apache.tools.ant.util.ScriptRunnerHelper; > > - > -import java.io.File; > - > /** > * This is a [EMAIL PROTECTED] ProjectComponent} that has > script support built in > * Use it as a foundation for scriptable things. > @@ -140,5 +139,14 @@ > */ > protected void executeScript(String execName) { > getRunner().executeScript(execName); > + } > + > + /** > + * Evaluate a script. > + * @param execName name of the script. > + * @return the result of the evaluation. > + */ > + protected Object evaluateScript(String > execName) { > + return > getRunner().evaluateScript(execName); > } > } > > Modified: > ant/core/trunk/src/main/org/apache/tools/ant/types/optional/ScriptCondition.java > URL: > http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/types/optional/ScriptCondition.java?view=diff&rev=551592&r1=551591&r2=551592 > ============================================================================== > --- > ant/core/trunk/src/main/org/apache/tools/ant/types/optional/ScriptCondition.java > (original) > +++ > ant/core/trunk/src/main/org/apache/tools/ant/types/optional/ScriptCondition.java > Thu Jun 28 08:14:04 2007 > @@ -33,7 +33,6 @@ > */ > private boolean value = false; > > - > /** > * Is this condition true? > * > @@ -44,8 +43,8 @@ > */ > public boolean eval() throws BuildException { > initScriptRunner(); > - executeScript("ant_condition"); > - return getValue(); > + Object result = > evaluateScript("ant_condition"); > + return result instanceof Boolean ? > ((Boolean) result).booleanValue() : getValue(); > } > > /** > > Modified: > ant/core/trunk/src/tests/antunit/types/scriptcondition-test.xml > URL: > http://svn.apache.org/viewvc/ant/core/trunk/src/tests/antunit/types/scriptcondition-test.xml?view=diff&rev=551592&r1=551591&r2=551592 > ============================================================================== > --- > ant/core/trunk/src/tests/antunit/types/scriptcondition-test.xml > (original) > +++ > ant/core/trunk/src/tests/antunit/types/scriptcondition-test.xml > Thu Jun 28 08:14:04 2007 > @@ -70,4 +70,87 @@ > </scriptcondition> > </f> > </target> > + > + <target name="testBeanshellReturnTrue"> > + <t message="testBeanshellReturnTrue"> > + <scriptcondition language="beanshell" > value="false"> > + return true; > + </scriptcondition> > + </t> > + </target> > + > + <target name="testBeanshellReturnFalse"> > + <f message="testBeanshellReturnFalse"> > + <scriptcondition language="beanshell" > value="true"> > + return false; > + </scriptcondition> > + </f> > + </target> > + > + <target name="testBeanshellReturnOverridesValue"> > + <f message="testBeanshellReturnOverridesValue"> > + <scriptcondition language="beanshell" > value="false"> > + self.setValue(true); > + return false; > + </scriptcondition> > + </f> > + </target> > + > + <target name="testBeanshellReturnNullIgnored"> > + <t message="testBeanshellReturnNullIgnored"> > + <scriptcondition language="beanshell" > value="true"> > + return null; > + </scriptcondition> > + </t> > + </target> > + > + <target > name="testBeanshellReturnNonBooleanIgnored"> > + <t > message="testBeanshellReturnNonBooleanIgnored"> > + <scriptcondition language="beanshell" > value="true"> > + return 20; > + </scriptcondition> > + </t> > + </target> > + > + <target name="testJsReturnTrue"> > + <t message="testJsReturnTrue"> > + <scriptcondition language="javascript" > value="false"> > + java.lang.Boolean.TRUE > + </scriptcondition> > + </t> > + </target> > + > + <target name="testJsReturnFalse"> > + <f message="testJsReturnFalse"> > + <scriptcondition language="javascript" > value="true"> > + java.lang.Boolean.FALSE > + </scriptcondition> > + </f> > + </target> > + > + <target name="testJsReturnOverridesValue"> > + <f message="testJsReturnOverridesValue"> > + <scriptcondition language="javascript" > value="false"> > + self.setValue(true); > + false > + </scriptcondition> > + </f> > + </target> > + > + <target name="testJsReturnNullIgnored"> > + <t message="testJsReturnNullIgnored"> > + <scriptcondition language="javascript" > value="true"> > + null > + </scriptcondition> > + </t> > + </target> > + > + <target name="testJsReturnNonBooleanIgnored"> > + <t message="testJsReturnNonBooleanIgnored"> > + <scriptcondition language="javascript" > value="true"> > + new java.lang.Integer(20) > + </scriptcondition> > + </t> > + </target> > + > </project> > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: > [EMAIL PROTECTED] > For additional commands, e-mail: > [EMAIL PROTECTED] > > ____________________________________________________________________________________ Be a better Heartthrob. Get better relationship answers from someone who knows. Yahoo! Answers - Check it out. http://answers.yahoo.com/dir/?link=list&sid=396545433 --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]