Home  >  Article  >  Java  >  How to control the final name of Maven JAR artifacts?

How to control the final name of Maven JAR artifacts?

Susan Sarandon
Susan SarandonOriginal
2024-11-12 15:59:02983browse

How to control the final name of Maven JAR artifacts?

Controlling the Final Name of Maven JAR Artifacts

In Maven, the finalName property allows developers to specify the final name of the generated JAR artifact, which is used for both the file name and the artifact identifier in repositories.

Understanding the Issue

The provided example sets the finalName property in the section of the pom.xml. However, you may encounter issues where the modified artifact name is not reflected in the generated JAR file.

Solution

If you are using Maven 3 or later, you can set the finalName property directly in the section of the pom.xml, as demonstrated in the provided code snippet:

<build>
    <finalName>WhatEverYouLikey</finalName>
</build>

For older versions of Maven, you will need to configure the finalName property within the Maven Jar Plugin configuration section:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-jar-plugin</artifactId>
    <configuration>
        <finalName>myJar</finalName>
    </configuration>
</plugin>

By following these instructions, you can modify the final name of the JAR artifact to meet your specific requirements.

The above is the detailed content of How to control the final name of Maven JAR artifacts?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn