Home >Java >javaTutorial >How to Customize the Final Name of a Maven JAR Artifact?

How to Customize the Final Name of a Maven JAR Artifact?

DDD
DDDOriginal
2024-11-10 07:24:021052browse

How to Customize the Final Name of a Maven JAR Artifact?

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!

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