1 18 package org.apache.tools.ant.taskdefs.optional.dotnet; 19 20 import org.apache.tools.ant.BuildException; 21 import org.apache.tools.ant.Task; 22 import org.apache.tools.ant.Project; 23 24 29 public class DotnetDefine { 30 private String name; 31 private String ifCond; 32 private String unlessCond; 33 34 35 40 public void setIf(String condition) { 41 this.ifCond = condition; 42 } 43 44 49 public void setUnless(String condition) { 50 this.unlessCond = condition; 51 } 52 53 57 public String getName() { 58 return name; 59 } 60 61 65 public void setName(String name) { 66 this.name = name; 67 } 68 69 76 public String getValue(Task owner) throws BuildException { 77 if (name == null) { 78 throw new BuildException("No name provided for the define element", 79 owner.getLocation()); 80 } 81 if (!isSet(owner)) { 82 return null; 83 } 84 return name; 85 } 86 87 88 93 public boolean isSet(Task owner) { 94 Project p = owner.getProject(); 95 if (ifCond != null && p.getProperty(ifCond) == null) { 96 return false; 97 } else if (unlessCond != null && p.getProperty(unlessCond) != null) { 98 return false; 99 } 100 return true; 101 } 102 } 103 | Popular Tags |