Controlling Maven's JAR Artifact Final Name
The final name of a JAR artifact can be customized in Maven to fit specific project requirements.
When defining a property in a super POM to be used by child projects for the destination of the generated artifact, the project/build/finalName property can be leveraged. However, its usage may differ slightly depending on the Maven version being used.
Maven 3 and Later
In Maven 3 and later, setting the finalName property directly in the build section of the POM is sufficient to control the artifact's final name:
<packaging>jar</packaging> <build> <finalName>MyCustomName</finalName> </build>
Older Maven Versions
For older Maven versions, finalName must be set in the configuration section of the Maven JAR plugin:
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-jar-plugin</artifactId> <version>2.3.2</version> <configuration> <finalName>MyCustomName</finalName> </configuration> </plugin>
By specifying the finalName property, the generated artifact will have the customized name, allowing for better organization and control over the generated JAR artifacts.
The above is the detailed content of How to Customize the Final Name of a Maven JAR Artifact?. For more information, please follow other related articles on the PHP Chinese website!