FAQ
Hello,

I have a target that transforms files XCF into PNG by calling the "convert" command.
I would like that this target does not execute if source files (i.e., the XCF files ) have changed.
I have tried with the "uptodate" task but it does not work.
Each time I run ant, the "convert" command is called.

Any idea ?

Thank you.
Best regards.

This is my build.xml file:
<project name="xcf2png" default="png">
  <target name="png-check">
   <uptodate property="png-uptodate" targetfile="png/**.*.png">
    <srcfiles dir= "xcf" includes="**/*.xcf"/>
   </uptodate>
  </target>
  <target name="png" depends="png-check" unless="png-uptodate">
   <mkdir dir="png"/>
   <exec executable="convert">
    <arg value="-verbose"/>
    <arg value="-alpha"/>
    <arg value="on"/>
    <arg value="-background"/>
    <arg value="none"/>
    <arg value="-layers"/>
    <arg value="merge"/>
    <arg value="xcf/icon.xcf"/>
    <arg value="png/icon.png"/>
   </exec>
  </target>
  <target name="clean">
   <delete dir="png"/>
  </target>
</project>

This is the result in the console:
$ ant
Buildfile: /home/yugiohjcj/xcf2png/build.xml

png-check:

png:
      [exec] xcf/icon.xcf[0] XCF 32x32 32x32+0+0 8-bit sRGB 1.21KB 0.000u 0:00.000
      [exec] xcf/icon.xcf[0] XCF 6x21 6x21+13+6 8-bit sRGB 0.000u 0:00.000
      [exec] xcf/icon.xcf=>png/icon-0.png[0] XCF 32x32 32x32+0+0 8-bit sRGB 1c 255B 0.000u 0:00.089
      [exec] xcf/icon.xcf=>png/icon-1.png[1] XCF 6x21 6x21+13+6 8-bit sRGB 3c 299B 0.000u 0:00.160

BUILD SUCCESSFUL
Total time: 0 seconds

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org

