java – Maven:指向多个jar的系统依赖关系

前端之家收集整理的这篇文章主要介绍了java – Maven:指向多个jar的系统依赖关系前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
是否可以在pom中定义一个依赖关系,以便它具有系统的范围,但指向多个jar?

我相信这是非常非正统的,但是,我只是想知道这是否可能.所以这样的东西:

<dependency>
  <groupId>foo</groupId>
  <artifactId>foo</artifactId>
  <version>1.0</version>
  <scope>system</scope>
  <systemPath>${basedir}/lib/foo/*.jar</systemPath>
</dependency>

解决方法

首先(我永远不会重复),使用系统范围的依赖关系是不鼓励的,除非你确切地知道你在做什么.从 Dependency Scopes

system: This dependency is required in some phase of your
project’s lifecycle,but is
system-specific. Use of this scope
is discouraged: This is considered an
“advanced” kind of feature and should
only be used when you truly understand
all the ramifications of its use,
which can be extremely hard if not
actually impossible to quantify
.
This scope by definition renders your
build non-portable. It may be
necessary in certain edge cases. The
system scope includes the
<systemPath> element which points to
the physical location of this
dependency on the local machine. It is
thus used to refer to some artifact
expected to be present on the given
local machine an not in a repository;
and whose path may vary
machine-to-machine. The systemPath
element can refer to environment
variables in its path: ${JAVA_HOME}
for instance.

现在,为了严格地回答你的问题,如果依赖关系在其Class-Path条目中相对地列出了一个MANIFEST.MF,则列出一个指向几个jar的系统范围的依赖关系是可能的.这样的东西(假设“根”依赖在lib中):

Class-Path: ../lib/bar.jar ../lib/foo.jar

但我不推荐这种方法,特别是在你的具体情况下.相反,请看这个previous answer,我将介绍如何设置基于文件的存储库.

原文链接:https://www.f2er.com/java/124534.html

猜你在找的Java相关文章