ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jacob Kjome <h...@visi.com>
Subject RE: How to return a value from <antcall>
Date Sat, 24 May 2003 13:36:27 GMT

These tasks would be really handy!  Have you thought about contributing 
them to something like the ant-contrib project?  That way, there would be a 
standard distribution where someone could access these useful tasks.

Jake

At 12:56 PM 5/23/2003 -0700, you wrote:
>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
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
>For additional commands, e-mail: user-help@ant.apache.org

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message