git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@270196 13f79535-47bb-0310-9956-ffa450edef68remotes/1776816827838153613/tmp_25f451bd36ab3145e487fcb2cd5c62c571e5b602
| @@ -17,11 +17,8 @@ import org.apache.myrmidon.api.TaskException; | |||||
| * | * | ||||
| * @author James Davidson <a href="mailto:duncan@x180.com">duncan@x180.com</a> | * @author James Davidson <a href="mailto:duncan@x180.com">duncan@x180.com</a> | ||||
| */ | */ | ||||
| public class Target | public class Target | ||||
| { | { | ||||
| private String ifCondition = ""; | |||||
| private String unlessCondition = ""; | |||||
| private Vector dependencies = new Vector( 2 ); | private Vector dependencies = new Vector( 2 ); | ||||
| private Vector children = new Vector( 5 ); | private Vector children = new Vector( 5 ); | ||||
| private String description = null; | private String description = null; | ||||
| @@ -71,11 +68,6 @@ public class Target | |||||
| this.description = description; | this.description = description; | ||||
| } | } | ||||
| public void setIf( String property ) | |||||
| { | |||||
| this.ifCondition = ( property == null ) ? "" : property; | |||||
| } | |||||
| public void setName( String name ) | public void setName( String name ) | ||||
| { | { | ||||
| this.name = name; | this.name = name; | ||||
| @@ -86,11 +78,6 @@ public class Target | |||||
| this.project = project; | this.project = project; | ||||
| } | } | ||||
| public void setUnless( String property ) | |||||
| { | |||||
| this.unlessCondition = ( property == null ) ? "" : property; | |||||
| } | |||||
| public Enumeration getDependencies() | public Enumeration getDependencies() | ||||
| { | { | ||||
| return dependencies.elements(); | return dependencies.elements(); | ||||
| @@ -166,31 +153,18 @@ public class Target | |||||
| public void execute() | public void execute() | ||||
| throws TaskException | 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 ); | 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; | |||||
| } | |||||
| } | } | ||||
| @@ -17,11 +17,8 @@ import org.apache.myrmidon.api.TaskException; | |||||
| * | * | ||||
| * @author James Davidson <a href="mailto:duncan@x180.com">duncan@x180.com</a> | * @author James Davidson <a href="mailto:duncan@x180.com">duncan@x180.com</a> | ||||
| */ | */ | ||||
| public class Target | public class Target | ||||
| { | { | ||||
| private String ifCondition = ""; | |||||
| private String unlessCondition = ""; | |||||
| private Vector dependencies = new Vector( 2 ); | private Vector dependencies = new Vector( 2 ); | ||||
| private Vector children = new Vector( 5 ); | private Vector children = new Vector( 5 ); | ||||
| private String description = null; | private String description = null; | ||||
| @@ -71,11 +68,6 @@ public class Target | |||||
| this.description = description; | this.description = description; | ||||
| } | } | ||||
| public void setIf( String property ) | |||||
| { | |||||
| this.ifCondition = ( property == null ) ? "" : property; | |||||
| } | |||||
| public void setName( String name ) | public void setName( String name ) | ||||
| { | { | ||||
| this.name = name; | this.name = name; | ||||
| @@ -86,11 +78,6 @@ public class Target | |||||
| this.project = project; | this.project = project; | ||||
| } | } | ||||
| public void setUnless( String property ) | |||||
| { | |||||
| this.unlessCondition = ( property == null ) ? "" : property; | |||||
| } | |||||
| public Enumeration getDependencies() | public Enumeration getDependencies() | ||||
| { | { | ||||
| return dependencies.elements(); | return dependencies.elements(); | ||||
| @@ -166,31 +153,18 @@ public class Target | |||||
| public void execute() | public void execute() | ||||
| throws TaskException | 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 ); | 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; | |||||
| } | |||||
| } | } | ||||