2015-01-13 63 views
1

如何在我的Build.sbt中指定JDK版本的依賴關係?如何指定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文件不是。

回答

1

經過一些谷歌搜索後,我發現Maven實際上有一個可選的額外座標,分類器,它緊跟在版本號(source)之後。

要在SBT使用它,你應該定義你的依賴作爲

"com.aspose" % "aspose-email" % "4.8.0" classifier "jdk17" 

source

+0

是的,請參閱更新的答案。 – lolski

+1

@lolski你從哪裏得到這個依賴?它在maven中心 –

+0

這是在http://maven.aspose.com/artifactory/simple/ext-release-local,更具體地說,http://maven.aspose.com/artifactory/simple/ext-release-local /com/aspose/aspose-email/4.8.0/ – lolski

相關問題