You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by "Andrew Bayer (abayer)" <ab...@cisco.com> on 2007/05/01 19:36:23 UTC

Reporting build success/failure in /'s output log file?

Hi -
	I'm working on a project that builds a number of subprojects in
a dynamically-determined order, based on some information we define in
properties. The problem I'm running into is in logging the subprojects -
<ant> (and therefore <subant>) hardcodes its subproject's build listener
as DefaultLogger at log level INFO. In a perfect world, I'd like to be
able to set that log level myself, but the more significant issue is
that I can't just look at the subproject's logfile and see whether it
failed or passed. The subprojects are not just Java - we have macro'd
wrappers around calls to InstallShield and Visual Studio on Windows,
among other things - so it's not like there's an easy pattern to look
for in case of failure.

	In an earlier incarnation of this project, I extended Ant.java
and basically rewrote it to use a custom-set log level, to return
properties (like ant-contrib's <antfetch>, but also allowing for
wildcards), to use a failonerror attribute like <subant>, and to run
newProject.fireBuildFinished after executing the subproject, so that we
got either BUILD SUCCESSFUL or BUILD FAILED in the subproject's log
file. I got the older version of the project working with Ant 1.7, but
it was an ugly and painful process that I'd really like to avoid having
to go through again when Ant changes down the road. The new version no
longer needs the returned properties, and now that I understand <subant>
better, I think I can use that instead of <ant> and get the failonerror
behavior that way. That leaves only the custom log level and getting
BUILD SUCCESSFUL/BUILD FAILED in the subproject's logs to go.

	I see that fireSubBuildFinished is called in <ant>, but since
the subproject's listener is hardcoded as DefaultLogger, that doesn't do
anything - I can use my own listener for the main project and report the
subproject's results in the main project's logfile, but I really want to
have that go into the subproject's logfile - we have a bunch of other
tools for reporting, integrating with our build management system,
working with an external distribution tool, etc that get run as
subprojects. The subprojects know how to get at the logfiles for the
other subprojects (through the information we're storing in
globally-defined properties), and can therefore determine which
subprojects have failed or passed just by finding the logfile for a
subproject and looking for BUILD SUCCESSFUL/BUILD FAILED. 

	Is there any way to do this without having to subclass Ant.java?
I'm not married to the output being BUILD SUCCESSFUL or BUILD FAILED
specifically - any pass/fail string that I can do a regexp for would be
sufficient. Any help/advice/etc anyone could provide would be greatly
appreciated. Thank you!

Andrew Bayer

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


Re: Reporting build success/failure in /'s output log file?

Posted by Dominique Devienne <dd...@gmail.com>.
On 5/9/07, Andrew Bayer (abayer) <ab...@cisco.com> wrote:
> > I'd like to hand a graph of builds to run (from Ivy) and have
> > <subant>
> > detect a failure and skip all dependencies, then carry on with
> > everything else. So at the end of the <subant> run, we'd report
> >   -failing builds
> >   -skipped builds
> > then it would halt.

Hmmm, sounds strangely familiar.... Ah yes, GUMP! That's not the realm
of Ant IMHO.

> That's basically what I'm looking for - we have enough projects that are
> not all directly related to each other that it's a huge help for us to
> attempt to build every project, even if an early one fails, so that we
> can see if there are unrelated errors in later projects, etc... Ideally,
> I'd also like to be able to have subprojects be able to tell if any
> previously-run subprojects have failed, because we've got a couple
> projects that interact with our packaging and distribution systems that
> behave in different ways depending on whether the compilation projects
> have all passed or not.

A large build like this which takes different actions depending on
success/failures of sub-builds will be a huge maintenance headache.
Ant is not designed to be used like this, and consequently makes it
hard to do this. You'd be better off writing the "orchestrating" logic
using a true scripting language like Python (hmm, that GUMP reference
coming up again ;-) on top of your existing Ant builds for each
sub-project.

That said, you may be able to work something out without having to
hack the Ant code itself by writing a custom BuildListener that writes
out to a file success/failure info about your various
builds/subbuilds, that you can query from your builds (using existing
tasks wrapped in macros, or custom tasks). (the build listener could
also set properties, but on which build (Project)???)

--DD

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


RE: Reporting build success/failure in /'s output log file?

Posted by "Andrew Bayer (abayer)" <ab...@cisco.com>.
> I'd like to hand a graph of builds to run (from Ivy) and have 
> <subant> 
> detect a failure and skip all dependencies, then carry on with 
> everything else. So at the end of the <subant> run, we'd report
>   -failing builds
>   -skipped builds
> then it would halt.

That's basically what I'm looking for - we have enough projects that are
not all directly related to each other that it's a huge help for us to
attempt to build every project, even if an early one fails, so that we
can see if there are unrelated errors in later projects, etc... Ideally,
I'd also like to be able to have subprojects be able to tell if any
previously-run subprojects have failed, because we've got a couple
projects that interact with our packaging and distribution systems that
behave in different ways depending on whether the compilation projects
have all passed or not.

A.

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


Re: Reporting build success/failure in /'s output log file?

Posted by Steve Loughran <st...@apache.org>.
Dominique Devienne wrote:
> On 5/1/07, Andrew Bayer (abayer) <ab...@cisco.com> wrote:
>> Is there any way to do this without having to subclass Ant.java?
>> I'm not married to the output being BUILD SUCCESSFUL or BUILD FAILED
>> specifically - any pass/fail string that I can do a regexp for would be
>> sufficient. Any help/advice/etc anyone could provide would be greatly
>> appreciated. Thank you!
> 
> I've used (at a previous job) <subant> extensively, with several
> levels of sub-projects and many  "leaf" projects as well, yet your
> request implies that you set failonerror="false" in <subant>, which is
> the reason you have to jump thru all these hoops to try to find out
> a-posteriori when a sub-project failed.
> 
> I've always been a proponent that if *anything* fails, the *whole*
> build fails. If you were to take this approach, we'd see how it
> simplifies your Ant build. This approach, coupled with a
> SubBuildLogger that tells you which build a target belongs to is all I
> ever needed with my large builds.
> 

I'd like to hand a graph of builds to run (from Ivy) and have <subant> 
detect a failure and skip all dependencies, then carry on with 
everything else. So at the end of the <subant> run, we'd report
  -failing builds
  -skipped builds
then it would halt.


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


Re: Reporting build success/failure in /'s output log file?

Posted by Dominique Devienne <dd...@gmail.com>.
On 5/1/07, Andrew Bayer (abayer) <ab...@cisco.com> wrote:
> Is there any way to do this without having to subclass Ant.java?
> I'm not married to the output being BUILD SUCCESSFUL or BUILD FAILED
> specifically - any pass/fail string that I can do a regexp for would be
> sufficient. Any help/advice/etc anyone could provide would be greatly
> appreciated. Thank you!

I've used (at a previous job) <subant> extensively, with several
levels of sub-projects and many  "leaf" projects as well, yet your
request implies that you set failonerror="false" in <subant>, which is
the reason you have to jump thru all these hoops to try to find out
a-posteriori when a sub-project failed.

I've always been a proponent that if *anything* fails, the *whole*
build fails. If you were to take this approach, we'd see how it
simplifies your Ant build. This approach, coupled with a
SubBuildLogger that tells you which build a target belongs to is all I
ever needed with my large builds.

Sorry, not a direct answer to your question, more a "change your
approach" advice. Good luck, --DD

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