• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Ant Property or Fileset

 
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Mike,

I'm having problems with the Property/Fileset concept. Or, specifically, why I can't use properties to do most of what filesets do, and easier.

Example:

<property name="build.classpath"
value="classes;../other/classes;a.jar;b.jar;.">

<path id="build.classpath">
<pathelement path="classes" />
<pathelement path="../other/classes" />
<fileset dir="jars" >
<include name="a.jar" />
<include name="b.jar" />
</fileset>
</path>

Both of these appear to me to be setting a classpath variable, and the property version seems easier and more straighforward. What do you think?

Erik
 
author
Posts: 83
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The property version isn't portable across platforms. Ant doesn't know how to take the ';' in a property value and convert it to the correct classpath delimiter on the operating system. However, Ant does know how to do this with a <path>.

In other words, you could do this:



That way is more idiomatic of Ant and it guarantees better portability.

Mike
 
author
Posts: 14112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Additionally, you can use wildcards in filesets. That is, instead of

<property name="build.classpath" value="a.jar;b.jar">

you can write

<path id="build.classpath">
<fileset dir="jars" >
<include name="*.jar" />
</fileset>
</path>

and it will automatically pick up *all* the jar files in the jars directory. No need to change the build script when you add or remove a jar!
 
Ranch Hand
Posts: 1312
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In my work, i'm use fileset tag.



 
Skool. Stay in. Smartness. Tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic