Hi Stefan,
>
> > I tried to build a workaround by setting a property but the problem
> > is that I can't override properties and properties defined inside
> > a target seem to be local, I can't use them in other targets.
>
> Could you please explain this a little? Properties are global, but
> those set in sub builds - the things you run via <ant> or <antcall>
> will not be transferred back to the parent build.
>
The problem is that I want to find out if the stuff I checked out does
compile. If it compiles everything is fine, if not I want to be able to
inform the user.
(for xml source please see end of mail)
Now I got the target build-clean. This creates directories to which the
sources are checked out and into which the classes will be compiled.
This target is called indirectly by the target cvs-check, which calls
cvs-check-sub which in turn depends on build-clean. (I was desperate ;O))
Why this?? The idea was, if build-clean fails cvs-check-sub wouldn't
be executed. This would mean that the property cvs-check.succeeded wouldn't
be set. Now we are back in the target cvs-check.
This now calls cvs-check-succeeded and cvs-check-failed, which both have
conditions connected to the property cvs-check.succeeded.
If my approach would have worked I now would have been able to give the user
the response I wanted.
There are two problems with this idea. First if the property gets set
in cvs-check-sub it isn't visible in the other targets. So it's definied
local. ==> Idea doesn't work
Another problem is that if I set failonerror to no in the javac task I
always
will have my property set to true. But if I don't do it it won't work eather
because ANT exits.
On more thing to failonerror. I ask for a feature like this but what I ment
was
something different.
Say I want to compile 10 files. 9 of these are correct and one contains a
syntax
error, this one is totaly unrelated to the others. Now if I run ANT and it
hits
the buggy file it will stop compiling. It would be nice if I where able to
tell it to
go on and try the rest.
Why?? I'm the guy how has to do the reviews. So I check out everything
and try to compile it. If something doesn't work I say "who cares" and start
reviewing the stuff that does work. (The stuff I check out consist of
several more
or less unrelated apps)
Cheers Thomas
<!--
===================================================================
Check if contents of CVS repository compiles
===================================================================
-->
<target name="cvs-check" if="cvs.user">
<antcall target="cvs-check-sub" />
<antcall target="cvs-check-succeeded" />
<antcall target="cvs-check-failed" />
</target >
<target name="cvs-check-sub" depends="build-clean" if="cvs.user">
<property name="cvs-check.succeeded" value="true" />
<echo message="${cvs-check.succeeded}" />
</target >
<target name="build-clean" if="cvs.user">
<tstamp/>
<!-- Dateien vom letzten Check wegwerfen -->
<delete dir="${cvs-check.src.dir}" />
<delete dir="${cvs-check.build.dir}" />
<!-- Verzeichnisse erzeugen, die fuer den Check benoetigt werden. -->
<mkdir dir="${cvs-check.src.dir}" />
<mkdir dir="${cvs-check.build.dir}" />
<cvs command="-d :pserver:[EMAIL PROTECTED]:${cvs.repository}
checkout -P -d '${cvs-check.src.dir}' src" />
<javac srcdir="${cvs-check.src.dir}"
destdir="${cvs-check.build.dir}"
>
</javac >
</target >
<target name="cvs-check-succeeded" if="cvs-check.succeeded">
<echo message="Sources in cvs repository compiled without errors." />
</target >
<target name="cvs-check-failed" unless="cvs-check.succeeded">
<echo message="Sources in cvs repository contain errors." />
</target >