Koen,

 

I see that multiple people have already responded.

 

So……

 

The script below is another way of accomplishing your request.

I haven’t tested it, but it should be easy enough to get functional.

 

The script won’t work properly if you use the ‘depends’ attribute on your targets.

This only works if you have a sequential build order.

 

Noel

 

 

 

 

<?xml version="1.0"?>

<project name="Test" default="start">

 

    <!-- File to store restart information in -->

    <property name="restartFile" value="Test.restart" />

 

 

    <!-- The 'start' target sets the stage to allow

         restarting from the failed target           -->

    <target name="start">

        <!-- Set up the default first target to execute -->

        <property name="targetToCall" value="firstTarget" />

       

        <property name="nant.onsuccess" value="success" />

        <property name="nant.onfailure" value="setupRestart" />

       

        <if test="${file::exists(restartFile)">

            <!-- Load the restart target into a property -->

            <loadfile file="${restartFile}" property="targetToCall" />

            <delete file="${restartFile}" />

        </if test>

       

        <!-- call either the default first target or the restart target -->

        <call target="${targetToCall}" />

    </target>

   

    <target name="firstTarget">

        <property name="targetToCall" value="${target::get-current-target()}" />

        <echo message="In ${target::get-current-target()}" />

        <call target="checkoutCode" />

    </target>

   

    <target name="checkoutCode">

        <property name="targetToCall" value="${target::get-current-target()}" />

        <echo message="In ${target::get-current-target()}" />

        <call target="build" />

    </target>

 

    <target name="build">

        <property name="targetToCall" value="${target::get-current-target()}" />

        <echo message="In ${target::get-current-target()}" />

        <call target="package" />

    </target>

 

    <target name="package">

        <property name="targetToCall" value="${target::get-current-target()}" />

        <echo message="In ${target::get-current-target()}" />

    </target>

   

    <!-- nant.onfailure handler -- writes the name of the target that failed into a file -->

    <target name="setupRestart">

        <echo file="${restartFile}" message="${targetToCall}" />

        <echo message="target, ${targetToCall}, failed to complete" />

    </target>

  

    <!-- nant.onsuccess handler -->

    <target name="success">

        <echo message="all targets executed successfully" />

    </target>

 

</project>

 


From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Koen Mayens
Sent: Tuesday, January 10, 2006 6:42 AM
To: nant-users@lists.sourceforge.net
Subject: [NAnt-users] status build

 

Hi,

I'm looking for a way where I can restart a build from the last not succeeded part or task.
This is because our build proces takes more than an hour, and it's not an option to rebuild the whole stuff after the build failed.
I was thinking about using some kind of status file which contains a status of each step in the buildfile and wich will be created at the start of the build. (this because there will always be somebody who forgets to update the status file :))
Is there somebody who has some experience or information about this, or is this possible with nant commands?
I was thinking about implementing it myself, maybe someone already did something equal.

Thanks in advance

Koen


Reply via email to