ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From <>
Subject AW: dynamic targets
Date Tue, 24 Oct 2006 13:05:31 GMT
same - write a common buildfile (maybe with empty implementation) and all the 
projects have all needed targets. Web project could overwrite the target implementation.


>-----Urspr√ľngliche Nachricht-----
>Von: Markus M. May [] 
>Gesendet: Dienstag, 24. Oktober 2006 09:13
>An: Ant Users List
>Betreff: Re: dynamic targets
>Hello Jacob,
>why don't you just import a common build file and define the 
>common target there. Only when the target is not defined in 
>the build file, the common target gets executed. 
>Markus M. May
>-------- Original-Nachricht --------
>Datum: Mon, 23 Oct 2006 22:28:35 -0500
>Von: Jacob Kjome <>
>Betreff: dynamic targets
>> Along the lines of....
>> Is it possible to create targets dynamically, deferring 
>creation until 
>> such time as it is found that the project doesn't have the target 
>> already defined?  My use-case is using <subant> to iterate over 
>> sub-builds calling a target on each one.  My current strategy is to 
>> define <patternset>s for each type of project.  For instance, I add 
>> all web projects to a particular patternset and then reference that 
>> patternset when calling <subant>....
>>              <subant target="war" inheritAll="false">
>>                  <fileset dir=".">
>>                      <patternset refid="war.patternset"/>
>>                  </fileset>
>>              </subant>
>> As further fallback, individual builds may implement empty targets 
>> just so that they don't fail, just in case...
>> <target name="war">
>>      <echo message="Unimplemented target"/> </target>
>> However, ideally, I'd like to be able to create the above target 
>> dynamically in the case that it isn't implemented already by the
>> build.   This would have 2 benefits:
>> 1.  I wouldn't have to bother creating the patternsets.  I'd 
>just call 
>> all the build files and let them either build the war file 
>or echo the 
>> "Unimplemented target" message.
>> 2.  Individual builds that aren't web projects wouldn't have to have 
>> to know what a web project is.  If the only artifact generated is a 
>> simple jar library, it seems odd to have to implement a dummy "war"
>> target simply because some external master build file might 
>call "war" 
>> on it.
>> Instead of Ant failing with the following message...
>> Target `war' does not exist in this project.
>> ...I'd like Ant to just run the above dynamically created 
>target (not 
>> just the "war" target, but any target that might not exist), report 
>> the "Unimplemented target" message, and continue on.
>> So, is this possible?  Where/how do I hook into Ant to know 
>the target 
>> isn't implemented and create it myself via a scriptdef before Ant 
>> gives me the build failure?
>> Jake
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: For 
>> commands, e-mail:
>To unsubscribe, e-mail: For 
>additional commands, e-mail:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message