looping in ant scripts

Discussion in 'Java' started by sri, Dec 20, 2004.

  1. sri

    sri Guest

    this is the target in ant script to create a single jar file for a
    module

    <target name="deployjar">
    <jar jarfile="${deploy}/PTS${moduleTitle}-${DSTAMP}-${TSTAMP}.jar" >
    <fileset dir="${build}" >
    <exclude name="${web}/**/*.*" />
    </fileset>

    <fileset dir="${src}\ejb\${moduleName}\META-INF" />
    </jar>
    </target>

    the problem is i have 10 such modules
    should i repeat this script for each of the 10 modules to create 10 jar
    files or
    is there some way to loop or invoke the target with different module
    names
    and create different jar with different module titles
    if there is a way how can we pass different property values for each
    invocation?
    sri, Dec 20, 2004
    #1
    1. Advertising

  2. sri wrote:

    > this is the target in ant script to create a single jar file for a
    > module


    [...]

    > is there some way to loop or invoke the target with different module
    > names
    > and create different jar with different module titles
    > if there is a way how can we pass different property values for each
    > invocation?


    Ant 1.6 has a macro feature that might get you where you want to go. If
    you're using 1.6 then look up <MacroDef> among the core tasks.


    John Bollinger
    John C. Bollinger, Dec 20, 2004
    #2
    1. Advertising

  3. sri

    sri Guest

    this is the way i solved the problem using macrodef task


    <macrodef name="testing">
    <attribute name="moduleName" default="maintainrole"/>
    <attribute name="moduleTitle" default="maintainrole"/>
    <sequential>
    <jar jarfile="${deploy}/PTS@{moduleTitle}-${DSTAMP}-${TSTAMP}.jar" >
    <fileset dir="${build}" >
    <exclude name="com/xxx/pms/web/" />
    <include name="com/xxx/pms/ejb/@{moduleName}/**/*.*"/>
    <include name="com/xxx/pms/lib/@{moduleName}/**/*.*"/>
    </fileset>

    <fileset dir="${src}/ejb/@{moduleName}" >
    <include name="**/*.xml" />
    </fileset>

    </jar>
    </sequential>
    </macrodef>


    <testing moduleName="maintainrole" moduleTitle="RoleModule">
    </testing>

    <testing moduleName="maintainactivity" moduleTitle="ActivityModule">
    </testing>


    thanks for ur reply john thanks for helping me out
    sri, Dec 21, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Chris Bedford
    Replies:
    6
    Views:
    2,205
  2. john martin
    Replies:
    2
    Views:
    2,195
    john martin
    Apr 7, 2005
  3. Replies:
    1
    Views:
    475
    Larry
    Mar 7, 2006
  4. Replies:
    6
    Views:
    845
  5. Replies:
    5
    Views:
    255
Loading...

Share This Page