How to get classifier name from Maven properties?

What is the easiest way to get the classifier name from Maven properties and use it as a variable in pom.xml ?

For instance:

 <properties> <final_jar>${project.build.finalName}-${classifier}.jar</final_jar> </properties> 

The description of the official documentation does not mention the property of the classifier.

Looking at the source of the maven-jar-plugin , it seems that it gets it from a property called maven.jar.classifier , but it does not seem to be available outside the plugin. Is there any way to access it?

+6
source share
1 answer

Although the classifier is mentioned in the POM Reference, Maven Coordinates , it must be declared in the maven-jar-plugin . So you call it not part of the <project> element Model .

Unfortunately, I have not yet found a way to access the maven.jar.classifier property maven-jar-plugin , but 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 are a Properties properties in Maven Model's superclass ModelBase . But if it is not used by the plugin ...

And also there is no property interpolation syntax (yet?), For example:

 ${project.build.plugins.plugin[<G>:<A>:<V>].<property>} 
+1
source

Source: https://habr.com/ru/post/982795/


All Articles