In folder, src, I have a set of subfolders with java source code:
/a/A.java
/a/b/B.java
/a/b/c/C.java
I need a property with the following value:
src/a/A.java,src/a/b/B.java,src/a/b/c/C.java
I tried the following:
<pathconvert property="list-of-files">
<globmapper from="*" to="src/*"/>
<fileset dir=${src-folder}/>
</pathconvert>
but I end up with the following value on my property:
src/full/path/to/folder_a/a/A.java,src/full/path/to/folder_a/a/b/B.java,src/full/path/to/folder_a/a/b/c/C.java
How can I accomplish what I want? Any input is appreciated!
You can use the map
parameter of pathconvert for this.
First get the full path to your src dir by appending its path to the value of the basedir
property. Then use that as the from
attribute of your map.
<property name="src.dir" value="${basedir}${file.separator}${src-folder}"/>
<pathconvert property="list-of-files">
<map from="${src.dir}" to="src"/>
<fileset dir="${src-folder}"/>
</pathconvert>
Just in case if someone needs to get relative file paths of resources and map them to URL paths accordingly, so it works both on Windows and *nix the solution is:
<pathconvert dirsep="/" pathsep=";" property="css.files.list">
<map from="${basedir}/" to="" /><!-- This is the trick. Remove slash to make path absolute. -->
<fileset dir="." includes="${src.dir}/**/*.css" />
</pathconvert>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With