File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Ant, Maven and Other Build Tools and the fly likes I dont quite get some terms in build.xml Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark "I dont quite get some terms in build.xml" Watch "I dont quite get some terms in build.xml" New topic

I dont quite get some terms in build.xml

xy zhang

Joined: May 18, 2005
Posts: 14
contents in build.xml
<project name="test" default="compile" basedir=".">

<!-- Load all the default properties, and any the user wants -->
<!-- to contribute (without having to type -D or edit this file -->
<property file="${user.home}/" />
<property file="${basedir}/" />
<property file="${basedir}/" />


well, I can find there, but
-I dont know how they define ""?
-what does "user.home" here means?I dont find the definition in this build.xml for "user.home".

Carol Enderlin
Ranch Hand

Joined: Oct 10, 2000
Posts: 1364
user.home is the user's home directory.

I added a target with an echo to your build snippet without doing anything to set the user.home:

A property that isn't set in the build or properties file can also be sent in on command-line with -D. Or you can override a built-in value.

What's your question about
Roseanne Zhang
Ranch Hand

Joined: Nov 14, 2000
Posts: 1953
Here is an FAQ for your question:

The only thing I need to add is what Carol Enderlin mentioned:

ant -Dpswd=newpassword

This pswd will prevail.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 17421

There are a number of predefined properties in Ant. user.home is one of them (look in the online Ant manual for the complete list). is just a standard Java proeprties file that's being used to load more properties into Ant.

One tricky thing about Ant properties: Unlike most systems, the FIRST setter of the property wins. This means that you can do things like load user-local properties first, then project properties, then hardcoded (build.xml) properties, and the user properties override the project and hardcoded properties, and the project properties override the harcoded properties. And, of course, properties defined as one-shots on the Ant command line take precedence over all (e.g.: "-Dbuild.type=production").

This can be vary useful. For example, I can use the same build.xml to build against different tomcat release libraries and to set different project directory paths on my local (Windows XP) and test (Solaris) boxes just by setting appropriate property overrides.

An IDE is no substitute for an Intelligent Developer.
xy zhang

Joined: May 18, 2005
Posts: 14

All your answers are very helpful!
I agree. Here's the link:
subject: I dont quite get some terms in build.xml
It's not a secret anymore!