From 961d431384377a9ec616ead0d4f520e178978b96 Mon Sep 17 00:00:00 2001 From: Peter Donald Date: Sun, 16 Dec 2001 05:12:39 +0000 Subject: [PATCH] Remove if/unless checking from target. It was insanity to have it there in the first place and has been the cause of much confusion. git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@270196 13f79535-47bb-0310-9956-ffa450edef68 --- .../src/main/org/apache/tools/ant/Target.java | 68 +++---------------- .../src/todo/org/apache/tools/ant/Target.java | 68 +++---------------- 2 files changed, 18 insertions(+), 118 deletions(-) diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/Target.java b/proposal/myrmidon/src/main/org/apache/tools/ant/Target.java index 03ecd1138..d273d88b2 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/Target.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/Target.java @@ -17,11 +17,8 @@ import org.apache.myrmidon.api.TaskException; * * @author James Davidson duncan@x180.com */ - public class Target { - private String ifCondition = ""; - private String unlessCondition = ""; private Vector dependencies = new Vector( 2 ); private Vector children = new Vector( 5 ); private String description = null; @@ -71,11 +68,6 @@ public class Target this.description = description; } - public void setIf( String property ) - { - this.ifCondition = ( property == null ) ? "" : property; - } - public void setName( String name ) { this.name = name; @@ -86,11 +78,6 @@ public class Target this.project = project; } - public void setUnless( String property ) - { - this.unlessCondition = ( property == null ) ? "" : property; - } - public Enumeration getDependencies() { return dependencies.elements(); @@ -166,31 +153,18 @@ public class Target public void execute() throws TaskException { - if( testIfCondition() && testUnlessCondition() ) + Enumeration enum = children.elements(); + while( enum.hasMoreElements() ) { - Enumeration enum = children.elements(); - while( enum.hasMoreElements() ) + Object o = enum.nextElement(); + if( o instanceof Task ) + { + Task task = (Task)o; + task.perform(); + } + else { - Object o = enum.nextElement(); - if( o instanceof Task ) - { - Task task = (Task)o; - task.perform(); - } - else - { - } } - } - else if( !testIfCondition() ) - { - project.log( this, "Skipped because property '" + this.ifCondition + "' not set.", - Project.MSG_VERBOSE ); - } - else - { - project.log( this, "Skipped because property '" + this.unlessCondition + "' set.", - Project.MSG_VERBOSE ); } } @@ -207,28 +181,4 @@ public class Target children.setElementAt( o, index ); } } - - private boolean testIfCondition() - throws TaskException - { - if( "".equals( ifCondition ) ) - { - return true; - } - - String test = project.replaceProperties( ifCondition ); - return project.getProperty( test ) != null; - } - - private boolean testUnlessCondition() - throws TaskException - { - if( "".equals( unlessCondition ) ) - { - return true; - } - String test = project.replaceProperties( unlessCondition ); - return project.getProperty( test ) == null; - } - } diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/Target.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/Target.java index 03ecd1138..d273d88b2 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/Target.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/Target.java @@ -17,11 +17,8 @@ import org.apache.myrmidon.api.TaskException; * * @author James Davidson duncan@x180.com */ - public class Target { - private String ifCondition = ""; - private String unlessCondition = ""; private Vector dependencies = new Vector( 2 ); private Vector children = new Vector( 5 ); private String description = null; @@ -71,11 +68,6 @@ public class Target this.description = description; } - public void setIf( String property ) - { - this.ifCondition = ( property == null ) ? "" : property; - } - public void setName( String name ) { this.name = name; @@ -86,11 +78,6 @@ public class Target this.project = project; } - public void setUnless( String property ) - { - this.unlessCondition = ( property == null ) ? "" : property; - } - public Enumeration getDependencies() { return dependencies.elements(); @@ -166,31 +153,18 @@ public class Target public void execute() throws TaskException { - if( testIfCondition() && testUnlessCondition() ) + Enumeration enum = children.elements(); + while( enum.hasMoreElements() ) { - Enumeration enum = children.elements(); - while( enum.hasMoreElements() ) + Object o = enum.nextElement(); + if( o instanceof Task ) + { + Task task = (Task)o; + task.perform(); + } + else { - Object o = enum.nextElement(); - if( o instanceof Task ) - { - Task task = (Task)o; - task.perform(); - } - else - { - } } - } - else if( !testIfCondition() ) - { - project.log( this, "Skipped because property '" + this.ifCondition + "' not set.", - Project.MSG_VERBOSE ); - } - else - { - project.log( this, "Skipped because property '" + this.unlessCondition + "' set.", - Project.MSG_VERBOSE ); } } @@ -207,28 +181,4 @@ public class Target children.setElementAt( o, index ); } } - - private boolean testIfCondition() - throws TaskException - { - if( "".equals( ifCondition ) ) - { - return true; - } - - String test = project.replaceProperties( ifCondition ); - return project.getProperty( test ) != null; - } - - private boolean testUnlessCondition() - throws TaskException - { - if( "".equals( unlessCondition ) ) - { - return true; - } - String test = project.replaceProperties( unlessCondition ); - return project.getProperty( test ) == null; - } - }