Author: brett
Date: Wed Feb 4 10:52:03 2009
New Revision: 740692
URL: http://svn.apache.org/viewvc?rev=740692&view=rev
Log:
[MNG-3760] document ${project.baseuri}, and add a section on POM variables
Modified:
maven/site/trunk/src/site/apt/guides/introduction/introduction-to-the-pom.apt
Modified:
maven/site/trunk/src/site/apt/guides/introduction/introduction-to-the-pom.apt
URL:
http://svn.apache.org/viewvc/maven/site/trunk/src/site/apt/guides/introduction/introduction-to-the-pom.apt?rev=740692&r1=740691&r2=740692&view=diff
==============================================================================
---
maven/site/trunk/src/site/apt/guides/introduction/introduction-to-the-pom.apt
(original)
+++
maven/site/trunk/src/site/apt/guides/introduction/introduction-to-the-pom.apt
Wed Feb 4 10:52:03 2009
@@ -3,8 +3,9 @@
------
Jason van Zyl
Franz Allan Valencia See
+ Brett Porter
------
- 2008-12-23
+ 2009-02-04
------
Introduction to the POM
@@ -37,6 +38,12 @@
[]
+ * {{{./introduction-to-the-pom.html#Project_Interpolation}Project
Interpolation and Expressions}}
+
+ * {{{./introduction-to-the-pom.html#Available_Expressions}Available
Expressions}}
+
+ []
+
[]
* {What is a POM}?
@@ -460,3 +467,61 @@
{{{introduction-to-the-pom.html}[top]}}
+* {Project Interpolation} and Variables
+
+ One of the practices that Maven encourages is <don't repeat yourself>.
However, there are circumstances where you will need to use the same value in
several different locations.
+ To assist in ensuring the value is only specified once, Maven allows you to
use both your own and pre-defined variables in the POM.
+
+ For example, to access the <<<project.version>>> variable, you would
reference it like so:
+
++----+
+ <version>${project.version}</version>
++----+
+
+ One factor to note is that these variables are processed <after> inheritance
as outlined above. This means that if a parent project uses a variable, then
its definition in the child, not the parent, will be the one eventually used.
+
+** {Available Variables}
+
+*** Project Model Variables
+
+ Any field of the model that is a single value element can be referenced as a
variable. For example, <<<$\{project.groupId\}>>>, <<<$\{project.version\}>>>,
<<<$\{project.build.sourceDirectory\}>>> and so on.
+ Refer to the POM reference to see a full list of properties.
+
+ These variables are all referenced by the prefix "<<<project.>>>". You may
also see references with <<<pom.>>> as the prefix, or the prefix omitted
entirely - these forms are now deprecated and should not be used.
+
+*** Special Project Variables
+
+*-----------------------------------+--------------------------------------+
+| <<<basedir>>> | The directory that the current project
resides in. |
+*-----------------------------------+--------------------------------------+
+| <<<project.baseUri>>> | The directory that the current project
resides in, represented as an URI. |
+*-----------------------------------+--------------------------------------+
+
+*** Properties
+
+ You are also able to reference any properties defined in the project as a
variable. Consider the following example:
+
++----+
+<project>
+ ...
+ <properties>
+ <mavenVersion>2.1</mavenVersion>
+ </properties>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-artifact</artifactId>
+ <version>${mavenVersion}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-project</artifactId>
+ <version>${mavenVersion}</version>
+ </dependency>
+ </dependencies>
+ ...
+</project>
++----+
+
+ {{{introduction-to-the-pom.html}[top]}}
+