开发者

Turning an ant propertyset into a fileset

I have a propertyset, where the values of the properties in the set specify a list of files I want to include in a jar. But I can't seem to figure out how to build a jar from a propertyset, only a fileset. How can I convert the values of a propertyset into an ant f开发者_高级运维ileset?


I did some work and found an approach that works. I build a comma-separated list of the property values, then pass that as the include attribute of a fileset.

<target name="buildjarfromprops">
  <!-- read list of files to include from properties -->
  <property file="files.properties"/>
  <!-- select the properties to include -->
  <propertyset id="includeFiles">
    <propertyref prefix="files."/>
  </propertyset>
  <!-- build a comma-separated list of files to include -->
  <pathconvert refid="includeFiles" pathsep="," property="includeFiles"/>
  <!-- now jar them all up -->
  <property name="sourcedir" value="/dir"/>
  <jar destfile="destjar.jar" basedir="${sourcedir}" includes="${includeFiles}"/>
</target>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