更新时间:2023-01-10 11:36:48
我看到三个选项:
provided
.system
scope trick (i.e. declare the dependencies with a system scope and set the path to the jars in your file system.system
scope.干净的方法是选择#1,但其他方法在您的情况下也可以使用.选项#3似乎是您所寻找的最接近的东西.
The clean way is option #1 but others would work too in your case. Option #3 seems be the closest to what you're looking for.
更新:要阐明选项#3
假设您有一个包含 a.jar
和 b.jar
的目录.创建一个 c.jar
,并在META-INF/MANIFEST.MF
列表中的Class-Path
条目中列出其他罐子,如下所示:
Let's say you have a directory with a.jar
and b.jar
. Create a c.jar
with a Class-Path
entry in its META-INF/MANIFEST.MF
listing other jars, something like this:
Class-Path: ./a.jar ./b.jar
然后在具有system
范围的c
(并且仅在c
)上的POM中声明一个依赖项,其他jar将变为可见",而无需在您的POM中明确列出它们(请确保您需要在清单中声明它们,但这可以很容易地编写为脚本).
Then declare a dependency in your POM on c
(and only on c
) with a system
scope, other jars will become "visible" without having to explicitly list them in your POM (sure, you need to declare them in the manifest but this can be very easily scripted).