build dependencies and executing independent targets in the same project

View: New views
4 Messages — Rating Filter:   Alert me  

build dependencies and executing independent targets in the same project

by isaacsteele :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I'm relatively new to Ant and have an issue.  I am using cruisecontrol and ant to build our projects.

I have a build file with targets A, B, C and D.

C is dependent on B and A, likewise B is dependent on A.
D, however, is independent of all of them.

I want to be able to call C (which is my test target), then call D after C regardless of whether the test target passes or fails.  I'm using <subant> within C and currently, when a test fails, it exits the build.xml and fails the build without having run target D.  (And without C being a dependencies of D, even if it passes, D is not run I'm required to put a default target in my project.)

So my questions are:
1) Is this possible--that I execute a target at the end of a build regardless of failure?
2) What should my default target be (if I have two independent targets that should be built)?
3) I know I could use <failonerror> in subant and then make D dependent on C, but then the build isn't marked as failed when finished.  (If there is a way to fail a build with a test error after using <failonerror=false>, then that might be the easiest thing.)

Thanks for your help.

Re: build dependencies and executing independent targets in the same project

by Stefan Bodewig :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

[Isaac, this really is a qiestion for the user list, not the dev list
which is about the development of Ant itself, not developing with Ant.]

On 2009-09-14, isaacsteele <isaac.steele@...> wrote:

> 1) Is this possible--that I execute a target at the end of a build
> regardless of failure?

Not out of the box, no.  There are patches to enable this and I think
I've even seen somebody implement a BuildListener that will invoke a
target in the *finished event (which sounds dangerous given that the
project instance thinks the build is over).

> 2) What should my default target be (if I have two independent targets that
> should be built)?

Probably something like <target name="do-all-of-it" depends="C,D"/>

> 3) I know I could use <failonerror> in subant and then make D dependent on
> C, but then the build isn't marked as failed when finished.

In the part I've snipped, you said C would fail if a test failed.  do
you really need subant at all?  If not, then make <junit> set a property
instead of making the build fail and later use <fail/> if that property
has been set.

Stefan

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@...
For additional commands, e-mail: dev-help@...


Re: build dependencies and executing independent targets in the same project

by isaacsteele :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Apologies about placing it in this question in the wrong forum, should I copy the post and re-submit it there?

I'm using subant because it is calling my tests for multiple projects in multiple directories:

<target name="test">
        <subant>
                <fileset dir="../../" includes="**/build.xml" excludes="**/abc/build.xml, **/xyz/build.xml">
                <target name="test"/>
        </subant>
</target>

This calls ~15 different build.xml files for projects that I want to test that I built previously my overall project build.xml.

If there is a better way to do this (with with the junit task), I'd love to use it, but I don't know how at this point.

Stefan Bodewig wrote:
[Isaac, this really is a qiestion for the user list, not the dev list
which is about the development of Ant itself, not developing with Ant.]

On 2009-09-14, isaacsteele <isaac.steele@zoominfo.com> wrote:

> 1) Is this possible--that I execute a target at the end of a build
> regardless of failure?

Not out of the box, no.  There are patches to enable this and I think
I've even seen somebody implement a BuildListener that will invoke a
target in the *finished event (which sounds dangerous given that the
project instance thinks the build is over).

> 2) What should my default target be (if I have two independent targets that
> should be built)?

Probably something like <target name="do-all-of-it" depends="C,D"/>

> 3) I know I could use <failonerror> in subant and then make D dependent on
> C, but then the build isn't marked as failed when finished.

In the part I've snipped, you said C would fail if a test failed.  do
you really need subant at all?  If not, then make <junit> set a property
instead of making the build fail and later use <fail/> if that property
has been set.

Stefan

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

Re: build dependencies and executing independent targets in the same project

by Stefan Bodewig :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On 2009-09-14, isaacsteele <isaac.steele@...> wrote:

> Apologies about placing it in this question in the wrong forum, should I copy
> the post and re-submit it there?

No, just please remember doing so in the future.

> I'm using subant because it is calling my tests for multiple projects in
> multiple directories:

> <target name="test">
> <subant>
> <fileset dir="../../" includes="**/build.xml" excludes="**/abc/build.xml,
> **/xyz/build.xml">
> <target name="test"/>
> </subant>
> </target>

I see.

> If there is a better way to do this (with with the junit task), I'd love to
> use it, but I don't know how at this point.

You could use one big junit task and different batchtests, but that
would probably defeat your subant based build system.

It would probably be a good idea to add an errorProperty attribute to
the <ant> family of tasks so you could specifiy failOnError="false"
errorProperty="tests.failed" and have <fail if="tests.failed"/> after
your target D has finished.

Suddenly we are on-topic for the dev list ;-)

Stefan

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@...
For additional commands, e-mail: dev-help@...