What's the easiest way to get the classifier name from Maven's properties and use it as a variable in the pom.xml
?
For example:
<properties>
<final_jar>${project.build.finalName}-${classifier}.jar</final_jar>
</properties>
There is no mention of a classifier property in the official documentation.
Looking at the source of maven-jar-plugin
, it seems that it's getting it from a property called maven.jar.classifier
but it doesn't seem to be available outside the plugin. Is there any way to access it ?
classifier: The classifier distinguishes artifacts that were built from the same POM but differ in content. It is some optional and arbitrary string that - if present - is appended to the artifact name just after the version number.
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.
The name is used for the project used by maven to build the artifact, while the artifact-id is used to identify the artifact that will be built.
finalName: This is the name of the bundled project when it is finally built (sans the file extension, for example: my-project-1.0. jar). It defaults to ${artifactId}-${version}.
Despite of classifier
being mentioned under POM Reference, Maven Coordinates it has to be declared in a maven-jar-plugin
section. So (you name it) it's not part of the <project>
element's Model
.
Unfortunately, I too haven't found a way yet to access the maven.jar.classifier
property of the maven-jar-plugin
but by declaring an extra <project>
property:
<project>
...
<properties>
<jar.classifier>CLASSIFIER</jar.classifier>
</properties>
...
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.6</version>
<configuration>
<classifier>${jar.classifier}</classifier>
</configuration>
</plugin>
...
</project>
There's a Properties properties
in the Maven Model's
superclass ModelBase
. But if it's not used by a plugin...
And there's also no property interpolation syntax (yet?) like:
${project.build.plugins.plugin[<G>:<A>:<V>].<property>}
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