I'm currently doing this to bypass my custom tasks because they fail if
I run them more than once when not needed.

Here's a snippet of my ant file:

----------------------------------------------------------

  <target name="compile-gensrc" depends="compile-xdoclet">

     <!-- see if the output files are up to date -->
     <uptodate property="gensrc.notRequired" value="true"
targetfile=".last.gensrc.build">
         <srcfiles dir="${tracker.domain.root}/src/main"
includes="**/*.java"/>
         <srcfiles dir="${build.lib}" includes="shared-xdoclet.jar"/>
     </uptodate>

     <!-- if the source files are older than the timestamp file
          then there is no need to try and generate -->
     <if>
       <equals arg1="${gensrc.notRequired}" arg2="true"/>
       <then>
         <echo message="value objects up to date"/>
       </then>
       <else>
        <taskdef name="valueobjects"
classname="com.fgm.tracker.shared.xdoclet.ValueObjectsTask">
            <classpath>
               <fileset dir="${build.lib}">
                 <include name="shared-xdoclet.jar"/>
               </fileset>
               <path refid="javac.classpath"/>
            </classpath>
        </taskdef>

        <!-- generate the VO value objects -->
        <valueobjects destdir="${build.gen-src}" force="true">
           <packageSubstitution packages="domain,domain.documents"
                 substituteWith="shared.valueobjects"/>

           <fileset dir="${project.root}/domain/src/main">
             <include name="**/*.java"/>
           </fileset>

           <valueobject/>

           <converter/>

           <convertutil/>

        </valueobjects>

         <touch file=".last.gensrc.build"/>
       </else>
     </if>
  </target>

-----------------------------------------------

If the generation process goes successfully, I touch the
.last.gensrc.build file.  The timestamp on this is used to compare
against the source files (and my custom xdoclet task jar file). The
uptodate task checks to see if .last.gensrc.build file is newer than the
specified source files.  If so the gensrc.notRequired property is set to
"true".

My clean target, of course, deletes the .last.gensrc.build file.

The if/else stuff is part of ant-contrib.  It's not part of the core or
optional ant tasks.  However, you should be able to setup the same kind
of logic with ant using the "unless" and "if" attributes of the target
tasks and/or ant conditionals.  Personally, that stuff is real ugly and
I prefer to use the if/else tasks from ant-contrib.

Scott

> -----Original Message-----
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On Behalf 
> Of Mark Lybarger
> Sent: Tuesday, March 02, 2004 4:01 PM
> To: [EMAIL PROTECTED]
> Subject: RE: [Xdoclet-user] Sloooow...ejbdoclet
> 
> 
> I'd also be interested in seeing an example usage of uptodate 
> to bypass xdoclet generation.  
> 
> We're currently using xdoclet to generate stateless session 
> bean remote/home interfaces as well as dd's.  (and one 
> validator.xml file).  
> 
> Anyone willing to share an example? perhaps the xdoclet time 
> hasn't caused many to jump on to use this?
> 
> thanks!
> ~mark
> 
> > -----Original Message-----
> > From: [EMAIL PROTECTED]
> > [mailto:[EMAIL PROTECTED] Behalf Of David 
> > Corbin
> > Sent: Sunday, February 22, 2004 7:30 AM
> > To: [EMAIL PROTECTED]
> > Subject: Re: [Xdoclet-user] Sloooow...ejbdoclet
> > 
> > 
> > On Sunday 22 February 2004 06:30, Andrew Stevens wrote:
> > > On Sat, 2004-02-21 at 12:08, David Corbin wrote:
> > > > I have 36 beans that are a mix of CMP, Session and MDB.
> > When there is
> > > > nothing to do (generate), ejbdoclet still takes nearly a
> > minute to decide
> > > > there is nothing to do.
> > >
> > > You may want to investigate Ant's uptodate task.  With
> > that, your build
> > > script can skip running the ejbdoclet task altogether 
> when there's 
> > > nothing for it to do.
> > 
> > I am familiar with it.  I don't suppose you have an example
> > specific to EJB 
> > generation that I could use as a pattern.
> > 
> > 
> > 
> > 
> > -------------------------------------------------------
> > SF.Net is sponsored by: Speed Start Your Linux Apps Now. Build and 
> > deploy apps & Web services for Linux with a free DVD 
> software kit from 
> > IBM. Click Now! 
> http://ads.osdn.com/?ad_id=1356&alloc_id=> 3438&op=click
> > 
> 
> _______________________________________________
> > xdoclet-user mailing list
> > [EMAIL PROTECTED]
> > https://lists.sourceforge.net/lists/listinfo/xdoclet-user
> > 
> > 
> > ---
> > Incoming mail is certified Virus Free.
> > Checked by AVG anti-virus system (http://www.grisoft.com).
> > Version: 6.0.574 / Virus Database: 364 - Release Date: 1/29/2004
> >  
> > 
> 
> ---
> Outgoing mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.574 / Virus Database: 364 - Release Date: 1/29/2004
>  
> 
> 
> 
> -------------------------------------------------------
> SF.Net is sponsored by: Speed Start Your Linux Apps Now.
> Build and deploy apps & Web services for Linux with
> a free DVD software kit from IBM. Click Now! 
http://ads.osdn.com/?ad_id56&alloc_id438&op=ick
_______________________________________________
xdoclet-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/xdoclet-user



-------------------------------------------------------
SF.Net is sponsored by: Speed Start Your Linux Apps Now.
Build and deploy apps & Web services for Linux with
a free DVD software kit from IBM. Click Now!
http://ads.osdn.com/?ad_id56&alloc_id438&op=click
_______________________________________________
xdoclet-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/xdoclet-user

Reply via email to