Wednesday, September 19, 2007

hierarchy of properties files

In fact, Maven has a hierarchy of properties files which you can use to customize a build for a specific project or a specific user. Maven reads properties from the following sources, in the order shown:

${basedir}/project.properties
This file is a sibling to both maven.xml and project.xml. This file customizes behavior for a particular project.

${basedir}/build.properties
This file is also a sibling to maven.xml and project.xml, but this file is used to customize a specific project's build for a specific user. If you need to change the value of a property for your own build environment but you don't want to affect the properties of other users, add a build.properties file to ${basedir}. Values defined in this file will override values defined in project.properties. build.properties should not be checked into source control; this file is for an individual user to tailor the behavior of a specific project.

${user.home}/build.properties
Your home directory can contain a build.properties file which contains user-specific properties to be used on all projects. This is the proper file in which to configure properties for a proxy server or a remote repository. Properties defined in this file are read for every project, and they supersede the values set in the previous two files.

System properties (specified with the -D flag)
Setting the value of a property on the command line supersedes all other configuration files. This is the final stop for properties.

No comments: