--- Scott Goldstein <[EMAIL PROTECTED]> wrote:
> After finding a .jar file conflict, I finally got the script task to
> work using javascript.
> 
> However, I'm having problems getting and setting system properties.
> 
> First, I'm trying to get properties using System.getProperty().  I can 
> successfully get the "user.dir" property, but I can't get the "basedir" 
> property.  In addition, I can't get any properties that I set within the
> same target.

"basedir" isn't a system property -- it's an Ant property. Same with any
properties you set. You need to use Ant's getProperty().

> Secondly, I can't set a property for later access.

You need to use Ant's setProperty().

For example:
  <target name="testscript">
    <property name="somefoo" value="somefoo"/>
    <taskdef name="script"
             classname="org.apache.tools.ant.taskdefs.optional.Script"/>
    <script language="javascript"> <![CDATA[
      getprop = projname.getProperty("somefoo")
      setprop = projname.setProperty("somebar", "somebar")
      showit = projname.createTask("echo");
      showit.setMessage(getprop) ;
      showit.execute() ;
      showit = projname.createTask("echo");
      showit.setMessage(projname.getProperty("somebar")) ;
      showit.execute() ;
      showit = projname.createTask("echo");
      showit.setMessage(projname.getProperty("basedir")) ;
      showit.execute() ;
      ]]>
    </script>
  </target>

  <target name="reshow">
    <echo message="somebar is ${somebar}"/>
  </target>

$ ant testscript reshow
testscript:
     [echo] somefoo
     [echo] somebar
     [echo] D:\cygwin\home\dianeh\work\ant

reshow:
     [echo] somebar is somebar

Hope this helps,
Diane

=====
([EMAIL PROTECTED])



__________________________________________________
Do You Yahoo!?
Get email alerts & NEW webcam video instant messaging with Yahoo! Messenger
http://im.yahoo.com

Reply via email to