ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Scott M Stark" <Scott_St...@displayscape.com>
Subject Dynamic binding of properties
Date Thu, 05 Oct 2000 03:37:20 GMT

I tried to write an ant script that would go through an object serialization compatibility
testing suite. It is using BSF/JavaScript to try to simplify the writing of a common set
of steps shown below as the runV target. The script below does not work because
properties are bound as the xml document is parsed. Now I have looked at how
properties are handled by Ant and at first glance it does not seem that it would be
all that difficult to introduce dynamic properties, but it would require a complete
change in how properties and attributes are represented. Is this something that
could show up on a future todo list or are there ramifications that would make this
unlikely?

<?xml version="1.0" encoding="UTF-8"?>
<project name="JavaSerializationTests" default="run">
 <property name="java.proj" value="/usr/local/src/scott_home_rips/packages" />
 <property name="build.dir" value="/tmp" />
 <property name="version" value="V0" />

...

 <target name="run0">
  <script language="javascript"> <![CDATA[
   JavaSerializationTests.setProperty("version", "V0");
   runV.execute();
  ]]></script>
 </target>

 <target name="run1">
  <script language="javascript"> <![CDATA[
   JavaSerializationTests.setProperty("version", "V1");
   runV.execute();
  ]]></script>
 </target>

 <target name="runV">
  <echo message="Version = ${version}" />
  <delete file="${java.proj}/test/standards/serialization/RCIndexDef.java" />
  <copyfile src="${java.proj}/test/standards/serialization/RCIndexDef${version}.java"
dest="${java.proj}/test/standards/serialization/RCIndexDef.java" />
  <javac srcdir="${java.proj}" destdir="${build.dir}">
   <include name="test/standards/serialization/tst${version}.java" />
   <include name="test/standards/serialization/RCIndexDef.java" />
  </javac>

  <echo message="tst${version}, reading V0 object..." />
  <java classname="com.bear.racs.test.standards.serialization.tst${version}"
   fork="true" failonerror="true"
  >
   <arg value="-r" />
   <arg value="RCIndexDef_V0.ser" />
   <classpath>
    <pathelement location="${build.dir}" />
   </classpath>
  </java>

  <echo message="tst${version}, reading V1 object..." />
  <java classname="com.bear.racs.test.standards.serialization.tst${version}"
   fork="true" failonerror="true"
  >
   <arg value="-r" />
   <arg value="RCIndexDef_V1.ser" />
   <classpath>
    <pathelement location="${build.dir}" />
   </classpath>
  </java>
 </target>

</project>



Mime
View raw message