Executing Gradle task unknown times in loop

(Mohan Raj) #1

My project’s ANT target(mkisofsInstaller) generates ISO images based on the CD disks available. i.e. The target runs for n times with each time a parameter mkisofs.dir which holds the path of disks. Please find the code below.

<target name="generateISO" depends="init">
      <foreach target="mkisofsInstaller" param="mkisofs.dir" inheritall="true">
            <dirset dir="${build.home}\CDROM_Installers">
               <include name="disk*"/>
     <target name="mkisofsInstaller">
  <propertyfile file="${build.diskimages}/disk.number">
         <entry key="mkisofs.disk.number" type="int" operation="+" default="0"/>
  <echo message="Copying documentation to disk 1"/>
  <copy todir="${mkisofs.dir}/Documents">
     <fileset dir="${build.lib.documents}">
     <include name="*.pdf"/>
                   <echo message="Creating disk image of dir: ${mkisofs.dir}"/>
      <exec dir="${basedir}" executable="mkisofs" failonerror="true">
         <arg value="-l"/>
         <arg value="-J"/>
         <arg value="-R"/>
         <arg value="-r"/>
         <arg value="-VInstaller${mkisofs.disk.number}"/>
         <arg value="-o${build.diskimages}/Installer${mkisofs.disk.number}.iso"/>
         <arg value="${mkisofs.dir}"/>

I am trying to gradilize the below targets to Gradle tasks where I face difficulty in executing a task in loop.

I tried an option of creating task rules, but I do not know how to pass path as parameter

and also not sure how much time this task needs to called(as there are around 8 to 10 CD disks).

Kindly help!

Thanks, Mohan