My linux world » Maven predefined properties

Maven predefined properties


By default maven has some predefined properties. They are all defined in :
${MAVEN_HOME}/lib/maven-model-builder.jar!org/apache/maven/model/pom-4.0.0.xml

Example pom.xml

<project>
      <modelVersion>4.0.0</modelVersion>
      <groupId>com.mycompany.myapp</groupId>
      <artifactId>my-module</artifactId>
      <name>my-module name</name>
      <version>1.0.0-SNAPSHOT</version>
 
	  <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>${project.basedir}/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>
Project model variables
Property Value
${project.basedir} directory (full path) that contains the pom.xml
${project.groupId} the project groupId (i.e. com.mycompany.myapp)
${project.artifactId} the project artifactId (i.e. my-module)
${project.name} the project name (i.e. my-module name)
${project.version} the project version (i.e. 1.0.0-SNAPSHOT)
${project.build.directory} ${project.basedir}/target
${project.build.outputDirectory} ${project.build.directory}/classes
${project.build.finalName} ${project.artifactId}-${project.version}
${project.build.testOutputDirectory} ${project.build.directory}/test-classes
${project.build.sourceDirectory} ${project.basedir}/src/main/java
${project.build.scriptSourceDirectory} ${project.basedir}/src/main/scripts
${project.build.testSourceDirectory} ${project.basedir}/src/test/java
${project.build.resources[0].directory} ${project.basedir}/src/main/resources
${project.build.testResources[0].directory} ${project.basedir}/src/test/resources

Copyright © 2023 My linux world - by Marc RABAHI
Design by Marc RABAHI and encelades.

Fork me on GitHub