I have this same configuration and I have a target that sets the flag before getting on with it. <target name="debug_dist" depends="set_debug,dist"/>
Where set_debug is like setmode... And Dist depends on an init that sets debug to false. Then I use debug in my javac calls... Alan. -----Original Message----- From: Peter Davis [mailto:[EMAIL PROTECTED]] Sent: 16 November 2001 06:31 To: Ant Users List Subject: Re: Doing both debug and release builds with same targets If you specify the property on the command line: ant -Dmode=debug compile-proj1 then mode will not be overwritten even if there is a <property> that sets it. But this means you have to type that ugly -D parameter, which is why I think that the message to which I am replying is probably the most elegant solution. On Thursday 15 November 2001 05:31 pm, you wrote: > The way I would do it is the following > > <target name="setmode" unless="mode"> > <echo message="mode not set, setting mode to debug"/> > <property name="mode" value="debug" /> > </target> > > <target name="compile-proj1" depends="prepare, setmode"> > etc. > > Hope this helps, > Jim > > --- Alan Pearson <[EMAIL PROTECTED]> wrote: > > This must be a relatively common task, so I present the Ant user > > commuity > > with the following question: I am trying to write a build.xml file > > that can > > build in either debug mode or release mode depending on which target > > is > > invoked on the command line (or build them both). The difference > > between the > > two builds will be the settings of the Optimization/Debug flags on > > the javac > > tasks, and also the output directories for classes and other > > generated > > files. My best solution has the following structure: > > > > <?xml version='1.0' encoding='utf-8'?> > > <project name="test" default="both" basedir="."> > > > > <target name="prepare"> > > <echo message = "Preparing ${mode} directory." /> > > </target> > > > > <target name="compile-proj1" depends="prepare"> > > <echo message = "compiling project 1 in ${mode} mode" > > /> > > </target> > > > > <target name="compile-proj2" depends="prepare"> > > <echo message = "compiling project 2 in ${mode} mode" > > /> > > </target> > > > > <target name="build" depends="compile-proj1,compile-proj2" /> > > > > <target name="debug-build"> > > <property name="mode" value="debug" /> > > <antcall target="build" /> > > </target> > > > > <target name="release-build"> > > <property name="mode" value="release" /> > > <antcall target="build" /> > > </target> > > > > <target name="both"> > > <antcall target="debug-build" /> > > <antcall target="release-build" /> > > </target> > > > > </project> > > > > When I run ant with the "both", the "debug-build" or the > > "release-build" > > target, it does exactly what I want. The problem with this Is that I > > can > > only do the top-level build targets sucessfully. If I am working on > > just > > "project1", I'd like to be able to run "ant compile-proj1" and have > > it just > > build that project (preferably in debug-mode). However if I run ant > > that > > way, the ${mode}does not get set, and I get the output: > > > > prepare: > > [echo] Preparing ${mode} directory. > > > > compile-proj1: > > [echo] compiling project 1 in ${mode} mode > > > > > > So what I tried to do was to insert the statement > > > > <property name="mode" value="debug" /> > > > > at the very beginning of the file (right after the <project> > > declaration). > > My hope was that this would provide a "default" value for mode, and > > that > > when I ran "release-build" or when "both" antcall'ed "release-build" > > the > > property statement within that target would override the default > > setting. > > Unfortunately, it didn't happen that way. After adding the above > > property > > statement, the release-build target started using ${mode}="debug". > > > > Can I have my cake and eat it too? Is there a way to set the default > > value > > of ${mode} to be "debug" and have it set to "release" only when the > > release-build target is run? > > > > > > > > Thanks, > > > > Alan Pearson > > __________________________________________________ > Do You Yahoo!? > Find the one for you at Yahoo! Personals > http://personals.yahoo.com -- Furthermore, I believe bacon prevents hair loss. Peter Davis Developer, Speaklink Inc. [EMAIL PROTECTED] -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]> -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>