What I m trying to do is compile to a file which takes it s version from a constant inside my source files.
I have a setup like this (or at least the significant bits):
tasks/compile.xml
<project name="Compile">
<target name="check.version">
<script language="javascript">
regex = /VERSION.+?"([d.]+)";/;
r = new java.io.BufferedReader(new java.io.FileReader(new java.io.File(file)));
line = r.readLine();
while ( (line = r.readLine()) != null) {
m = regex.exec(line);
if (m) {
project.setProperty( "project.version" , m[1] );
break;
}
}
r.close();
</script>
<echo>${ant.project.name}-${project.version}</echo> <!-- = Fail-0.2 -->
</target>
</project>
And a build.xml:
<project name="Fail">
<import file="${basedir}/build/tasks/compile.xml"/>
<target name="test">
<antcall target="check.version">
<param name="file" value="${basedir}/Source.as"/>
</antcall>
<echo>${project.version}</echo> <!-- = ${project.version} -->
<echoproperties></echoproperties>
</target>
</project>
So, it seems that the property set by the script is only locally defined in that target, if i specify another target in the same project ("Compile") it won t know of that property either.
I ve also tried to set a in the "Compile"-project xml but it won t be overwritten by the target anyway.
So how can I access that property generated by the script? Or is there another way for doing something like this?
I d really like to keep that part in a separate xml as it makes the project build script so much cleaner.
Thanks!