Return-Path: Delivered-To: apmail-jakarta-ant-dev-archive@jakarta.apache.org Received: (qmail 26117 invoked by uid 500); 11 May 2001 22:36:29 -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 26104 invoked from network); 11 May 2001 22:36:27 -0000 Sender: ageo@mail.hereuare.com Message-ID: <3AFC5297.ADDE7578@hereuare.com> Date: Fri, 11 May 2001 13:59:03 -0700 From: Alan George X-Mailer: Mozilla 4.72 [en] (X11; U; Linux 2.2.14-5.0 i686) X-Accept-Language: en MIME-Version: 1.0 To: ant-dev@jakarta.apache.org Subject: PATCH: if and unless attributes for Tasks Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Spam-Rating: h31.sny.collab.net 1.6.2 0/1000/N Index: jakarta-ant/src/main/org/apache/tools/ant/Target.java =================================================================== RCS file: /home/cvspublic/jakarta-ant/src/main/org/apache/tools/ant/Target.java,v retrieving revision 1.17 diff -r1.17 Target.java 150,166c150,176 < try { < project.fireTaskStarted(task); < task.maybeConfigure(); < task.execute(); < project.fireTaskFinished(task, null); < } < catch(RuntimeException exc) { < if (exc instanceof BuildException) { < BuildException be = (BuildException) exc; < if (be.getLocation() == Location.UNKNOWN_LOCATION) { < be.setLocation(task.getLocation()); < } < } < project.fireTaskFinished(task, exc); < throw exc; < } < } --- > try { > project.fireTaskStarted(task); > task.maybeConfigure(); > > if (task.testIfCondition() && task.testUnlessCondition()) { > task.execute(); > } else if (!task.testIfCondition()) { > project.log(this, "Task skipped because property '" + task.getIf() + "' not set.", > Project.MSG_VERBOSE); > } else { > project.log(this, "Task skipped because property '" + task.getUnless() + "' set.", > Project.MSG_VERBOSE); > } > > project.fireTaskFinished(task, null); > } > catch(RuntimeException exc) { > if (exc instanceof BuildException) { > BuildException be = (BuildException) exc; > if (be.getLocation() == Location.UNKNOWN_LOCATION) { > be.setLocation(task.getLocation()); > } > } > project.fireTaskFinished(task, exc); > throw exc; > } > } 168c178 < project.log(this, "Skipped because property '" + this.ifCondition + "' not set.", --- > project.log(this, "Target skipped because property '" + this.ifCondition + "' not set.", 171c181 < project.log(this, "Skipped because property '" + this.unlessCondition + "' set.", --- > project.log(this, "Target skipped because property '" + this.unlessCondition + "' set.", Index: jakarta-ant/src/main/org/apache/tools/ant/Task.java =================================================================== RCS file: /home/cvspublic/jakarta-ant/src/main/org/apache/tools/ant/Task.java,v retrieving revision 1.17 diff -r1.17 Task.java 71a72,73 > protected String ifCondition = ""; > protected String unlessCondition = ""; 169a172,187 > public void setIf( String property ) { > ifCondition=(property == null) ? "" : property; > } > > public String getIf() { > return ifCondition; > } > > public void setUnless( String property ) { > unlessCondition=(property == null) ? "" : property; > } > > public String getUnless() { > return unlessCondition; > } > 222a241,251 > > public boolean testIfCondition() { > return "".equals(ifCondition) > || project.getProperty(ifCondition) != null; > } > > public boolean testUnlessCondition() { > return "".equals(unlessCondition) > || project.getProperty(unlessCondition) == null; > } >