Hi Ben,
I have solved the problem. I have changed this line

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

and it works. Thanks for your help.

Regards,
Uma

-----Original Message-----
From: Burgess, Benjamin [mailto:[EMAIL PROTECTED]
Sent: Monday, April 17, 2006 6:59 PM
To: Ant Users List
Subject: RE: return Substring from java file


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:[EMAIL PROTECTED]
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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



**************************************************************
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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to