Understanding the Project Build Final Name
The project.build.finalName property is intended to define the final name of the artifact generated by Maven. However, in certain scenarios, it may not operate as expected. To control this aspect accurately, two approaches are available, one for newer Maven versions and another for older ones.
Maven 3 and Higher
For Maven 3 and subsequent versions, including the current one, the direct manipulation of the finalName property in the
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> ... <packaging>jar</packaging> <build> <finalName>WhateverYouLike</finalName> </build> ... </project>
Older Maven Versions
For older versions of Maven, setting the finalName property in the
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-jar-plugin</artifactId> <version>2.3.2</version> <configuration> <finalName>myJar</finalName> </configuration> </plugin>
This approach ensures the desired final artifact name.
The above is the detailed content of How to Control the Final Name of a Maven JAR Artifact?. For more information, please follow other related articles on the PHP Chinese website!