ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Peter Reilly" <peter.kitt.rei...@gmail.com>
Subject Re: [Ant 1.6.5] Question on "OutOfDate" Usage
Date Fri, 28 Sep 2007 18:27:08 GMT
On 9/28/07, Dominique Devienne <ddevienne@gmail.com> wrote:
> On 9/28/07, Anil VVNN <vvnn_anil@yahoo.com> wrote:
> > I'm trying to use "OutOfDate" task for the following requirement,[...]
> >       <targetfiles>
> >         <pathelement path="${xjc.java.dir}"/>
> >       </targetfiles>
> > [...]
> > But generate.xjc.java is called always (no matter whether there is a change
> > to XSD's or not).
>
> Could be that your "target files" should be all the generated files
> inside xjc.java.dir, instead of (or in addition to) just xjc.java.dir.
> If any target file is older than any source file, the sequential will
> fire. Could be you only need a <touch> on xjc.java.dir in the
> sequential too.
>
> The problem with this approach is that the sequential will no fire for
> missing generated files, and to deal with this, you either need to use
> <filelist> in targetfiles, if you know the generated file names
> (possibly via a mapper and the input sources), or write a custom task
> that records all generated files after each sequential, so test
> they're all here and up-to-date on the next run (what I did in my
> <jaxb> task in BugZilla). --DD

The targetfile in this case is just the top-level directory, which
may not get updated each time - so it is always out-of-date.

However, you do not need to use <outofdate> for the xjc ant
task as it has its own dependecy check, if it is configured.

This is the <macro> I used:
  <!-- Macro: compile-xsd -->
  <macrodef name="compile-xsd">
    <attribute name="xsd"/>
    <attribute name="package" default="@{xsd}"/>
    <sequential>
      <xjc schema="${main.dir}/schema/@{xsd}.xsd"
           destdir="${gen.java}"
           package="com.COMPANY.presence.xsd.@{package}"
           extension="yes"
           >
        <produces dir="${gen.java}/com/COMPANY/presence/xsd/@{package}"
                  includes="**/*.java"/>
      </xjc>
    </sequential>
  </macrodef>

(Note the produces nested element).

and use:

 <target name="compile-xsd">
    <mkdir dir="${gen.java}"/>
    <compile-xsd xsd="data-model" package="datamodel"/>
    <compile-xsd xsd="pidf"/>
    <compile-xsd xsd="rpidf"/>
  </target>

Another technique to use with <outofdate> is to pick
a file that *always* gets updated (given the particular input)
when a 3-party ant task is used.

For example:
  <macrodef name="gen-java-from-wsdl">
    <attribute name="wsdl"  description="s"/>
    <attribute name="targetfile"/>
    <attribute name="package"/>
    <sequential>
      <ac:outofdate>
        <sourcefiles path="@{wsdl}"/>
        <targetfiles path="@{targetfile}"/>
        <sequential>
          <axis-wsdl2java
            output="build/gen/java"
            url="@{wsdl}"
            serverside="true"
            verbose="false">
            <mapping namespace="${ws.ns}" package="@{package}"/>
            <classpath refid="main.path"/>
          </axis-wsdl2java>
        </sequential>
      </ac:outofdate>
    </sequential>
  </macrodef>

in this case the target file is a file and not a directory.

    <gen-java-from-wsdl
      wsdl="src/main/wsdl/PresenceUserStore.wsdl"
      targetfile=
      "build/gen/java/${ws.path}/PresenceUserStore/UserMgmtService.java"
      package="${ws.package}.PresenceUserStore"/>

What DD is saying about missing files is correct, but it is also
true for <javac> and other tasks.

One should always do an ant clean if one changes the source drastically.

Peter

PS, please please do not use <antcall>

Peter


> ---------------------------------------------------------------------
> 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


Mime
View raw message