Create jar file from maven

user3188912

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>
MariuszS

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.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Is there a way to create maven dependency in pom file from a local jar

From Dev

Create JAR with one file in Maven

From Dev

Create JAR with one file in Maven

From Dev

To create a single executable jar file Maven

From Dev

Executing a JAR file straight from a Maven repository

From Dev

Get .jar file from local maven repository

From Dev

read a scala conf file from a maven jar

From Dev

Using Maven to create Javadocs as a zip file instead of a jar file

From Dev

Using Maven to create Javadocs as a zip file instead of a jar file

From Dev

create windows service from jar file

From Dev

How to Create a jar file from github project

From Dev

how to create a jar file from android studio

From Dev

How to Create a C Library from a jar File?

From Dev

Create jar file from openfire plugin

From Dev

Need to create Java JAR file and add it to Maven Dependency

From Dev

How to create a executable jar file using Maven and Netbeans

From Dev

maven: create a jar from generated sources and add it as a dependency before compiling

From Dev

Maven - Create runnable jar and extract classes from dependent libraries

From Dev

maven: how to build the dependency from source.jar to jar files and put the jar file as it dependency?

From Dev

How to add Maven dependency jar file from the lib folder

From Dev

Exclude META-INF/maven folder from the generated jar file

From Dev

How to run Maven Failsafe integration tests from a jar file?

From Dev

download and execute jar file from remote maven repository

From Dev

Import and use an exernal jar file from maven using bazel

From Dev

How to read properties file from external jar in maven project

From Dev

Using maven assembly plugin to create ZIP file containing a fat jar (jar-with-dependencies)

From Dev

How to create a exe file from jar file for database application in Java?

From Dev

How to create windows service from jar file and how to call it from another jar file?

From Dev

Maven Create Jar and exclude Files

Related Related

  1. 1

    Is there a way to create maven dependency in pom file from a local jar

  2. 2

    Create JAR with one file in Maven

  3. 3

    Create JAR with one file in Maven

  4. 4

    To create a single executable jar file Maven

  5. 5

    Executing a JAR file straight from a Maven repository

  6. 6

    Get .jar file from local maven repository

  7. 7

    read a scala conf file from a maven jar

  8. 8

    Using Maven to create Javadocs as a zip file instead of a jar file

  9. 9

    Using Maven to create Javadocs as a zip file instead of a jar file

  10. 10

    create windows service from jar file

  11. 11

    How to Create a jar file from github project

  12. 12

    how to create a jar file from android studio

  13. 13

    How to Create a C Library from a jar File?

  14. 14

    Create jar file from openfire plugin

  15. 15

    Need to create Java JAR file and add it to Maven Dependency

  16. 16

    How to create a executable jar file using Maven and Netbeans

  17. 17

    maven: create a jar from generated sources and add it as a dependency before compiling

  18. 18

    Maven - Create runnable jar and extract classes from dependent libraries

  19. 19

    maven: how to build the dependency from source.jar to jar files and put the jar file as it dependency?

  20. 20

    How to add Maven dependency jar file from the lib folder

  21. 21

    Exclude META-INF/maven folder from the generated jar file

  22. 22

    How to run Maven Failsafe integration tests from a jar file?

  23. 23

    download and execute jar file from remote maven repository

  24. 24

    Import and use an exernal jar file from maven using bazel

  25. 25

    How to read properties file from external jar in maven project

  26. 26

    Using maven assembly plugin to create ZIP file containing a fat jar (jar-with-dependencies)

  27. 27

    How to create a exe file from jar file for database application in Java?

  28. 28

    How to create windows service from jar file and how to call it from another jar file?

  29. 29

    Maven Create Jar and exclude Files

HotTag

Archive