ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Uma Maheswar" <kalluru.mahes...@psidata.com>
Subject return Substring from java file
Date Mon, 17 Apr 2006 13:13:38 GMT

Hi,

I wanted to do "substring" and get the resultant string in the build.xml
file. This is my java code

import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Task;
import java.io.File;

public class AntHelper extends Task {

    private String message;

    public void execute() throws BuildException {
        message = message.substring(message.lastIndexOf(File.separator)+1,
message.length());
        System.out.println("In Java::"+message);
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public String getMessage(){
        return message;
    }

    public void addText(String message) {
        this.message = message;
    }

    public String createMessage() {
        return message;
    }
}

And this is my build.xml file

    <target name="build" depends="compile" description="compile and generate
the war file" >

    	<taskdef name="mytask" classname="AntHelper" classpath="${antFiles}"/>
    	<mytask message1="${basedir}"/>
    </target>


The reason I am doing this is in my project I am having different modules
and each module will have a common build.xml file. I wanted to generate
the "base directory" name as the "WAR file name".

I get the value printed in the console, but I need the value in the
build.xml file so that I can set the war file name dynamically

       <jar jarfile="${refLocation}/xx.war" basedir="${build.dir}"/>

Any clues please?

Regards,
Uma


Disclaimer: The information contained in this communication is intended solely for the individual
or entity to which it is addressed. It may contain confidential and/or legally privileged
information. Any review, retransmission, dissemination or other use of, or taking any action
in reliance on the contents of this information by persons or entities other than the intended
recipient is strictly prohibited and may be unlawful. If you have received this communication
in error, please notify us immediately by responding to this email and then delete it from
your system. Aditya Birla Group Companies attempts to sweep e-mails and attachments for viruses,
it does not guarantee that either are virus free and that we accept no liability for any damage
sustained as a result of viruses.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Mime
View raw message