如何指定 sbt 依赖关系以及预期的 JDK 版本
How to specify sbt dependency along with the intended JDK version
如何在 Build.sbt
中指定依赖项的 JDK 版本?
我在 Aspose 库中遇到过这种情况,其中文件名后缀为 JDK 版本,即 aspose-email-4.8.0-jdk17.jar
而不是普通的 aspose-email-4.8.0.jar
。因此,通常指定依赖关系,例如
"com.aspose" % "aspose-email" % "4.8.0"
会导致 sbt 抱怨以下错误,因为可怜的 SBT 试图下载一个不存在的文件:
[warn] [FAILED ] com.aspose#aspose-email;4.8.0!aspose-email.jar: (0ms)
[warn] ==== local: tried
[warn] /Users/developer/.ivy2/local/com.aspose/aspose-email/4.8.0/jars/aspose-email.jar
[warn] ==== public: tried
[warn] https://repo1.maven.org/maven2/com/aspose/aspose-email/4.8.0/aspose-email-4.8.0.jar
[warn] ==== Aspose: tried
[warn] http://maven.aspose.com/artifactory/simple/ext-release-local/com/aspose/aspose-email/4.8.0/aspose-email-4.8.0.jar
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: FAILED DOWNLOADS ::
[warn] :: ^ see resolution messages for details ^ ::
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: com.aspose#aspose-email;4.8.0!aspose-email.jar
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
sbt.ResolveException: download failed: com.aspose#aspose-email;4.8.0!aspose-email.jar
更新
然后我认为将 JDK 版本附加到版本号可能会修复它:
"com.aspose" % "aspose-email" % "4.8.0-jdk17"
不幸的是,它会导致 SBT 认为 POM 文件位于 aspose-email-4.8.0-jdk17.pom
而导致的另一个错误,而它应该是 aspose-email-4.8.0.pom
.
[info] Resolving com.aspose#aspose-email;4.8.0-jdk17 ...
[warn] module not found: com.aspose#aspose-email;4.8.0-jdk17
[warn] ==== local: tried
[warn] /Users/ganeshwara/.ivy2/local/com.aspose/aspose-email/4.8.0-jdk17/ivys/ivy.xml
[warn] ==== public: tried
[warn] https://repo1.maven.org/maven2/com/aspose/aspose-email/4.8.0-jdk17/aspose-email-4.8.0-jdk17.pom
[warn] ==== Aspose: tried
[warn] http://maven.aspose.com/artifactory/simple/ext-release-local/com/aspose/aspose-email/4.8.0-jdk17/aspose-email-4.8.0-jdk17.pom
[info] Resolving net.sf.proguard#proguard-base;5.1 ...
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: UNRESOLVED DEPENDENCIES ::
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: com.aspose#aspose-email;4.8.0-jdk17: not found
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn]
[warn] Note: Unresolved dependencies path:
[warn] com.aspose:aspose-email:4.8.0-jdk17 (/Users/ganeshwara/DropMyEmail/backup-server/project/Build.scala#L290)
[warn] +- Dropmysite:common_2.11:1.0-296020c84e74fa1fd65cd5361b563519ff9c4a5d
sbt.ResolveException: unresolved dependency: com.aspose#aspose-email;4.8.0-jdk17: not found
我想如果你查看 repo,你会发现问题是由于不同的命名约定造成的——jar 文件后缀有预期的 JDK 版本,但 POM 文件不是。
谷歌搜索后,我发现 Maven 实际上有一个可选的额外坐标,即 分类器 ,它紧跟在版本号 (source) 之后.
要在 sbt 中使用它,您应该将依赖项定义为
"com.aspose" % "aspose-email" % "4.8.0" classifier "jdk17"
(source)
如何在 Build.sbt
中指定依赖项的 JDK 版本?
我在 Aspose 库中遇到过这种情况,其中文件名后缀为 JDK 版本,即 aspose-email-4.8.0-jdk17.jar
而不是普通的 aspose-email-4.8.0.jar
。因此,通常指定依赖关系,例如
"com.aspose" % "aspose-email" % "4.8.0"
会导致 sbt 抱怨以下错误,因为可怜的 SBT 试图下载一个不存在的文件:
[warn] [FAILED ] com.aspose#aspose-email;4.8.0!aspose-email.jar: (0ms)
[warn] ==== local: tried
[warn] /Users/developer/.ivy2/local/com.aspose/aspose-email/4.8.0/jars/aspose-email.jar
[warn] ==== public: tried
[warn] https://repo1.maven.org/maven2/com/aspose/aspose-email/4.8.0/aspose-email-4.8.0.jar
[warn] ==== Aspose: tried
[warn] http://maven.aspose.com/artifactory/simple/ext-release-local/com/aspose/aspose-email/4.8.0/aspose-email-4.8.0.jar
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: FAILED DOWNLOADS ::
[warn] :: ^ see resolution messages for details ^ ::
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: com.aspose#aspose-email;4.8.0!aspose-email.jar
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
sbt.ResolveException: download failed: com.aspose#aspose-email;4.8.0!aspose-email.jar
更新 然后我认为将 JDK 版本附加到版本号可能会修复它:
"com.aspose" % "aspose-email" % "4.8.0-jdk17"
不幸的是,它会导致 SBT 认为 POM 文件位于 aspose-email-4.8.0-jdk17.pom
而导致的另一个错误,而它应该是 aspose-email-4.8.0.pom
.
[info] Resolving com.aspose#aspose-email;4.8.0-jdk17 ...
[warn] module not found: com.aspose#aspose-email;4.8.0-jdk17
[warn] ==== local: tried
[warn] /Users/ganeshwara/.ivy2/local/com.aspose/aspose-email/4.8.0-jdk17/ivys/ivy.xml
[warn] ==== public: tried
[warn] https://repo1.maven.org/maven2/com/aspose/aspose-email/4.8.0-jdk17/aspose-email-4.8.0-jdk17.pom
[warn] ==== Aspose: tried
[warn] http://maven.aspose.com/artifactory/simple/ext-release-local/com/aspose/aspose-email/4.8.0-jdk17/aspose-email-4.8.0-jdk17.pom
[info] Resolving net.sf.proguard#proguard-base;5.1 ...
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: UNRESOLVED DEPENDENCIES ::
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: com.aspose#aspose-email;4.8.0-jdk17: not found
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn]
[warn] Note: Unresolved dependencies path:
[warn] com.aspose:aspose-email:4.8.0-jdk17 (/Users/ganeshwara/DropMyEmail/backup-server/project/Build.scala#L290)
[warn] +- Dropmysite:common_2.11:1.0-296020c84e74fa1fd65cd5361b563519ff9c4a5d
sbt.ResolveException: unresolved dependency: com.aspose#aspose-email;4.8.0-jdk17: not found
我想如果你查看 repo,你会发现问题是由于不同的命名约定造成的——jar 文件后缀有预期的 JDK 版本,但 POM 文件不是。
谷歌搜索后,我发现 Maven 实际上有一个可选的额外坐标,即 分类器 ,它紧跟在版本号 (source) 之后.
要在 sbt 中使用它,您应该将依赖项定义为
"com.aspose" % "aspose-email" % "4.8.0" classifier "jdk17"
(source)