Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Basic ANT question

Reply
Thread Tools

Basic ANT question

 
 
Rob
Guest
Posts: n/a
 
      02-04-2005
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="server:usernameassword@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="server:usernameassword@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!


 
Reply With Quote
 
 
 
 
Alan Gutierrez
Guest
Posts: n/a
 
      02-04-2005
On 2005-02-04, Rob <(E-Mail Removed)> 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="server:usernameassword@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="server:usernameassword@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="server:usernameassword@10.1.1.151:/cvs"
package="${application}"
dest="${destination}"
/>

</project>

Cheers

--
Alan Gutierrez - http://www.velocityreviews.com/forums/(E-Mail Removed)
 
Reply With Quote
 
 
 
 
John C. Bollinger
Guest
Posts: n/a
 
      02-04-2005
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="server:usernameassword@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="server:usernameassword@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
(E-Mail Removed)
 
Reply With Quote
 
Rob
Guest
Posts: n/a
 
      02-04-2005
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" <(E-Mail Removed)> wrote in message
news:cu0gog$vgi$(E-Mail Removed)...
> 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="server:usernameassword@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="server:usernameassword@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
> (E-Mail Removed)



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem with Ant build file (basic!) gvanto Java 4 05-06-2008 04:00 PM
Run ant script from ant script? lionelv@gmail.com Java 6 07-26-2007 02:12 AM
error runing ant in eclipse ant view yihucd@gmail.com Java 1 03-07-2006 08:39 PM
trouble with Hibernate and Ant (probably just Ant) john martin Java 2 04-07-2005 09:27 PM
wondering how i can launch tomcat from ant without ant hanging... Chris Bedford Java 6 12-23-2004 12:41 AM



Advertisments