简体   繁体   English

我想使用 Maven 从我的 libs 项目文件夹中加载所有 JAR

[英]I want to load all JARs from my libs project folder with Maven

I have a Java project using Maven.我有一个使用 Maven 的 Java 项目。 In my project I have a folder called libs that contains all the JARs that I can't load from internet/external repository.在我的项目中,我有一个名为libs的文件夹,其中包含我无法从 Internet/外部存储库加载的所有 JAR。

My issue is how to specify to Maven to include those JARs during packaging, building etc.?我的问题是如何指定 Maven 在打包、构建等过程中包含这些 JAR?

New to Maven, sorry if it is a stupid question. Maven 新手,抱歉,如果这是一个愚蠢的问题。

EDIT : I have an automatic tool that will look up at my pom.xml on my Git to build & deploy my project on different environments.编辑:我有一个自动工具,可以在我的 Git 上查找我的pom.xml以在不同的环境中构建和部署我的项目。 So adding it in local Maven repo, as suggested here will not help since it will work only on my PC.因此,按照此处的建议将其添加到本地 Maven 存储库中将无济于事,因为它只能在我的 PC 上运行。 If I add a libs folder with my JARs it will work wherever I am.如果我在 JAR 中添加了一个libs文件夹,那么无论我身在何处,它都可以使用。

Ask me in comments if it's not clear or if I'm mistaken.如果不清楚或者我弄错了,请在评论中问我。

Contrary to your EDIT adding to the local Maven repo will help and it can be automated as follows:与您的编辑相反,添加到本地 Maven 存储库有所帮助,并且可以按如下方式自动化:

  • See jtahlborn's answer to Multiple install:install-file in a single pom.xml .请参阅jtahlbornMultiple install:install-file in a single pom.xml的回答 (The current version of the maven-install-plugin is 2.5.2 . I'd use that rather than the default.) maven-install-plugin的当前版本是2.5.2 。我会使用它而不是默认版本。)
  • The <configuration> s should look like: <configuration>应如下所示:

     <configuration> <file>${project.basedir}/path/to/your/libs/lib-X.jar</file> <repositoryLayout>default</repositoryLayout> <!-- match the dependency declaration for this artifact --> <groupId>logan.wlv</groupId> <artifactId>lib-X</artifactId> <version>xyz</version> <packaging>jar</packaging> <!-- -------------------------------------------------- --> </configuration>
  • Put the install-plugin declaration into a build profile , eg lib .install-plugin声明放入构建配置文件中,例如lib

  • Run mvn initialize -P lib once on every new PC (and once after the contents of libs , and hence the install-plugin declaration, changed) before invoking any phase that resolves dependencies first, eg compile .在调用首先解决依赖关系的任何阶段(例如compile )之前,在每台新 PC 上运行mvn initialize -P lib一次(并且在libs的内容之后运行一次,因此install-plugin声明已更改)。

or或者

  • Automate this even further with:通过以下方式进一步自动化:

     <profile> <id>lib</id> <activation> <file> <missing>${settings.localRepository}/logan/wlv/lib-X/xyz/lib-Xx.yzjar</missing> </file> </activation> ... <profile>

    Such being able to run just mvn initialize without the explicit profile activation the very first time.这样就可以在第一次没有显式配置文件激活的情况下只运行mvn initialize

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

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