cuzyoo
cuzyoo

Reputation: 67

Ant property set to files inside given directory

I'm working on an ant-build script and got a given variable with the path of a directory. I now want to get all these files inside this directory with a separator (like ';') and use it as a property.

<property name="connectivity.additional.jars" value="${connectivity.additional.jars.dir}" />

I tried it with filesets, but I'm not sure if this is the correct approach and how I would set this as a property / or even concat the filenames...

<fileset dir="${connectivity.additional.jars.dir}">
  <include name="**/*.jar"/>
</fileset>

Upvotes: 0

Views: 992

Answers (1)

Rebse
Rebse

Reputation: 10377

Using a fileset with id is the right approach. Use it combined with ant builtin properties ${ant.refid:filesetid} or ${toString:filesetid}, f.e. :

<project>
<fileset dir="c:/WKS/gradle-2.4/lib" id="foo">
  <include name="**/*.jar"/>
</fileset>

<property name="foobar" value="${toString:foo}"/>
<!-- or -->
<property name="foobar" value="${ant.refid:foo}"/>   
</project>

${ant.refid:xxx} or ${toString:main.xxx} is a csv property with ';' as default separator, see Ant manual Properties and PropertyHelpers.

Upvotes: 1

Related Questions