Return-Path: Delivered-To: apmail-jakarta-ant-dev-archive@jakarta.apache.org Received: (qmail 84455 invoked by uid 500); 6 Sep 2001 11:22:38 -0000 Mailing-List: contact ant-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk Reply-To: ant-dev@jakarta.apache.org list-help: list-unsubscribe: list-post: Delivered-To: mailing list ant-dev@jakarta.apache.org Received: (qmail 84446 invoked from network); 6 Sep 2001 11:22:37 -0000 Message-ID: <3B975BE6.4000409@evtechnology.com> Date: Thu, 06 Sep 2001 12:20:06 +0100 From: Matt Denner Organization: Escape Velocity Technology User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:0.9.2) Gecko/20010628 X-Accept-Language: en-us MIME-Version: 1.0 To: ant-dev@jakarta.apache.org Subject: conditional logic and making it nicely extensible Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Scanner: exiscan *15exFE-0000dZ-00* X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N Dear all, my first mail to this so if i'm out of order or in the wrong place then bash me know :) i have been given the task of maintaining and upgrading our Ant build system. after spending a few days separating out generic tasks into nice files and writing a few new Ant tasks i have come to a point where i really want to get down into the Ant code and make (what i think are) some valuable changes. i have written a couple of neat org.apache.tools.ant.taskdefs.condition.Condition derived classes: * IsPropertySet (that will return true from eval() if the property is set) * IsTargetDefined (that returns true from eval() if the target is defined in the project). around these i've written a class called ConditionWrapper that allows me to extend the condition logic in Ant without having to change the code. so, in my project i might write: to get a condition that, if the 'build.this.now' property is set, will do something. i even updated the ConditionBase class to access an instance of ConditionWrapper so you can do things like . i then had a look at CallTarget (which is the element) and made that have a conditional bit so that i could do: so that the call to the 'build.something' target will only occur if the target exists. suddenly it dawned on me that what i really wanted was something that would allow me to execute different tasks based on a generic condition. something like: which would, if the condition passed (which could be any of the Condition classes) execute the actions, and if it failed would execute the actions. something like: is exactly the same as doing the simple but would offer the ability to set the value of 'file.there' to something if the file is available and something different if it isn't. [ jees, will this guy ever get to the point? ed :) ] finally, here's why this whole message was started: rather than have to create a ConditionalTask class that will have addOr(), addNot(), addXYZ() methods, i'd rather try to make ant handle an addCondition() generically. so my ConditionalTask might look like: public final class ConditionalTask { public void addCondition(final Condition condition) ... } ant addCondition() would be called even if i wrote: ... or: ... or any of the org.apache.tools.ant.taskdefs.condition.Condition derived classes. AFAIK, right now this isn't possible. i have managed to hack a bit at the Ant code to handle this special case but i end up in all sorts of mess and generally get NullPointerExceptions all over the shop. is anyone looking at doing / done similar stuff? does anyone have any guidance for what bits of the Ant code i should be looking at if i want to handle generic methods like addCondition() or addTask()? i'd appreciate all help. Cheers, Matt p.s. i've got several "bug" fixes and stuff that i'd like to contribute back to the source. who do i talk to about the changes i've made (like making elements work across different directories)? ----------------------------------------------------------------------------- Sessami is a trademark of Escape Velocity Technology Mobile Services Limited. All information contained in this e-mail is confidential and for the use of the addressee only. If you receive this message in error please notify.