我正在使用QR-Bill 库 v2.5.3。作为其依赖项之一,它使用 range 指定 PDFBox [2.0.0,3.0):
<dependency>
<groupId>org.apache.pdfbox</groupId>
<artifactId>pdfbox</artifactId>
<version>[2.0.0,3.0)</version>
<scope>runtime</scope>
</dependency>
Run Code Online (Sandbox Code Playgroud)
对于 Gradle 项目,依赖关系解析为pdfbox-2.0.24. 对于 Maven 项目,它解析为pdfbox-3.0.0-RC1.
Maven 和 Gradle 对待版本范围的方式真的不同吗?库的正确范围是多少,以便 Gradle 和 Maven 都使用 PDFBox 的最新 2.x 版本,但不使用 3.x 版本(因为它不兼容)?
进一步的调试细节:
Maven项目
https://github.com/manuelbl/SwissQRBill/tree/master/examples/maven_example
% mvn dependency:tree
[INFO] net.codecrete.qrbill:maven-example:jar:1.0-SNAPSHOT
[INFO] \- net.codecrete.qrbill:qrbill-generator:jar:2.5.3:compile
[INFO] +- io.nayuki:qrcodegen:jar:1.7.0:runtime (version selected from constraint [1.6.0,2.0))
[INFO] \- org.apache.pdfbox:pdfbox:jar:3.0.0-RC1:runtime (version selected from constraint [2.0.0,3.0))
[INFO] +- org.apache.pdfbox:fontbox:jar:3.0.0-RC1:runtime
[INFO] \- commons-logging:commons-logging:jar:1.2:runtime
Run Code Online (Sandbox Code Playgroud)
摇篮项目
https://github.com/manuelbl/SwissQRBill/tree/master/examples/gradle_example
% gradle dependencies --configuration runtimeClasspath
runtimeClasspath - Runtime classpath of source set 'main'.
\--- net.codecrete.qrbill:qrbill-generator:2.5.3+ -> 2.5.3
+--- io.nayuki:qrcodegen:[1.6.0,2.0) -> 1.7.0
\--- org.apache.pdfbox:pdfbox:[2.0.0,3.0) -> 2.0.24
+--- org.apache.pdfbox:fontbox:2.0.24
| \--- commons-logging:commons-logging:1.2
\--- commons-logging:commons-logging:1.2
Run Code Online (Sandbox Code Playgroud)
Maven 的排序实现状态比 alpha、beta 和 RC 版本要小于实际版本。这就是您看到这种行为发生的原因。
因此,实际上 pdfbox-3.0.0-RC1 < pdfbox-3.0。
为了完全排除 3.0,您需要排除第一个预发行版。您可以通过一些方法来实现这一目标:
[2.0.,3-阿尔法)
[2.0.0,3.0.0-alpha2)
或者另一个选项 - 这并不理想 - 是将范围的上限指定为 2.x 版本的最新版本:
[2.0.0,2.0.24]
最后一个选项远非很好,因为如果 Apache 发布名为 2.0.25 的 2.x 修订版,Maven 将不会包含它。
| 归档时间: |
|
| 查看次数: |
331 次 |
| 最近记录: |