1


I would like to create a jar file dynamically depending on selected java modules Here is the part of the ant script which does that.
<property name="modules.selected" value="A,C,F" />
<for list="${modules.selected}" param="module">
<sequential>
<echo>Module chosen ${basedir}/@{module}/src</echo>
<copy todir="${build.dir.src}" overwrite="true">
<fileset dir="${basedir}/@{module}/src">
<include name="**/*.${src.valid.exts}" />
</fileset>
</copy>
</sequential>
</for>

In the above script I am selecting a module and then constructing a directory and copying all the modules present in the directory to a location (build/src).
But I really dont like the logic mentioned above would like to change to include all the required modules in a fileset and use the populated fileset to copy.
Here is the logic I am looking for
<fileset id="required-modules" dir="${basedir}/@{module}/src">
<for list="${modules.selected}" param="module">
<sequential>
<echo>Module chosen ${basedir}/@{module}/src</echo>
<include name="**/*.${src.valid.exts}" />
</sequential>
</for>
</fileset>

<copy todir="${build.dir.src}" overwrite="true">
<fileset refid="required-modules" />
</copy>

Could anyone update the above script to make it work.

Pulak Agrawal
  • 2,481
  • 4
  • 25
  • 49
venu88
  • 41
  • 4
  • 1
    Why do you want to copy the Java source files in the first place? Why not compile them in their original location and build the jar you require from the classes compiled? And why build a single jar rather than, say, jar per module? – ewan.chalmers Nov 15 '11 at 14:06
  • I need specific modules (A,C,F) of my projects to be part of the `jar` rather than all the modules(A,B,C,D,E,F) . So I would dynamically change the modules in the property and then create a jar and then use newly created Jar. – venu88 Nov 15 '11 at 14:09
  • do you have a pattern for A,C,F ? just wondering if a regex would work. – Pulak Agrawal Aug 13 '12 at 03:18

0 Answers0