Maven Settings Properties. You can also reference any properties in the Maven Local Settings file which is usually stored in ~/. m2/settings. xml.
Maven properties are value placeholders, like properties in Ant. Their values are accessible anywhere within a POM by using the notation ${X}, where X is the property. Or they can be used by plugins as default values, for example: In your case you have defined properties as version of java.
Custom Properties It can define the properties on pom. xml between <properties></properties> tags.
project. basedir : The directory that the current project resides in. This means this points to where your Maven projects resides on your system. It corresponds to the location of the pom.
Do you mean this one?
https://web.archive.org/web/20150520200505/https://docs.codehaus.org/display/MAVENUSER/MavenPropertiesGuide
I also moved its content to a GitHub repo:
https://github.com/cko/predefined_maven_properties/blob/master/README.md
Take a look at section 9.2.: Maven Properties of the free online book Maven: The Complete Reference.
Looking at the "effective POM" will probably help too. For instance, if you wanted to know what the path is for ${project.build.sourceDirectory}
you would find the related XML in the effective POM, such as:
<project>
<build>
<sourceDirectory>/my/path</sourceDirectory>
Also helpful - you can do a real time evaluation of properties via the command line execution of mvn help:evaluate
while in the same dir as the POM.
I think the best place to look is the Super POM.
As an example, at the time of writing, the linked reference shows some of the properties between lines 32 - 48.
The interpretation of this is to follow the XPath as a .
delimited property.
So, for example:
${project.build.testOutputDirectory}
== ${project.build.directory}/test-classes
And:
${project.build.directory}
== ${project.basedir}/target
Thus combining them, we find:
${project.build.testOutputDirectory}
== ${project.basedir}/target/test-classes
(To reference the resources directory(s), see this stackoverflow question)
<project>
<modelVersion>4.0.0</modelVersion>
.
.
.
<build>
<directory>${project.basedir}/target</directory>
<outputDirectory>${project.build.directory}/classes</outputDirectory>
<finalName>${project.artifactId}-${project.version}</finalName>
<testOutputDirectory>${project.build.directory}/test-classes</testOutputDirectory>
<sourceDirectory>${project.basedir}/src/main/java</sourceDirectory>
<scriptSourceDirectory>src/main/scripts</scriptSourceDirectory>
<testSourceDirectory>${project.basedir}/src/test/java</testSourceDirectory>
<resources>
<resource>
<directory>${project.basedir}/src/main/resources</directory>
</resource>
</resources>
<testResources>
<testResource>
<directory>${project.basedir}/src/test/resources</directory>
</testResource>
</testResources>
.
.
.
</build>
.
.
.
</project>
I got tired of seeing this page with its by-now stale references to defunct Codehaus pages so I asked on the Maven Users mailing list and got some more up-to-date answers.
I would say that the best (and most authoritative) answer contained in my link above is the one contributed by Hervé BOUTEMY:
here is the core reference: http://maven.apache.org/ref/3-LATEST/maven-model-builder/
it does not explain everyting that can be found in POM or in settings, since there are so much info available but it points to POM and settings descriptors and explains everything that is not POM or settings
This link shows how to list all the active properties: http://skillshared.blogspot.co.uk/2012/11/how-to-list-down-all-maven-available.html
In summary, add the following plugin definition to your POM, then run mvn install
:
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.7</version>
<executions>
<execution>
<phase>install</phase>
<configuration>
<target>
<echoproperties />
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With