ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stefan Bodewig <bode...@bost.de>
Subject Re: Why Properties became immutable
Date Fri, 21 Jul 2000 11:34:04 GMT
>>>>> "PD" == Peter Donald <donaldp@mad.scientist.com> writes:

 PD> Well strickly speaking I don't think we need it once we have
 PD> scripting.

We have. 

The example I've posted works with release 1.1 once you have BSF and
Rhino installed. Getting BSF might be kind of a problem at the moment
due to some oddities of their website though.

 PD> However it [...] should also be less resource hungry.

Agreed.

 PD> <template-target name="template-blah"> 
 PD>   <with-param name="someClasspath" /> 
 PD>   <with-param name="someVariable" />

 PD>   <java classpath="${someClasspath}" ... /> 
 PD>   <taskA ... /> 
 PD>   <taskB ... />

 PD> </template-target>

 PD> <target name="blah" template="template-blah" > 
 PD>   <with-param name="someClasspath" value="myJar.jar" /> 
 PD>   <with-param name="someVariable" value="1"/> 
 PD> </target>


 PD> However I figure that would be shouted down because it *could* be
 PD> complex.

Hmm, this is not my main problem, but also that I don't think we need
a fifth way to achieve that. 

[I'm now going to demonstrate four ways, three of them already
possible - don't read on if not interested.]

<target name="template_blah">
  <java id="template_blah_javac"
        classpath="${propertyname-with-no-value-in-project}" />
</target>

<target name="blah">
  <ant target="template_blah" antfile="${ant.file}">
    <property name="propertyname-with-no-value-in-project" value="myJar.jar" />
  </ant>
</target>

is possible (the dir attribute defaults to "."). Maybe add ant-call
with a nested param instead of property and neither dir nor antfile
attributes.

<target name="blah">
  <ant-call target="template_blah">
    <param name="propertyname-with-no-value-in-project" value="myJar.jar" />
  </ant-call>
</target>

Should be quite readable and is even less verbose than the XSLT like
way.

<target name="blah">
  <script><![CDATA[
    template_blah_javac.setClasspath("myJar.jar");
    template_blah.execute();
  ]]></script>
</target>

doesn't necessary use more resources as it runs in the same project
and doesn't use a sub build. It might be less readable and be saved
for more difficult cases, as well as

<taskdef name="call_blah_template" classname="CallBlah" />
<target name="blah">
  <call_blah_template classpath="myJar.jar" />
</target>

with CallBlah.java

public class CallBlah {
    private Path classpath;

    public void setClasspath(Path p) {
        classpath = p;
    }

    public void execute throws BuildException {
        Javac j = (Javac) project.getReferences().get("template_blah_javac");
        j.setClasspath(classpath);
        Target t = (Target) project.getTargets().get("template_blah");
        t.execute();
    }
}

Mime
View raw message