ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Malik, Yousuff M" <>
Subject Has anyone written an ant task by extending Task
Date Tue, 23 Sep 2003 21:58:48 GMT

I am trying to write a custom ant task by extending Task. 

My task needs to read a string, parse it and save the value in a property.

I have completed the reading string and the parsing part. I don't know how to set the value
in a property. Can anyone please help me  with this

This is my Class


public class BuildLabelParser extends Task{	

	protected String value;
	protected String name;
	public void setValue(String value){
		//Strip out the build number from the ant label BUILD_LABEL
		String temp2 = value.substring(value.indexOf("_")+1);
		//Convert it into the format x.x.x.x from x.x.x_x
		value = temp2.substring(0,temp2.indexOf("_"))+"."+ temp2.substring(temp2.indexOf("_")+1);

		System.out.println("Value is " + value);
	public String getValue() {
        return value;

	public void setName(String name) { = name;

    public String getName() {
        return name;
    public String toString() {
        return value == null ? "" : value;

This is how I invoke it in the ant script

<target name="test.parser">
		<taskdef name="buildlabelparser" classname="">
				<pathelement location="${libDir}/anttasks.jar"/>

		<buildlabelparser name="xyz" value="LRDGUI_2.0.2_3"/>


The output after I execute the target

U:\arch_vob\Products\lrdGUI\antbuild>ant test.parser
Buildfile: build.xml

[buildlabelparser] Value is
     [echo] LRDGUI_2.0.2_3

Any help would be appreciated?

Yousuff Malik

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message