<subant genericbuildfile> ? Or a combination of <subant> and <import> as described in the <subant> examples (I think, the last one).
Jan > -----Ursprüngliche Nachricht----- > Von: Cyril Sagan [mailto:[EMAIL PROTECTED] > Gesendet: Donnerstag, 29. Mai 2008 00:27 > An: Ant Users List > Betreff: How can I "conditionall chooise" a target implementation? > > 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] > > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]