com.rshtech.ant.taskdefs
Class VersionTask

java.lang.Object
  extended by org.apache.tools.ant.ProjectComponent
      extended by org.apache.tools.ant.Task
          extended by com.rshtech.ant.taskdefs.VersionTask
All Implemented Interfaces:
java.lang.Cloneable

public class VersionTask
extends org.apache.tools.ant.Task

Version extracts a version tag from a source file or a compiled class in the classpath. Version is useful when you want to store the version number of your application in a class file for use within the app; you can then reuse this information with your build system via Version.

Usage from within ant is straight-forward:

     <taskdef name="version"
        classname="com.rshtech.ant.Version">
        <classpath>
            ...
        </classpath>
    </taskdef>

    <version sourceclass="your.stuff.Version" versionproperty="test.version"/>

    <echo level="info">test.version == ${test.version}</echo>

    <version sourcefile="src/your/stuff/Version.java" versionproperty="test.version2"/>

    <echo level="info">test.version2 == ${test.version2}</echo>
 
If you do not specify the versionproperty, it defaults to "project.version."

Version:
$Revision: 3134 $
Author:
$Author: kostya $

Field Summary
static java.lang.String DEFAULT_VERSION_PROPERTY
           
static java.lang.String VERSION_FIELD_NAME
           
static java.lang.String VERSION_PATTERN
           
 
Fields inherited from class org.apache.tools.ant.Task
target, taskName, taskType, wrapper
 
Fields inherited from class org.apache.tools.ant.ProjectComponent
description, location, project
 
Constructor Summary
VersionTask()
           
 
Method Summary
 void execute()
           
 void executeForClass()
           
 void executeForJava()
           
 java.lang.Class<?> getSourceClass()
           
 java.io.File getSourceFile()
           
 java.lang.String getVersionProperty()
           
 void setSourceClass(java.lang.Class<?> sourceClass)
           
 void setSourceFile(java.io.File sourceFile)
           
 void setVersionProperty(java.lang.String versionProperty)
           
 
Methods inherited from class org.apache.tools.ant.Task
bindToOwner, getOwningTarget, getRuntimeConfigurableWrapper, getTaskName, getTaskType, getWrapper, handleErrorFlush, handleErrorOutput, handleFlush, handleInput, handleOutput, init, isInvalid, log, log, log, log, maybeConfigure, perform, reconfigure, setOwningTarget, setRuntimeConfigurableWrapper, setTaskName, setTaskType
 
Methods inherited from class org.apache.tools.ant.ProjectComponent
clone, getDescription, getLocation, getProject, setDescription, setLocation, setProject
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_VERSION_PROPERTY

public static final java.lang.String DEFAULT_VERSION_PROPERTY
See Also:
Constant Field Values

VERSION_FIELD_NAME

public static final java.lang.String VERSION_FIELD_NAME
See Also:
Constant Field Values

VERSION_PATTERN

public static final java.lang.String VERSION_PATTERN
See Also:
Constant Field Values
Constructor Detail

VersionTask

public VersionTask()
Method Detail

execute

public void execute()
             throws org.apache.tools.ant.BuildException
Overrides:
execute in class org.apache.tools.ant.Task
Throws:
org.apache.tools.ant.BuildException

executeForClass

public void executeForClass()
                     throws org.apache.tools.ant.BuildException
Throws:
org.apache.tools.ant.BuildException

executeForJava

public void executeForJava()
                    throws org.apache.tools.ant.BuildException
Throws:
org.apache.tools.ant.BuildException

getSourceFile

public java.io.File getSourceFile()

setSourceFile

public void setSourceFile(java.io.File sourceFile)

getSourceClass

public java.lang.Class<?> getSourceClass()

setSourceClass

public void setSourceClass(java.lang.Class<?> sourceClass)

getVersionProperty

public java.lang.String getVersionProperty()

setVersionProperty

public void setVersionProperty(java.lang.String versionProperty)