Basic ANT question

Discussion in 'Java' started by Rob, Feb 4, 2005.

  1. Rob

    Rob Guest

    Let me preface by saying I know nothing about Java development, I'm trying
    to convert some shell scripts over to ANT and have a question. I've used
    ANT for all of about two hours, thus I know nothing about ANT either :).

    This example works:
    <?xml version="1.0"?>
    <project name="RobTest" default="main" basedir="/home/deployer/rob_test">
    <property name="destination" value="/home/deployer/rob_test"/>
    <property name="application" value="BUILDTEST"/>
    <cvs cvsRoot=":pserver:username:password@10.1.1.151:/cvs"
    package="${application}"
    dest="${destination}"
    />
    </project>

    This example does not (note that application.txt contains the text BUILDTEST
    with no carriage return afterwards.
    <?xml version="1.0"?>
    <project name="RobTest" default="main" basedir="/home/deployer/rob_test">
    <loadfile property="application" srcFile="application.txt"/>
    <property name="destination" value="/home/deployer/rob_test"/>
    <cvs cvsRoot=":pserver:username:password@10.1.1.151:/cvs"
    package="${application}"
    dest="${destination}"
    />
    </project>

    The resulting error is:
    [cvs] Using cvs passfile: /home/deployer/.cvspass
    [cvs] cvs server: cannot find module `BUILDTEST
    [cvs] ' - ignored
    [cvs] cvs [checkout aborted]: cannot expand modules

    What simple thing am I missing :). Thanks!
     
    Rob, Feb 4, 2005
    #1
    1. Advertising

  2. On 2005-02-04, Rob <> wrote:
    > Let me preface by saying I know nothing about Java development, I'm trying
    > to convert some shell scripts over to ANT and have a question. I've used
    > ANT for all of about two hours, thus I know nothing about ANT either :).
    >
    > This example works:
    ><?xml version="1.0"?>
    ><project name="RobTest" default="main" basedir="/home/deployer/rob_test">
    ><property name="destination" value="/home/deployer/rob_test"/>
    ><property name="application" value="BUILDTEST"/>
    ><cvs cvsRoot=":pserver:username:password@10.1.1.151:/cvs"
    > package="${application}"
    > dest="${destination}"
    > />
    ></project>
    >
    > This example does not (note that application.txt contains the text BUILDTEST
    > with no carriage return afterwards.
    ><?xml version="1.0"?>
    ><project name="RobTest" default="main" basedir="/home/deployer/rob_test">
    ><loadfile property="application" srcFile="application.txt"/>
    ><property name="destination" value="/home/deployer/rob_test"/>
    ><cvs cvsRoot=":pserver:username:password@10.1.1.151:/cvs"
    > package="${application}"
    > dest="${destination}"
    > />
    ></project>


    > The resulting error is:
    > [cvs] Using cvs passfile: /home/deployer/.cvspass
    > [cvs] cvs server: cannot find module `BUILDTEST
    > [cvs] ' - ignored
    > [cvs] cvs [checkout aborted]: cannot expand modules
    >
    > What simple thing am I missing :). Thanks!


    Sorry, I've never used loadfile, so I can't troubleshoot your
    particular choice of tag.

    The way to set property tags from file, is to use a properties file.


    --- application.properties ---
    # My properties file. Hash marks are for comments.

    application = BUILDTEST
    destination = /home/deployer/rob_test

    # Convention is break up property names with dots as path.

    foo.debug = off
    bar.debug = off
    frobnicator.debug = on

    --- application.properties ---


    Now you can try again with:

    <?xml version="1.0"?>

    <project name="RobTest" default="main" basedir="/home/deployer/rob_test">

    <property file="application.properties"/>

    <!--| Easy debugging. I do this all the time. -->
    <echo message="application = ${application}"/>
    <echo message="destination = ${destination}"/>

    <cvs cvsRoot=":pserver:username:password@10.1.1.151:/cvs"
    package="${application}"
    dest="${destination}"
    />

    </project>

    Cheers

    --
    Alan Gutierrez -
     
    Alan Gutierrez, Feb 4, 2005
    #2
    1. Advertising

  3. Rob wrote:

    > Let me preface by saying I know nothing about Java development, I'm trying
    > to convert some shell scripts over to ANT and have a question. I've used
    > ANT for all of about two hours, thus I know nothing about ANT either :).
    >
    > This example works:
    > <?xml version="1.0"?>
    > <project name="RobTest" default="main" basedir="/home/deployer/rob_test">
    > <property name="destination" value="/home/deployer/rob_test"/>
    > <property name="application" value="BUILDTEST"/>
    > <cvs cvsRoot=":pserver:username:password@10.1.1.151:/cvs"
    > package="${application}"
    > dest="${destination}"
    > />
    > </project>
    >
    > This example does not (note that application.txt contains the text BUILDTEST
    > with no carriage return afterwards.
    > <?xml version="1.0"?>
    > <project name="RobTest" default="main" basedir="/home/deployer/rob_test">
    > <loadfile property="application" srcFile="application.txt"/>
    > <property name="destination" value="/home/deployer/rob_test"/>
    > <cvs cvsRoot=":pserver:username:password@10.1.1.151:/cvs"
    > package="${application}"
    > dest="${destination}"
    > />
    > </project>
    >
    > The resulting error is:
    > [cvs] Using cvs passfile: /home/deployer/.cvspass
    > [cvs] cvs server: cannot find module `BUILDTEST
    > [cvs] ' - ignored
    > [cvs] cvs [checkout aborted]: cannot expand modules
    >
    > What simple thing am I missing :). Thanks!


    I don't know specifically why Ant is exhibiting the behavior you
    describe, but the loadfile task doesn't really appear to be aimed at the
    kind of use you are trying to put it to. Consider instead something like

    <property file="build.properties"/>

    where build.properties contains the line

    application=BUILDTEST

    The build.properties file may contain other properties as well, if you
    wish; each will be loaded into an Ant property of the same name,
    *provided* that no Ant property of that name has yet been set. (Ant
    properties can only be set once during a run, by any means.)

    --
    John Bollinger
     
    John C. Bollinger, Feb 4, 2005
    #3
  4. Rob

    Rob Guest

    Thanks John and Alan, this works even better since I wanted to dynamically
    generate the properties
    via a webpage. Now I can just dump everything into this properties file. I
    tried and it works wonderfully.
    Thanks for the help :).


    "John C. Bollinger" <> wrote in message
    news:cu0gog$vgi$...
    > Rob wrote:
    >
    >> Let me preface by saying I know nothing about Java development, I'm
    >> trying to convert some shell scripts over to ANT and have a question.
    >> I've used ANT for all of about two hours, thus I know nothing about ANT
    >> either :).
    >>
    >> This example works:
    >> <?xml version="1.0"?>
    >> <project name="RobTest" default="main" basedir="/home/deployer/rob_test">
    >> <property name="destination" value="/home/deployer/rob_test"/>
    >> <property name="application" value="BUILDTEST"/>
    >> <cvs cvsRoot=":pserver:username:password@10.1.1.151:/cvs"
    >> package="${application}"
    >> dest="${destination}"
    >> />
    >> </project>
    >>
    >> This example does not (note that application.txt contains the text
    >> BUILDTEST with no carriage return afterwards.
    >> <?xml version="1.0"?>
    >> <project name="RobTest" default="main" basedir="/home/deployer/rob_test">
    >> <loadfile property="application" srcFile="application.txt"/>
    >> <property name="destination" value="/home/deployer/rob_test"/>
    >> <cvs cvsRoot=":pserver:username:password@10.1.1.151:/cvs"
    >> package="${application}"
    >> dest="${destination}"
    >> />
    >> </project>
    >>
    >> The resulting error is:
    >> [cvs] Using cvs passfile: /home/deployer/.cvspass
    >> [cvs] cvs server: cannot find module `BUILDTEST
    >> [cvs] ' - ignored
    >> [cvs] cvs [checkout aborted]: cannot expand modules
    >>
    >> What simple thing am I missing :). Thanks!

    >
    > I don't know specifically why Ant is exhibiting the behavior you describe,
    > but the loadfile task doesn't really appear to be aimed at the kind of use
    > you are trying to put it to. Consider instead something like
    >
    > <property file="build.properties"/>
    >
    > where build.properties contains the line
    >
    > application=BUILDTEST
    >
    > The build.properties file may contain other properties as well, if you
    > wish; each will be loaded into an Ant property of the same name,
    > *provided* that no Ant property of that name has yet been set. (Ant
    > properties can only be set once during a run, by any means.)
    >
    > --
    > John Bollinger
    >
     
    Rob, Feb 4, 2005
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Chris Bedford
    Replies:
    6
    Views:
    2,272
  2. john martin
    Replies:
    2
    Views:
    2,243
    john martin
    Apr 7, 2005
  3. Replies:
    1
    Views:
    540
    Larry
    Mar 7, 2006
  4. Replies:
    6
    Views:
    901
  5. gvanto
    Replies:
    4
    Views:
    453
    Roedy Green
    May 6, 2008
Loading...

Share This Page