How to modify filename within <foreach> task

  • Aaron Stromas
    Aaron Stromas


    Although I've been using Ant for some time, it was for simple things, and now I'm stumped.

    basically, I heve several se\ts of directury structures containing jars which I need to sign,  The signed jars have to go in the "signed" subdirectory of the directory containing the jar that is being signed.
    I'm using the <foreach> task to iterate over the directory sets.
    target that does the signing I have access to the file path of the jar being signed and the directory in whichit lives, e.g,,
    /a/b/c/some.jar and /a/b/c.
    What I cannot figure out is how to create the path /a/b/c/signed/some.jar.

    Since I'm in a loop I can't use named properties. The signjar tasl does not allow structured tasks for  any of its attributes...

    If someone has a suggestion, I'll be much obliged. TIA.


    • John Hopkins
      John Hopkins

      In the target which foreach calls, perhaps you can use the 'dirname' task which determines the directory path of a specified file.  Append "/signed" and "/some.jar".

    • Matt Inger
      Matt Inger

      <target name="sign.jar">
         <dirname property="jar.dir" file="${jar.path}" />
         <basename property="" file="${}" />

         <property name="signed.jar.path"
             location="${jar.path}/signed/${}" />

          <!-- sign the jar here -->