Sorry, Ant properties are immutable once set. You may need use antcall within the for loop and invoke basename within the called target. Not a bug on anybody, other than my example was a little hasty.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
then I define a target named callCompile:
<target name="callCompile">
<basename property="file.filename" file="@{file}"/>
<exec
executable="compile.exe">
-o ${file.filename}"/>
</exec>
</target>
It couldn't get @{file}, Can you show me some code to let me know your opinion?
Thanks very much!
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
then I define a target named callCompile:
<target name="callCompile">
<basename property="file.filename" file="${file}"/>
<exec
executable="compile.exe">
-o ${file.filename}"/>
</exec>
</target>
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I use <for> like below:
<for param="file">
<path>
<fileset dir="${Dir_Work}">
<include name="**/*.java"/>
</fileset>
</path>
<sequential>
<exec
executable="compile.exe">
-o @{file}"/>
</exec>
</sequential>
</for>
here the @{file} I only need the file name(abc.java), but not the full path with fileName(d:/xyz/abc.java), Can you help me?
Thanks!
Use Ant's <basename> task. Something like:
<sequential>
<basename property="file.filename" file="${file}"/>
<exec executable="compile.exe">
<arg value="${file.filename}"/>
</exec>
</sequential>
Hope that is close enough to get you going.
It should be:
a0.java, b1.java, c2.java
I print the filename, it's
[echo] file.filename = a0.java
[echo] file.filename = a0.java
[echo] file.filename = a0.java
Is it a bug for ant or ant-contrib?
Sorry, Ant properties are immutable once set. You may need use antcall within the for loop and invoke basename within the called target. Not a bug on anybody, other than my example was a little hasty.
I don't understand.
I tried below:
<for param="file">
<path>
<fileset dir="${Dir_Work}">
<include name="**/*.java"/>
</fileset>
</path>
<sequential>
<antcall target="callCompile"/>
</sequential>
</for>
then I define a target named callCompile:
<target name="callCompile">
<basename property="file.filename" file="@{file}"/>
<exec
executable="compile.exe">
-o ${file.filename}"/>
</exec>
</target>
It couldn't get @{file}, Can you show me some code to let me know your opinion?
Thanks very much!
Sorry under deadline on something else right now and unable to spend any time on this.
You may need to pass @file as parameter to antcall target:
<for param="file">
<path>
<fileset dir="${Dir_Work}">
<include name="**/*.java"/>
</fileset>
</path>
<sequential>
<antcall target="callCompile">
<param name="file" value="@{file}"/>
</antcall>
</sequential>
</for>
then I define a target named callCompile:
<target name="callCompile">
<basename property="file.filename" file="${file}"/>
<exec
executable="compile.exe">
-o ${file.filename}"/>
</exec>
</target>
Get it! :D
I'm really a rookie!!
Thank you very much!!