0

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?

pom.xml

<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.aaa.rfid.scaleandlabel</groupId>
  <artifactId>my-project</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <organization>
    <name>aaa</name>
    <url>www.aaa.lt</url>
  </organization>
  <dependencies>
    <dependency>
        <groupId>org.apache.logging.log4j</groupId>
        <artifactId>log4j-api</artifactId>
        <version>2.11.1</version>
    </dependency>
    <dependency>
        <groupId>org.apache.logging.log4j</groupId>
        <artifactId>log4j-core</artifactId>
        <version>2.11.1</version>
    </dependency>
    <dependency>
        <groupId>org.scream3r</groupId>
        <artifactId>jssc</artifactId>
        <version>2.8.0</version>
    </dependency>
  </dependencies>
</project>
vico
  • 17,051
  • 45
  • 159
  • 315
  • Possible duplicate of [Controlling maven final name of jar artifact](https://stackoverflow.com/questions/4238944/controlling-maven-final-name-of-jar-artifact) – Gerold Broser Nov 04 '18 at 21:17

1 Answers1

1

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.

ernest_k
  • 44,416
  • 5
  • 53
  • 99
  • Where I can find configuration file? Is it pom.xml? – vico Nov 04 '18 at 11:06
  • @vico yes, that snippet goes under `` in your pom.xml file – ernest_k Nov 04 '18 at 11:10
  • Currenly I don't have `build` section at all. Please find my pom.xml in question body. Why? How Eclipse is building? Should I manually add `build` section? – vico Nov 04 '18 at 11:19
  • @vico Just add the build section. What you're having now is based on default configuration. You just have to customize it – ernest_k Nov 04 '18 at 11:21