简体   繁体   English

在Eclipse中使用Maven包

[英]Using maven package in Eclipse

I have Java Maven project in Eclipse. 我在Eclipse中有Java Maven项目。 When I do maven build and set goal to package maven builds jar file with name my-project-0.0.1-SNAPSHOT.jar . 当我执行maven build并将目标设置为package maven构建名称为my-project-0.0.1-SNAPSHOT.jar 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. my-project.jar会很好。 How to achieve that? 如何实现呢?

How to ask maven to put all jar libraries my project is using into my-project.jar ? 如何让Maven将我的项目正在使用的所有jar库放入my-project.jar

How to ask maven to place my-project.jar into particular folder target/ready_release . 如何要求maven将my-project.jar放入特定文件夹target/ready_release Currently maven puts jar into target folder. 目前,maven将jar放入target文件夹。 How to ask maven copy all libraries and configuration files project is using into this folder too. 如何要求maven将所有库和配置文件复制到该文件夹​​中。

Maybe I'm mistaking and all these jobs should be done under some other maven goal or any other operation? 也许我误会了,所有这些工作都应该在其他一些目标或其他任何操作下完成?

pom.xml 的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>

You can specify the name of the package by configuring the jar plugin: 您可以通过配置jar插件来指定软件包的名称:

<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. 这将在<project-root>/target/ready_release/jar-name.jar创建jar文件,随后的所有构建都将覆盖它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM