I want to create a jar file without SNAPSHOT cause when i used this command
mvn -f pom.XML package
created two files "file name_SNAPSHOT.jar and file name_SNAPSHOT_WITH_dependencies.jar" I want file name.jar i know that i should edit in pom.XML so i tried to add this
<plugin>
<groupId>org.Apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
but it created file name_SNAPSHOT_source.jar how can i solve it ?!
My pom.XML like that
<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">
<model Version>4.0.0</model Version>
<group Id>MyProject</group Id>
<artifact Id>MyProject</artifact Id>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
The proper way is to change project.version
. But this is not recommended because development jar should has version with suffix -SNAPSHOT
.
Maven goes a long way to help you with version management and you will often see the SNAPSHOT designator in a version, which indicates that a project is in a state of development.
More information:
Other solution without changing project.version
is to use property finalName
. This solution removes whole version
from artifact.
<build>
<finalName>${project.artifactId}</finalName>
</build>
After applying your pom.xml
should look like this:
<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">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example.something</groupId>
<artifactId>myproject</artifactId>
<version>0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>My Project<name>
<build>
<finalName>${project.artifactId}</finalName>
</build>
...
</project>
Property finalName
apply also to Maven Assembly Plugin
Read also:
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments