1 18 19 package org.apache.tools.ant.taskdefs; 20 21 import java.io.File ; 22 import org.apache.tools.ant.BuildException; 23 import org.apache.tools.ant.Task; 24 25 45 46 public class Dirname extends Task { 47 private File file; 48 private String property; 49 50 54 public void setFile(File file) { 55 this.file = file; 56 } 57 58 62 public void setProperty(String property) { 63 this.property = property; 64 } 65 66 67 71 public void execute() throws BuildException { 72 if (property == null) { 73 throw new BuildException("property attribute required", getLocation()); 74 } 75 if (file == null) { 76 throw new BuildException("file attribute required", getLocation()); 77 } else { 78 String value = file.getParent(); 79 getProject().setNewProperty(property, value); 80 } 81 } 82 } 83 84 | Popular Tags |