ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Burgess, Benjamin" <BBurg...@tiaa-cref.org>
Subject RE: return Substring from java file
Date Mon, 17 Apr 2006 13:29:25 GMT
Firstly, this seems best suited in a macrodef that can set a property
rather than in a custom task.

Secondly, doesn't this already do what you want? :

<basename file="${basedir}" property="warName"/>

Ben

-----Original Message-----
From: Uma Maheswar [mailto:kalluru.maheswar@psidata.com] 
Sent: Monday, April 17, 2006 9:14 AM
To: user@ant.apache.org
Subject: return Substring from java file


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



**************************************************************
This message, including any attachments, contains confidential information intended for a
specific individual and purpose, and is protected by law.  If you are not the intended recipient,
please contact sender immediately by reply e-mail and destroy all copies.  You are hereby
notified that any disclosure, copying, or distribution of this message, or the taking of any
action based on it, is strictly prohibited.
TIAA-CREF
**************************************************************


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


Mime
View raw message