ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mark Imel" <...@imelshire.com>
Subject RE: How to return a value from <antcall>
Date Fri, 23 May 2003 19:56:48 GMT
I've asked the same question before with no answers... so i wrote a couple
of tasks... (See below)
Hope this helps.
Here's how it's used:

<!-- declare them -->
<taskdef name="setreturn" classname="com.arranger.jarl.ant.SetReturnValue">
 <classpath refid="class.path"/>
</taskdef>
<taskdef name="getreturn" classname="com.arranger.jarl.ant.GetReturnValue">
 <classpath refid="class.path"/>
</taskdef>

<target name="testPrompt">
	<antcall target="promptUser" />
	<getreturn name="valueSelected"/>
	<echo message="${valueSelected}"/>
</target>

<target name="promptUser">
	<!-- prompt user -->
	<input message="Enter Vluae" addproperty="value.selected"/>
	<setreturn name="valueSelected" value="${value.selected}"/>
</target>




******************GetReturnValue*********************
public class GetReturnValue extends Task {

    protected String m_name;

    public String getName() {
        return m_name;
    }

    public void setName(String name) {
        m_name = name;
    }

    /**
     * Uses system.properties to get return values
     * @throws BuildException
     */
    public void execute() throws BuildException {
        //set project property
        String value = System.getProperty(m_name);
        if (value != null) {
            project.setUserProperty(m_name, value);
        }
    }
}

******************SetReturnValue*********************
public class SetReturnValue extends Task {

    protected String m_name;
    protected String m_value;

    public String getName() {
        return m_name;
    }

    public void setName(String name) {
        m_name = name;
    }

    public String getValue() {
        return m_value;
    }

    public void setValue(String value) {
        m_value = value;
    }

    /**
     * Uses system.properties to pass return values
     * @throws BuildException
     */
    public void execute() throws BuildException {
        //set system property
        System.setProperty(m_name, m_value);
    }
}


-----Original Message-----
From: plim [mailto:pengster@correlationtech.com]
Sent: Friday, May 23, 2003 12:43 PM
To: Ant-User@Jakarta. Apache. Org
Subject: How to return a value from <antcall>


Hi all,
I have a target called "get.branch.tag" that prompts the user to enter a
cvs branch tag.
How can I return the user's input back to the calling target?

This tag will be used to update my sources from cvs via a <cvs
command="${branch.tag}" ..../>.

pengster



Mime
View raw message