Hello,
You have to override the execute() method.
Hope it helps,
Emmanuel
>-----Message d'origine-----
>De : Malik, Yousuff M [mailto:Yousuff.M.Malik@erac.com]
>Envoyé : mardi 23 septembre 2003 23:59
>À : Ant Users List
>Objet : Has anyone written an ant task by extending Task
>
>
>
>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
>
>package com.erac.arch.prod.statusweb;
>import org.apache.tools.ant.taskdefs.Property;
>import org.apache.tools.ant.Task;
>import org.apache.tools.ant.BuildException;
>
>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);
> //this.setName(this.value);
> System.out.println("Value is " + value);
> }
>
> public String getValue() {
> return value;
> }
>
> public void setName(String name) {
> this.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="com.erac.arch.prod.statusweb.BuildLabelParser">
> <classpath>
> <pathelement
>location="${libDir}/anttasks.jar"/>
> </classpath>
> </taskdef>
>
> <buildlabelparser name="xyz" value="LRDGUI_2.0.2_3"/>
>
></target>
>
>The output after I execute the target
>
>U:\arch_vob\Products\lrdGUI\antbuild>ant test.parser
>Buildfile: build.xml
>
>test.parser:
>[buildlabelparser] Value is 2.0.2.3
> [echo] LRDGUI_2.0.2_3
>
>Any help would be appreciated?
>
>Regards
>Yousuff Malik
>ERAC
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
>For additional commands, e-mail: user-help@ant.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org
|