FileDocCategorySizeDatePackage
Dirname.javaAPI DocApache Ant 1.702415Wed Dec 13 06:16:18 GMT 2006org.apache.tools.ant.taskdefs

Dirname

public class Dirname extends org.apache.tools.ant.Task
Determines the directory name of the specified file. This task can accept the following attributes:
  • file
  • property
Both file and property are required.

When this task executes, it will set the specified property to the value of the specified file up to, but not including, the last path element. If file is a file, the directory will be the current directory.

since
Ant 1.5
ant.task
category="property"

Fields Summary
private File
file
private String
property
Constructors Summary
Methods Summary
public voidexecute()
Execute this task.

throws
BuildException on error

        if (property == null) {
            throw new BuildException("property attribute required", getLocation());
        }
        if (file == null) {
            throw new BuildException("file attribute required", getLocation());
        } else {
            String value = file.getParent();
            getProject().setNewProperty(property, value);
        }
    
public voidsetFile(java.io.File file)
Path to take the dirname of.

param
file a File value

        this.file = file;
    
public voidsetProperty(java.lang.String property)
The name of the property to set.

param
property the name of the property

        this.property = property;