Re: Ant Dependency Management

Earl Hood <[email protected]>
Newsgroups gmane.comp.jakarta.ant.user
Message-ID <CANDwYvdv1pL7CdBuyPoqh=+X_1CHhY+ipAf9uuE3Key2y2=jDQ@mail.gmail.com>
On Sat, Oct 28, 2017 at 5:17 PM, R0b0t1 wrote:

> Is it possible to cache compilation results? I would like to avoid
> lengthy compile times after changing one file.

What I do for these situations is have the task create an empty file
which can then be used on subsequent executions for a modtime check to
determine if the task should execute or not.

I use something like the following general pattern:

  <target name="sometask"
      unless="skip.sometask"
      depends="sometask-check">
    ...
    <!-- Create empty file for subsequent up-to-date checks -->
    <touch file="sometask.time" verbose="false"/>
  </target>

  <target name="sometask-check">
    <uptodate property="skip.sometask"
        targetfile="sometask.time">
      <!-- Pattern/file set(s) here -->
    </uptodate>
  </target>

The dependent "sometask-check" will set the "skip.sometask" property if
any files specified in the pattern/file set are newer than the file
"sometask.time".

I normally put such modtime-check files in a specific directory that
gets removed when doing a "clean".

Unlike `make', Ant does not have implicit modtime dependency checks, so
you have to roll your own utilizing the <uptodate> task to set a
property that can be used to conditionalize the execution of a task.

--ewh
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.