You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by "Sean (Xuong) Phu" <dr...@yahoo.com> on 2006/10/14 07:29:35 UTC

Re: build.properties input select

There is an <input> task that you can use to prompt the user. See http://ant.apache.org/manual/CoreTasks/input.html.
  As for concatenating user input with ".home", you can do 
  <property name="finalValue" value="${userInput}.home" />

Edward Mann <ed...@arctechnologies.net> wrote:
  I am trying to build an and build process where the user will run ant
and it will prompt them for the project. The projects are held in the
build.properties file. 
They look like this.

project1.home=/my/project/dev1
project2.home=/my/project/dev2

There are other things in the file but this is all the user will ever
edit. What i want is for the users to type in project2 and the ant
script will checkout from subversion that project and put it in the path
for project2.home.

Is this possible with ant? I would need to append the .home to the end
of the project name so i can get it's home directory. 

Thanks.



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



 		
---------------------------------
How low will we go? Check out Yahoo! Messenger’s low  PC-to-Phone call rates.

Re: build.properties input select

Posted by Edward Mann <ed...@arctechnologies.net>.
Mathieu,

Thanks for your answer it works. I am posting my code here just in case
anyone else is looking for this solution.

in my build.properties file i put the ant-contrib.jar file

ant-contrib.jar=/path/to/ant-contrib.jar

Then in my build.xml file i have the following code
<?xml version="1.0"?>
<project name="svnant" default="svncheckout">
        <!--  all properties are in build.properties -->
          <property file="build.properties" />
        <!-- path to the svnant libraries. Usually they will be located
in ANT_HOME/lib -->
          <path id="project.classpath">
            <pathelement location="${svnjavahl.jar}" />
            <pathelement location="${svnant.jar}" />
            <pathelement location="${svnClientAdapter.jar}" />
            <pathelement location="${ant-contrib.jar}" />
          </path>

          <!-- load the svn task -->
          <taskdef resource="svntask.properties"
classpathref="project.classpath"/>
<!-- contains the propertycopy -->
    <taskdef resource="net/sf/antcontrib/antcontrib.properties"
classpathref="project.classpath" />

        <target name="svncheckout" description="Checkout project from
Subversion.">
                <input message="Please enter Project Name:"
addproperty="project.name" defaultvalue="" />
                <input message="Branch or Tag? (exp. branch/1.0.1a)
default is trunk:" addproperty="bt.path" defaultvalue="trunk" />
                <condition property="abort">
                        <equals arg1="" arg2="${project.name}" />
                </condition>
                <fail if="abort">Build aborted Project name not
specified.</fail>
                <propertycopy name="project.home"
from="${project.name}.home" />
                <echo> project.src = ${project.home} </echo>
                <fail />


This is not the complete script, but enough to give someone an idea on
how it should work.

Take notice of the lines that i add the taskdef. 

Thanks for the help

On Sat, 2006-10-14 at 19:06 +0900, Mathieu Champlon wrote:
> Hello,
> 
> Edward Mann a écrit :
> > (...)
> >                 <property name="project.home" value="${project.name}.home" />
> > (...)
> >   
> 
> Right here you probably want instead something like
> 
>                 <property name="project.home" value="${${project.name}.home}" />
> 
> However you cannot do this as the properties are only evaluated once.
> To solve this you can use the <propertycopy> task from ant-contrib : 
> http://ant-contrib.sourceforge.net/tasks/tasks/propertycopy.html
> 
> So instead you would have :
> 
>                 <propertycopy property="project.home" from="${project.name}.home" />
> 
> 
> I hope this helps.
> 
> 
> MAT.
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
> 


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


Re: build.properties input select

Posted by Mathieu Champlon <m....@free.fr>.
Hello,

Edward Mann a écrit :
> (...)
>                 <property name="project.home" value="${project.name}.home" />
> (...)
>   

Right here you probably want instead something like

                <property name="project.home" value="${${project.name}.home}" />

However you cannot do this as the properties are only evaluated once.
To solve this you can use the <propertycopy> task from ant-contrib : 
http://ant-contrib.sourceforge.net/tasks/tasks/propertycopy.html

So instead you would have :

                <propertycopy property="project.home" from="${project.name}.home" />


I hope this helps.


MAT.

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


Re: build.properties input select

Posted by Edward Mann <ed...@arctechnologies.net>.
I have done that. But my results are not what i expect. Here is my
script.

<?xml version="1.0"?>
<project name="svnant" default="svncheckout">
        <!--  all properties are in build.properties -->
          <property file="build.properties" />
        <!-- path to the svnant libraries. Usually they will be located
in ANT_HOME/lib -->
          <path id="project.classpath">
            <pathelement location="${svnjavahl.jar}" />
            <pathelement location="${svnant.jar}" />
            <pathelement location="${svnClientAdapter.jar}" />
          </path>

          <!-- load the svn task -->
          <taskdef resource="svntask.properties"
classpathref="project.classpath"/>


        <target name="svncheckout" description="Checkout project from
Subversion.">
                <input message="Please enter Project Name:"
addproperty="project.name" defaultvalue="" />
                <input message="Branch or Tag? (exp. branch/1.0.1a)
default is trunk:" addproperty="bt.path" defaultvalue="trunk" />
                <condition property="abort">
                        <equals arg1="" arg2="${project.name}" />
                </condition>
                <fail if="abort">Build aborted Project name not
specified.</fail>
                <property name="project.home"
value="${project.name}.home" />
                <echo> project.home = ${project.home} </echo>
                <fail />
                <property name="dst.dir"    location="${project.name}"/>
                <property name="urlRepos"
value="file:///home/svn/${project.name}/${bt.path}" />
                <svn javahl="TRUE">
                        <checkout url="${urlRepos}"
destPath="${dst.dir}" />
                </svn>
        </target>

I expect to see that path,(/my/project/dev2 but all i see is the project
name plus home. (project2.home)

And this is what executes on my checkout.

I hope this helps clarify more.

Thanks.


On Fri, 2006-10-13 at 22:29 -0700, Sean (Xuong) Phu wrote:
> There is an <input> task that you can use to prompt the user. See http://ant.apache.org/manual/CoreTasks/input.html.
>   As for concatenating user input with ".home", you can do 
>   <property name="finalValue" value="${userInput}.home" />
> 
> Edward Mann <ed...@arctechnologies.net> wrote:
>   I am trying to build an and build process where the user will run ant
> and it will prompt them for the project. The projects are held in the
> build.properties file. 
> They look like this.
> 
> project1.home=/my/project/dev1
> project2.home=/my/project/dev2
> 
> There are other things in the file but this is all the user will ever
> edit. What i want is for the users to type in project2 and the ant
> script will checkout from subversion that project and put it in the path
> for project2.home.
> 
> Is this possible with ant? I would need to append the .home to the end
> of the project name so i can get it's home directory. 
> 
> Thanks.
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
> 
> 
> 
>  		
> ---------------------------------
> How low will we go? Check out Yahoo! Messenger’s low  PC-to-Phone call rates.


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