Basic ANT question

R

Rob

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:p[email protected]:/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:p[email protected]:/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!
 
A

Alan Gutierrez

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:p[email protected]:/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:p[email protected]:/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:p[email protected]:/cvs"
package="${application}"
dest="${destination}"
/>

</project>

Cheers
 
J

John C. Bollinger

Rob said:
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:p[email protected]:/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:p[email protected]:/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.)
 
R

Rob

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 said:
Rob said:
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:p[email protected]:/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:p[email protected]:/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.)
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top