How do I convert Java class names into file paths using Ant tasks?
For example, given a property containing foo.bar.Duck
I'd like to get out foo/bar/Duck.class
.
I tried (and failed) to implement this in terms of <pathconvert>
and <regexpmapper>
.
Here's a possible way to do this:
<property name="class.name" value="foo.bar.Duck"/>
<loadresource property="file.name">
<string value="${class.name}" />
<filterchain>
<replaceregex pattern="\." replace="/" flags="g" />
<replaceregex pattern="$" replace=".class" />
</filterchain>
</loadresource>
This puts the desired foo/bar/Duck.class
into the file.name
property.
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