Search Discussions

  • Harold Putman at Jan 2, 2015 at 3:41 pm
    your targetfile attribute on uptodate looks wrong

      targetfile="png/**.*.png

    Should that first dot be a slash?

    invoking ant with -d should give you an idea on why it is always setting
    png-uptodate
    On Tue, Dec 30, 2014 at 6:17 PM, YuGiOhJCJ Mailing-List wrote:

    Hello,

    I have a target that transforms files XCF into PNG by calling the
    "convert" command.
    I would like that this target does not execute if source files (i.e., the
    XCF files ) have changed.
    I have tried with the "uptodate" task but it does not work.
    Each time I run ant, the "convert" command is called.

    Any idea ?

    Thank you.
    Best regards.

    This is my build.xml file:
    <project name="xcf2png" default="png">
    <target name="png-check">
    <uptodate property="png-uptodate"
    targetfile="png/**.*.png">
    <srcfiles dir= "xcf" includes="**/*.xcf"/>
    </uptodate>
    </target>
    <target name="png" depends="png-check" unless="png-uptodate">
    <mkdir dir="png"/>
    <exec executable="convert">
    <arg value="-verbose"/>
    <arg value="-alpha"/>
    <arg value="on"/>
    <arg value="-background"/>
    <arg value="none"/>
    <arg value="-layers"/>
    <arg value="merge"/>
    <arg value="xcf/icon.xcf"/>
    <arg value="png/icon.png"/>
    </exec>
    </target>
    <target name="clean">
    <delete dir="png"/>
    </target>
    </project>

    This is the result in the console:
    $ ant
    Buildfile: /home/yugiohjcj/xcf2png/build.xml

    png-check:

    png:
    [exec] xcf/icon.xcf[0] XCF 32x32 32x32+0+0 8-bit sRGB 1.21KB 0.000u
    0:00.000
    [exec] xcf/icon.xcf[0] XCF 6x21 6x21+13+6 8-bit sRGB 0.000u 0:00.000
    [exec] xcf/icon.xcf=>png/icon-0.png[0] XCF 32x32 32x32+0+0 8-bit sRGB
    1c 255B 0.000u 0:00.089
    [exec] xcf/icon.xcf=>png/icon-1.png[1] XCF 6x21 6x21+13+6 8-bit sRGB
    3c 299B 0.000u 0:00.160

    BUILD SUCCESSFUL
    Total time: 0 seconds

    ---------------------------------------------------------------------
    To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
    For additional commands, e-mail: user-help@ant.apache.org

    --
    Harold PUTMAN
    Web Technology Specialist
    *Lexmark International, Inc. <http://www.lexmark.com>*
    740 W New Circle Rd.
    Lexington, KY 40550
    +1(859) 232-2839
    hputman@lexmark.com
  • YuGiOhJCJ Mailing-List at Jan 2, 2015 at 8:05 pm
    In fact, yes, there is a mistake at this line.
    It should be:
    targetfile="png/*.png"
    It is corrected now but the problem is the same.

    Here is my file hierarchy:
    $ tree
    .
    -- build.xml
    -- png
    `-- icon.png `-- xcf
    -- background.xcf
         `-- icon.xcf

    Why each time I run ant, my "png" target is executed please?

    On Fri, 2 Jan 2015 10:40:06 -0500
    Harold Putman wrote:
    your targetfile attribute on uptodate looks wrong

    targetfile="png/**.*.png

    Should that first dot be a slash?

    invoking ant with -d should give you an idea on why it is always setting
    png-uptodate

    On Tue, Dec 30, 2014 at 6:17 PM, YuGiOhJCJ Mailing-List <
    yugiohjcj-mailinglist@laposte.net> wrote:
    Hello,

    I have a target that transforms files XCF into PNG by calling the
    "convert" command.
    I would like that this target does not execute if source files (i.e., the
    XCF files ) have changed.
    I have tried with the "uptodate" task but it does not work.
    Each time I run ant, the "convert" command is called.

    Any idea ?

    Thank you.
    Best regards.

    This is my build.xml file:
    <project name="xcf2png" default="png">
    <target name="png-check">
    <uptodate property="png-uptodate"
    targetfile="png/**.*.png">
    <srcfiles dir= "xcf" includes="**/*.xcf"/>
    </uptodate>
    </target>
    <target name="png" depends="png-check" unless="png-uptodate">
    <mkdir dir="png"/>
    <exec executable="convert">
    <arg value="-verbose"/>
    <arg value="-alpha"/>
    <arg value="on"/>
    <arg value="-background"/>
    <arg value="none"/>
    <arg value="-layers"/>
    <arg value="merge"/>
    <arg value="xcf/icon.xcf"/>
    <arg value="png/icon.png"/>
    </exec>
    </target>
    <target name="clean">
    <delete dir="png"/>
    </target>
    </project>

    This is the result in the console:
    $ ant
    Buildfile: /home/yugiohjcj/xcf2png/build.xml

    png-check:

    png:
    [exec] xcf/icon.xcf[0] XCF 32x32 32x32+0+0 8-bit sRGB 1.21KB 0.000u
    0:00.000
    [exec] xcf/icon.xcf[0] XCF 6x21 6x21+13+6 8-bit sRGB 0.000u 0:00.000
    [exec] xcf/icon.xcf=>png/icon-0.png[0] XCF 32x32 32x32+0+0 8-bit sRGB
    1c 255B 0.000u 0:00.089
    [exec] xcf/icon.xcf=>png/icon-1.png[1] XCF 6x21 6x21+13+6 8-bit sRGB
    3c 299B 0.000u 0:00.160

    BUILD SUCCESSFUL
    Total time: 0 seconds

    ---------------------------------------------------------------------
    To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
    For additional commands, e-mail: user-help@ant.apache.org

    --
    Harold PUTMAN
    Web Technology Specialist
    *Lexmark International, Inc. <http://www.lexmark.com>*
    740 W New Circle Rd.
    Lexington, KY 40550
    +1(859) 232-2839
    hputman@lexmark.com
    ---------------------------------------------------------------------
    To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
    For additional commands, e-mail: user-help@ant.apache.org
  • YuGiOhJCJ Mailing-List at Jan 2, 2015 at 8:19 pm
    Oh, I have not read correctly the documentation of the <uptodate> task:
    "multiple target files are specified using a nested <mapper> element"

    So this is the correct target:
    <target name="png-check">
      <uptodate property="png-uptodate">
       <srcfiles dir= "xcf" includes="*.xcf"/>
       <mapper type="glob" from="*.xcf" to="../png/*.png"/>
      </uptodate>
    </target>

    It seems to work :)

    On Fri, 2 Jan 2015 21:04:25 +0100
    YuGiOhJCJ Mailing-List wrote:
    In fact, yes, there is a mistake at this line.
    It should be:
    targetfile="png/*.png"
    It is corrected now but the problem is the same.

    Here is my file hierarchy:
    $ tree
    .
    -- build.xml
    -- png
    `-- icon.png `-- xcf
    -- background.xcf
    `-- icon.xcf

    Why each time I run ant, my "png" target is executed please?

    On Fri, 2 Jan 2015 10:40:06 -0500
    Harold Putman wrote:
    your targetfile attribute on uptodate looks wrong

    targetfile="png/**.*.png

    Should that first dot be a slash?

    invoking ant with -d should give you an idea on why it is always setting
    png-uptodate

    On Tue, Dec 30, 2014 at 6:17 PM, YuGiOhJCJ Mailing-List <
    yugiohjcj-mailinglist@laposte.net> wrote:
    Hello,

    I have a target that transforms files XCF into PNG by calling the
    "convert" command.
    I would like that this target does not execute if source files (i.e., the
    XCF files ) have changed.
    I have tried with the "uptodate" task but it does not work.
    Each time I run ant, the "convert" command is called.

    Any idea ?

    Thank you.
    Best regards.

    This is my build.xml file:
    <project name="xcf2png" default="png">
    <target name="png-check">
    <uptodate property="png-uptodate"
    targetfile="png/**.*.png">
    <srcfiles dir= "xcf" includes="**/*.xcf"/>
    </uptodate>
    </target>
    <target name="png" depends="png-check" unless="png-uptodate">
    <mkdir dir="png"/>
    <exec executable="convert">
    <arg value="-verbose"/>
    <arg value="-alpha"/>
    <arg value="on"/>
    <arg value="-background"/>
    <arg value="none"/>
    <arg value="-layers"/>
    <arg value="merge"/>
    <arg value="xcf/icon.xcf"/>
    <arg value="png/icon.png"/>
    </exec>
    </target>
    <target name="clean">
    <delete dir="png"/>
    </target>
    </project>

    This is the result in the console:
    $ ant
    Buildfile: /home/yugiohjcj/xcf2png/build.xml

    png-check:

    png:
    [exec] xcf/icon.xcf[0] XCF 32x32 32x32+0+0 8-bit sRGB 1.21KB 0.000u
    0:00.000
    [exec] xcf/icon.xcf[0] XCF 6x21 6x21+13+6 8-bit sRGB 0.000u 0:00.000
    [exec] xcf/icon.xcf=>png/icon-0.png[0] XCF 32x32 32x32+0+0 8-bit sRGB
    1c 255B 0.000u 0:00.089
    [exec] xcf/icon.xcf=>png/icon-1.png[1] XCF 6x21 6x21+13+6 8-bit sRGB
    3c 299B 0.000u 0:00.160

    BUILD SUCCESSFUL
    Total time: 0 seconds

    ---------------------------------------------------------------------
    To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
    For additional commands, e-mail: user-help@ant.apache.org

    --
    Harold PUTMAN
    Web Technology Specialist
    *Lexmark International, Inc. <http://www.lexmark.com>*
    740 W New Circle Rd.
    Lexington, KY 40550
    +1(859) 232-2839
    hputman@lexmark.com
    ---------------------------------------------------------------------
    To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
    For additional commands, e-mail: user-help@ant.apache.org
    ---------------------------------------------------------------------
    To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
    For additional commands, e-mail: user-help@ant.apache.org
  • Dominique Devienne at Jan 5, 2015 at 8:13 am

    On Fri, Jan 2, 2015 at 9:17 PM, YuGiOhJCJ Mailing-List wrote:

    Oh, I have not read correctly the documentation of the <uptodate> task:
    "multiple target files are specified using a nested <mapper> element"
    I always recommend using Ant-Contrib's <outofdate> task instead of Ant's
    older <uptodate>+target.

    It's from an Ant committer, Peter Reilly, so it's as good as it gets. FWIW.
    --DD

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupuser @
categoriesant
postedDec 30, '14 at 11:19p
activeJan 5, '15 at 8:13a
posts5
users3
websiteant.apache.org

People

Translate

site design / logo © 2018 Grokbase