Wouldn't be possible to put an if="use.A" in every target of lib_A.xml, and have every target of A and B repeated in your generic with a dependency on the A and B implementation.
Maybe you can also try to play with macro instead of target. You replace every target by a macro, and place them in A and B, inside a <target name="define-macro" if="use.A">. Then n the generic script you put some generic target implementation that calls the macro. 2008/5/29 Cyril Sagan <[EMAIL PROTECTED]>: > PROBLEM: I'm trying to develop a general build framework. In so doing, > I need some mechanism for to provide a "conditional implementation" > for a target. We cannot solve this problem using <antcall/>. > Can anyone suggest an implementation? > > > Here's a couple ways that I tried, that almost work,... but do not. > > All use this simple build.xml: > <?xml version="1.0"?> > <project name="generic_build" default="all"> > <property file="config.properties" /> > <import file="common.xml"/> > </project> > > > Failing attempt #1: This almost works, but doesn't because <import/> > cannot be embedded inside a target!! arg! > > common.xml: > <?xml version="1.0"?> > <project name="generic_build" default="all"> > <target name="use_lib_A" if="use.A"> > <!-- sorry, cannot <import/> in a target! --> > <import file="lib_A.xml" /> <!-- target "all_impl" defined inside > --> > </target> > > <target name="use_lib_B" if="use.B"> > <!-- sorry, cannot <import/> in a target! --> > <import file="lib_B.xml" /> <!-- target "all_impl" defined inside > --> > </target> > > <target name="all" > depends="init, use_lib_A, use_lib_B, all_impl" /> > </project> > > > > Failing attempt #2: This would work, if Ant supported property expansion > in the targets's depends attribute. > > common.xml: > <?xml version="1.0"?> > <project name="generic_build" default="all"> > <import file="lib_A.xml" /> > <import file="lib_B.xml" /> > > <target name="use_lib_A" if="use.A"> > <property name="use.library" value="lib_A" /> > </target> > > <target name="use_lib_B" if="use.B"> > <property name="use.library" value="lib_B" /> > </target> > > <target name="use_lib_B" if="use.B"> > <import file="lib_B.xml" /> <!-- target "all_impl" defined inside > --> > </target> > > <!-- sorry, no property expansion inside attributes! --> > <target name="all" > depends="init, use_lib_A, use_lib_B, ${use.library}.all_impl" /> > </project> > > > > Failing attempt #3: Almost works, except the depends targets > always excute... > > common.xml: > <?xml version="1.0"?> > <project name="generic_build" default="all"> > <import file="lib_A.xml" /> > <import file="lib_B.xml" /> > > <!-- sorry, depends called regardless of if/unless --> > <target name="use_lib_A" if="use.A" depends="implementation_A" /> > <target name="use_lib_A" if="use.B" depends="implementation_B" /> > > <target name="all" depends="init, use_lib_A, use_lib_B" > </project> > > This gets us closest to what we want, and would suffice if we could > tolerate the <antcall/>: > <target name="use_lib_A" if="use.A"> > <antcall target="implementation_A" /> > </target> > > ...but we can't use antcall because it re-reads the *entire* build > file. There's some fairly complicated init (that we don't have > control of) that doesn't tolerate being called multiple times. > > I'd appreciate any suggestions from the experts! > > Thanks. > > --Cyril > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > -- Gilles Scokart --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]