## org.apache.tools.ant.taskdefs
Class Basename

    java.lang.Object
      org.apache.tools.ant.ProjectComponent
          org.apache.tools.ant.Task
              org.apache.tools.ant.taskdefs.Basename

public class Basename
extends Task

Sets a property to the base name of a specified file, optionally minus a suffix. This task can accept the following attributes:

- file
- property
- suffix

The file and property attributes are required. The suffix attribute can be specified either with or without the ".", and the result will be the same (ie., the returned file name will be minus the .suffix).

When this task executes, it will set the specified property to the value of the last element in the specified file. If file is a directory, the basename will be the last directory element. If file is a full-path filename, the basename will be the simple file name. If a suffix is specified, and the specified file ends in that suffix, the basename will be the simple file name without the suffix.

Since:
  Ant 1.5
Version:
  $Revision: 1.2.2.5 $
Author:
  Diane Holt holtdl@apache.org

Field Summary

Fields inherited from class org.apache.tools.ant.Task
`description, location, target, taskName, taskType, wrapper`

Fields inherited from class org.apache.tools.ant.ProjectComponent
`project`

Constructor Summary
`Basename()`

Method Summary
`void` `execute()` Called by the project to let the task do its work.
`void` `setFile(java.io.File file)` File or directory to get base name from.
`void` `setProperty(java.lang.String property)` Property to set base name to.
`void` `setSuffix(java.lang.String suffix)` Optional suffix to remove from base name.

Methods inherited from class org.apache.tools.ant.Task
`getDescription, getLocation, getOwningTarget, getRuntimeConfigurableWrapper, getTaskName, handleErrorFlush, handleErrorOutput, handleFlush, handleOutput, init, isInvalid, log, log, maybeConfigure, perform, setDescription, setLocation, setOwningTarget, setRuntimeConfigurableWrapper, setTaskName`

Methods inherited from class org.apache.tools.ant.ProjectComponent
`getProject, setProject`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### Basename

    public Basename()

Method Detail

### setFile

    public void setFile(java.io.File file)

  File or directory to get base name from.

### setProperty

    public void setProperty(java.lang.String property)

  Property to set base name to.

### setSuffix

    public void setSuffix(java.lang.String suffix)

  Optional suffix to remove from base name.

### execute

    public void execute()
                 throws BuildException

  Description copied from class: `Task`
  Called by the project to let the task do its work. This method may be called more than once, if the task is invoked more than once. For example, if target1 and target2 both depend on target3, then running "ant target1 target2" will run all tasks in target3 twice.

  Overrides:
    `execute` in class `Task`
  Throws:
    `BuildException` - if something goes wrong with the build

Copyright © 2000-2003 Apache Software Foundation. All Rights Reserved.