You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Saladin Sharif <al...@yahoo.com> on 2007/10/09 00:31:01 UTC

using ANT to check for any code changes in CVS

I am trying to automate my ANT build script, and incorporate a check in my build.xml that checks if there were any code changes made to CVS since the last time the build ran.  If there are any code changes then ANT gets the latest CVS code changes and then runs the build.  Otherwise, it doesn't run the build if there were no new code changes in CVS.

I was just wondering if anyone knew of how to write the ANT script portion that would check for whether any new code changes were made in CVS, and then maybe save that outcome to a property that I can use later on in my ANT script.

Thanks in advance,

-Saladin


 
**********************************************************
* Saladin Sharif
* e-mail: al_zawiah@yahoo.com
* Visit homepage @ http://gaia.ecs.csus.edu/~sharifs
**********************************************************


       
____________________________________________________________________________________
Pinpoint customers who are looking for what you sell. 
http://searchmarketing.yahoo.com/

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


Re: using ANT to check for any code changes in CVS

Posted by David Weintraub <qa...@gmail.com>.
Ant can do an excellent job of build avoidance, so this shouldn't
really be an issue if you have programmed your build.xml correctly. It
might still run through all the targets, but no tasks will be
executed.

Imagine you have a build.xml like this (the main thing to note that
each task depends upon the one above):

[...]

<target name="cvsupdate">
    <cvs command="update">
        [....]
    </cvs>
</target>

<target name="compile"
    depends="cvsupdate">
    <javac>
       [...]
    </javac>
</target>

<target name="jar"
    depends="compile">
    <jar>
       [...]
    </jar>
</target>

<target name="package"
    depends="jar">
    <tar>
        [...]
    </tar>
</target>

Let's say I run "ant package". The "cvsupdate" target runs and checks
out new files that have been modified. Next, the "compile" target runs
and builds new *.class files. Then, the "jar" target runs and builds a
new "jar". Finally, the "package" target runs and builds a new tar
file.

Now, I rerun the "ant package" command. The "cvsupdate" target runs,
but since there has been no files modified in the CVS archive, no new
*.java files are checked out. Now, the "compile" target is called, but
since all the *.class files are newer than all the *.java files, no
*.java files are compiled.

Now, the "jar" target executes. Since no new *.class files that make
up my jar have been modified, the "jar" task isn't executed. Now, the
"package" target runs, but the same thing. No files have been
modified, so the "tar" command isn't executed.

I have a build.xml that normally takes about 8 to 10 minutes if I have
a clean area for building. If I run that build.xml again, it takes
less than a minute to run through all the targets since it doesn't
need to execute any tasks.

Almost all Ant tasks do build avoidance if you take care in writing
your build.xml file (For example, "copy" and "mkdir" tasks do build
avoidance, but "move" and "delete" tasks do not). If you do find an
Ant task that has trouble with build avoidance, you can try using the
<uptodate> task as a way of checking if a particular target needs to
be executed:

<target name="foo">
   <uptodate property="foo.task.uptodate.flag">
       [...]
   </uptodate>
</target>

<target name="bar"
    depends="foo"
    if="foo.task.uptodate.flag">
    [...]
</target>

Or, if you don't mind using the AntContrib tasks, the <outofdate> task
allows you to specify inside the task the sub-tasks to execute. That
saves you from creating a property, then calling another target based
upon that target.

So, if you are careful in writing your build.xml, Ant may reexecute
all of your targets, but it won't execute a single task it does not
have to. There is no need to verify the output of the <cvs> task to
see if any new files were checked out.

On 10/8/07, Saladin Sharif <al...@yahoo.com> wrote:
> I am trying to automate my ANT build script, and incorporate a check in my build.xml that checks if there were any code changes made to CVS since the last time the build ran.  If there are any code changes then ANT gets the latest CVS code changes and then runs the build.  Otherwise, it doesn't run the build if there were no new code changes in CVS.
>
> I was just wondering if anyone knew of how to write the ANT script portion that would check for whether any new code changes were made in CVS, and then maybe save that outcome to a property that I can use later on in my ANT script.
>
> Thanks in advance,
>
> -Saladin
>
>
>
> **********************************************************
> * Saladin Sharif
> * e-mail: al_zawiah@yahoo.com
> * Visit homepage @ http://gaia.ecs.csus.edu/~sharifs
> **********************************************************
>
>
>
> ____________________________________________________________________________________
> Pinpoint customers who are looking for what you sell.
> http://searchmarketing.yahoo.com/
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
>
>


-- 
--
David Weintraub
qazwart@gmail.com

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


Re: using ANT to check for any code changes in CVS

Posted by Kevin Jackson <fo...@gmail.com>.
Hi,

> I am trying to automate my ANT build script, and incorporate a check in my build.xml that checks if there were any code changes made to CVS since the last time the build ran.  If there are any code changes then ANT gets the latest CVS code changes and then runs the build.  Otherwise, it doesn't run the build if there were no new code changes in CVS.
>

You should look at CruiseControl.  This has a feature which can check
any source control system for changes and run a build (ant based) if
there have been commits.

Kev

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