Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

maven property ${project.artifact.selectedVersion.majorVersion}

Tags:

java

maven

I see in many pom.xml files the use of this property: ${project.artifact.selectedVersion.majorVersion}

such as in:

<project>
  <modelVersion>4.0.0</modelVersion>

  <groupId>my_group</groupId>
  <artifactId>my_artifact</artifactId>
  <packaging>pom</packaging>
  <version>1.2.3-SNAPSHOT</version>

  <properties>
     <ver>${project.artifact.selectedVersion.majorVersion}</ver>
...

This property is not in the standard maven: http://docs.codehaus.org/display/MAVENUSER/MavenPropertiesGuide

So, where is this variable defined?

I see that it has the build-helper-maven-plugin plugin: http://mojo.codehaus.org/build-helper-maven-plugin/parse-version-mojo.html

which can parse the variable into majorVersion and minorVersion, but the default defaultPrefix is parsedVersion.{majorVersion, minorVersion}, instead of project.artifact.selectedVersion.{majorVersion, minorVersion}... (and the defaultPrefix is not defined in those pom.xml files that I am looking at)

so, where is the variable ${project.artifact.selectedVersion.majorVersion} defined?

like image 852
David Portabella Avatar asked Apr 30 '13 14:04

David Portabella


1 Answers

The thing to do is usually to start from the MavenProject JavaDocs and click through the property path.

MavenProject -> .getArtifact() -> Artifact -> .getSelectedVersion() -> ArtifactVersion -> .getMajorVersion()

For every XML Element in a pom.xml, there is a corresponding JavaBean Property in MavenProject, and periods delimit paths to properties of properties.

like image 119
Sean Patrick Floyd Avatar answered Sep 26 '22 18:09

Sean Patrick Floyd