Monday 8 July 2019

Maven: Refer a property in pom.xml


You can access a property by using $ symbol followed by the property placed in curly braces.

Ex
<finalName>${project.groupId}-${project.artifactId}-${project.version}</finalName>

pom.xml
<project>
   <modelVersion>4.0.0</modelVersion>
   <groupId>selfLearningJava</groupId>
   <artifactId>helloworld</artifactId>
   <packaging>jar</packaging>
   <version>1</version>
   <name>helloworld</name>
   
   <build>
  <finalName>${project.groupId}-${project.artifactId}-${project.version}</finalName>
   </build>
</project>

Go to the location where the 'pom.xml' file is located and run 'mvn help:effective-pom' command.

In the output, you can observe finaName value is changed like below.


<finalName>selfLearningJava-helloworld-1</finalName>



Previous                                                    Next                                                    Home

No comments:

Post a Comment