Top Description Fields Constructors Methods
org.apache.tools.ant.taskdefs

public Class BuildNumber

extends Task
Class Inheritance
Imports
java.io.File, .IOException, .InputStream, .OutputStream, java.nio.file.Files, java.util.Properties, org.apache.tools.ant.BuildException, .Task, org.apache.tools.ant.util.FileUtils

Read, increment, and write a build number in a file It will first attempt to read a build number from a file, then set the property "build.number" to the value that was read in (or 0 if no such value). Then it will increment the build number by one and write it back out into the file.
Since
Ant 1.5

Field Summary

Modifier and TypeField and Description
private static final String
DEFAULT_FILENAME

The default filename to use if no file specified.

private static final String
DEFAULT_PROPERTY_NAME

The name of the property in which the build number is stored.

private static final FileUtils
private File
myFile

The File in which the build number is stored.

Inherited from org.apache.tools.ant.Task:
targettaskNametaskTypewrapper

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
private int

Returns:

the build number or if no number in properties object
getBuildNumber
(final Properties
the properties to retrieve build number from
properties
)

Utility method to retrieve build number from properties object.

private Properties

Returns:

the loaded properties
loadProperties
()

Utility method to load properties from file.

public void
setFile(final File
the file in which build number is stored.
file
)

The file in which the build number is stored.

private void
validate()

Validate that the task parameters are valid.

Inherited from org.apache.tools.ant.Task:
bindToOwnergetOwningTargetgetRuntimeConfigurableWrappergetTaskNamegetTaskTypegetWrapperhandleErrorFlushhandleErrorOutputhandleFlushhandleInputhandleOutputinitisInvalidloglogloglogmaybeConfigureperformreconfiguresetOwningTargetsetRuntimeConfigurableWrappersetTaskNamesetTaskType

Field Detail

DEFAULT_FILENAMEback to summary
private static final String DEFAULT_FILENAME

The default filename to use if no file specified.

DEFAULT_PROPERTY_NAMEback to summary
private static final String DEFAULT_PROPERTY_NAME

The name of the property in which the build number is stored.

FILE_UTILSback to summary
private static final FileUtils FILE_UTILS
myFileback to summary
private File myFile

The File in which the build number is stored.

Constructor Detail

BuildNumberback to summary
public BuildNumber()

Method Detail

executeback to summary
public void execute() throws BuildException

Overrides org.apache.tools.ant.Task.execute.

Run task.

Annotations
@Override
Exceptions
BuildException:
if an error occurs
getBuildNumberback to summary
private int getBuildNumber(final Properties properties) throws BuildException

Utility method to retrieve build number from properties object.

Parameters
properties:Properties

the properties to retrieve build number from

Returns:int

the build number or if no number in properties object

Exceptions
BuildException:
if build.number property is not an integer
loadPropertiesback to summary
private Properties loadProperties() throws BuildException

Utility method to load properties from file.

Returns:Properties

the loaded properties

Exceptions
BuildException:
if something goes wrong
setFileback to summary
public void setFile(final File file)

The file in which the build number is stored. Defaults to "build.number" if not specified.

Parameters
file:File

the file in which build number is stored.

validateback to summary
private void validate() throws BuildException

Validate that the task parameters are valid.

Exceptions
BuildException:
if parameters are invalid