> This looks very interesting :). Just one quick question... Why did you
>add extra 'id' attributes instead of using targets? Targets are already
>named.
Because the echo task is a task and not a target. My intention is to make
every XML element be addressable. I have gone back and committed a change
where project and target names can be used as ids.
Amidst all the discussions as to whether properties should be constants or
variables, and what delimiters should be used, I've been quietly doing a
survey of how properties have been used.
Example: cocoon's build.xml defines a property named debug, and then adds a
debug="${debug}" on the javac step. Contrast this to how the
build.compiler property is used. I'm beginning to think that a more CSS
approach is warranted.
> My reason for asking is that it is unclear what your example script
>actually does
I believe that you have correctly surmised exactly what each of the scripts
do. Given the recent less than productive discussion on related topics on
this mailing list, I'm intentially trying to be thought provoking at this
point instead of advocating a specific position.
Here's another working example, which outputs the single word false:
<?xml version="1.0"?>
<project name="test" default="main">
<target name="main">
<script language="javascript">
echoTask.setMessage(main.dependencies.hasMoreElements())
</script>
<echo id="echoTask"/>
</target>
</project>
- Sam Ruby
Will Uther <[EMAIL PROTECTED]> on 03/19/2000 01:54:22 PM
Please respond to [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
cc: [EMAIL PROTECTED]
Subject: Re: new *optional* scripting taskdef
Hi all,
--On Saturday, March 18, 2000 10:42 PM -0500 [EMAIL PROTECTED] wrote:
> OK, I've taken the plunge. I've committed a scripting task to Ant.
This looks very interesting :). Just one quick question... Why did you
add extra 'id' attributes instead of using targets? Targets are already
named.
My reason for asking is that it is unclear what your example script
actually does:
> <?xml version="1.0"?>
>
> <project name="test" default="main">
>
> <target name="main">
> <property name="welcome" value="from BSF!" />
> <echo message="hi there" id="echoTask"/>
>
> <script language="javascript">
> echoTask.setMessage(welcome)
> echoTask.execute()
> </script>
> </target>
>
> </project>
Does the echo task get run the first time time through the script? My
guess is yes. This means the output would be:
hi there
from BSF!
In order to get a task referenced in a script that should not be executed
normally you'd have to do something like:
> <?xml version="1.0"?>
>
> <project name="test" default="main">
>
> <target name="neverrun">
> <echo id="echoTask"/>
> </target>
>
> <target name="main">
> <property name="welcome" value="hi there from BSF!" />
>
> <script language="javascript">
> echoTask.setMessage(welcome)
> echoTask.execute()
> </script>
> </target>
>
> </project>
which might output (haven't tested it):
hi there from BSF!
Which brings up another point: it looks like ids are gloablly scoped.
This is fine. Just needs to be documented.
More interestingly, does this script work? And what does it output?
> <?xml version="1.0"?>
>
> <project name="test" default="main">
>
> <target name="main">
> <property name="welcome" value="from BSF!" />
>
> <script language="javascript">
> echoTask.setMessage(welcome)
> echoTask.execute()
> </script>
>
> <echo message="hi there" id="echoTask"/>
> </target>
>
> </project>
When I get back to CMU I'll have to play with this more...
later,
\x/ill :-}