Using maven package in Eclipse

2298 views java
6

I have Java Maven project in Eclipse. When I do maven build and set goal to package maven builds jar file with name my-project-0.0.1-SNAPSHOT.jar. I need package to be always constant name since I put it system that starts it with script. my-project.jar would be fine. How to achieve that?

How to ask maven to put all jar libraries my project is using into my-project.jar?

How to ask maven to place my-project.jar into particular folder target/ready_release. Currently maven puts jar into target folder. How to ask maven copy all libraries and configuration files project is using into this folder too.

Maybe I'm mistaking and all these jobs should be done under some other maven goal or any other operation?

answered question

1 Answer

4

You can specify the name of the package by configuring the jar plugin:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-jar-plugin</artifactId>
    <version>3.1.0</version>
    <configuration>
        <finalName>ready_release/my-project</finalName>                   
    </configuration>
</plugin> 

This will create the jar file at <project-root>/target/ready_release/jar-name.jar and every subsequent build will overwrite it.

posted this

Have an answer?

JD

Please login first before posting an answer.