Ant: how can I interact in all subfolders and complete a task in ant

I'm currently doing

<foreach list="${myfolders}" target="bundle" param="worksheet" inheritall="true"/> 

Run the target package in the folder list. However, the problem is that I need to install this list. How to use Ant to simply iterate over all folders specified by the parent directory?

If there is a way to do this, and also exclude specific folders that would be even better. Thanks.

+6
source share
3 answers

You can provide <dirset> for the <foreach> task to work:

  <foreach target="bundle" param="worksheet" inheritall="true"> <path> <dirset dir="${subDir}"> <include name="*"/> </dirset> </path> </foreach> 

Note that the list parameter is not used when I do it this way.

You cannot use <dirset> directly under <foreach> as you can with <fileset> . However, you can put <dirset> under the <path> as shown above. <include name="*"/> prevents directory tree recursion.

+8
source

You can do it with subant

Example:

 <?xml version="1.0" encoding="UTF-8"?> <project name="subant" default="subant1"> <target name="subant1"> <subant target=""> <dirset dir="." includes="*"/> <target name="release" /> </subant> </target> </project> 
0
source

I am using the foreach task from ant-contrib for similar work. This will trigger the target for each entry in the list, passing the entry as a parameter each time.

-1
source

Source: https://habr.com/ru/post/889876/


All Articles