Certainly! I would like to allow targets to "dynamically" add other targets to execute onsuccess or onfailure. The simplest solution I can think of is to define an onsuccess and an onfailure target to handle the appropriate situation and provide a property where the other targets can add their extra handler:
[example] <property name="nant.onsuccess" value="teardown.success" /> <property name="nant.onfailure" value="teardown.failure" /> <property name="teardown.success.targets" value="" /><!-- default: empty string --> <property name="teardown.failure.targets" value="" /><!-- default: empty string --> <target name="teardown.success"> <foreach item="String" in="${teardown.success.targets}" delim=" " property="${teardown.target}"> <call target="${teardown.target}" /> </foreach> </target> <target name="teardown.failure"> <foreach item="String" in="${teardown.failure.targets}" delim=" " property="${teardown.target}"> <call target="${teardown.target}" /> </foreach> </target> [/example] This system can then by used at "runtime" by other tasks to add handlers to the two cases: [example] <target name="init"> <!-- add a handler at runtime when init is executed --> <property name="teardown.failure.targets" value=" preundo ${teardown.failure.targets} postundo" /> </target> <target name="preundo" /> <target name="postundo" /> [/example] In this example preundo would be a target that gets execute prior to any targets already present in teardown.failure.targets. Likewise postundo would get executed after the current teardown.failure.targets. One must use great care to make sure that one includes teardown.failure.targets or teardown.success.targets when changing their value or one completely redefines them. A better solution would be to encapsulate this all behind custom tasks and provide custom functions to better manage the addition (and perhaps removal) of handler targets and their order of execution. Then each target needing to add a onsuccess handler could do something like this: [example] <property name="nant.onsuccess" value="teardown.success" /> <target name="teardown.success"> <onsuccess execute="true" /> </target> <target name="init"> <onsuccess> <addhandler target="processlogs" priority="1" /> </onsuccess> </target> [/example] You can imagine how <removehandler> would be used. <onfailure> would be used in a very similar fashion. Implementing this might be trickier. OnSuccessTask and OnFailureTask would be logical singletons and I'm not sure if NAnt's execution model would conflict with them. Perhaps if each instance of OnSuccessTask and OnFailureTask simply define actions to be taken on the internal SuccessSingleton and FailureSingleton... that might work. Anyway, it's and idea. Please don't hesitate to ask if you need more clarification. I hope this clarifies what I was trying to do and the two solutions I've come thought up. --Edwin ________________________________________ From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Butler, Mark A Mr IPI Gramm Tech Sent: Wednesday, January 26, 2005 1:43 PM To: [EMAIL PROTECTED] Sourceforge. Net Subject: RE: [Nant-users] Specifying a Finally target I was thinking along the line of... <property name="nant.onsuccess" value="target1" /> <target name="target1" <call target="target2"/> <call target="target3"/> </target> Can you post your workaround for the edification of the uninitiated? (Me) MArk B. -----Original Message----- From: Castro, Edwin Gabriel (Firing Systems Engr.) [mailto:[EMAIL PROTECTED] Sent: Wednesday, January 26, 2005 1:35 PM To: Butler, Mark A Mr IPI Gramm Tech; [EMAIL PROTECTED] Sourceforge. Net Subject: RE: [Nant-users] Specifying a Finally target Like this: <property name="nant.onsuccess" value="target1 target2 target3" /> I need to add targets dynamically at runtime. There's no problem if nant doesn't support this natively. The workaround is quite trivial and I've already implemented it. I was just wondering if nant already allowed for this. ________________________________________ From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Butler, Mark A Mr IPI Gramm Tech Sent: Wednesday, January 26, 2005 12:09 PM To: [EMAIL PROTECTED] Sourceforge. Net Subject: RE: [Nant-users] Specifying a Finally target You can put more tasks within the onsuccess and onfailure. MArk B. ------------------------------------------------------- This SF.Net email is sponsored by: IntelliVIEW -- Interactive Reporting Tool for open source databases. Create drag-&-drop reports. Save time by over 75%! Publish reports on the web. Export to DOC, XLS, RTF, etc. Download a FREE copy at http://www.intelliview.com/go/osdn_nl _______________________________________________ Nant-users mailing list Nant-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/nant-users