1 18 19 package org.apache.tools.ant.taskdefs; 20 21 import java.io.IOException ; 22 23 import org.apache.tools.ant.Task; 24 import org.apache.tools.ant.BuildException; 25 import org.apache.tools.ant.types.PropertySet; 26 27 51 public class CallTarget extends Task { 52 53 private Ant callee; 54 private boolean inheritAll = true; 56 private boolean inheritRefs = false; 58 59 private boolean targetSet = false; 60 61 66 public void setInheritAll(boolean inherit) { 67 inheritAll = inherit; 68 } 69 70 75 public void setInheritRefs(boolean inheritRefs) { 76 this.inheritRefs = inheritRefs; 77 } 78 79 83 public void init() { 84 callee = new Ant(this); 85 callee.init(); 86 } 87 88 93 public void execute() throws BuildException { 94 if (callee == null) { 95 init(); 96 } 97 if (!targetSet) { 98 throw new BuildException( 99 "Attribute target or at least one nested target is required.", 100 getLocation()); 101 } 102 callee.setAntfile(getProject().getProperty("ant.file")); 103 callee.setInheritAll(inheritAll); 104 callee.setInheritRefs(inheritRefs); 105 callee.execute(); 106 } 107 108 112 public Property createParam() { 113 if (callee == null) { 114 init(); 115 } 116 return callee.createProperty(); 117 } 118 119 125 public void addReference(Ant.Reference r) { 126 if (callee == null) { 127 init(); 128 } 129 callee.addReference(r); 130 } 131 132 137 public void addPropertyset(PropertySet ps) { 138 if (callee == null) { 139 init(); 140 } 141 callee.addPropertyset(ps); 142 } 143 144 148 public void setTarget(String target) { 149 if (callee == null) { 150 init(); 151 } 152 callee.setTarget(target); 153 targetSet = true; 154 } 155 156 161 public void addConfiguredTarget(Ant.TargetElement t) { 162 if (callee == null) { 163 init(); 164 } 165 callee.addConfiguredTarget(t); 166 targetSet = true; 167 } 168 169 177 public void handleOutput(String output) { 178 if (callee != null) { 179 callee.handleOutput(output); 180 } else { 181 super.handleOutput(output); 182 } 183 } 184 185 199 public int handleInput(byte[] buffer, int offset, int length) 200 throws IOException { 201 if (callee != null) { 202 return callee.handleInput(buffer, offset, length); 203 } 204 return super.handleInput(buffer, offset, length); 205 } 206 207 215 public void handleFlush(String output) { 216 if (callee != null) { 217 callee.handleFlush(output); 218 } else { 219 super.handleFlush(output); 220 } 221 } 222 223 232 public void handleErrorOutput(String output) { 233 if (callee != null) { 234 callee.handleErrorOutput(output); 235 } else { 236 super.handleErrorOutput(output); 237 } 238 } 239 240 248 public void handleErrorFlush(String output) { 249 if (callee != null) { 250 callee.handleErrorFlush(output); 251 } else { 252 super.handleErrorFlush(output); 253 } 254 } 255 } 256 | Popular Tags |