2017-08-31 135 views
0

我有一個ScalaJS項目在IntelliJ中內置了SBT,我想在其中包含一個基於Leaflet庫的滑動地圖。ScalaJS項目:SBT依賴於傳單未解決

我使用ScalaJS版本0.6.19和SBT版本0.13.7

build.sbt如下:

import com.lihaoyi.workbench.Plugin.{bootSnippet, updateBrowsers} 

enablePlugins(ScalaJSPlugin) 

workbenchSettings 

name := "WeatherReport" 
version := "0.1-SNAPSHOT" 

scalaVersion := "2.11.11" 

libraryDependencies ++= Seq(
    "org.scala-js" %%% "scalajs-dom"  % "0.9.1" 
    ,"org.scala-js" %%% "scalajs-java-time" % "0.2.2" 
    ,"com.lihaoyi"  %%% "scalatags"   % "0.6.5" 
    ,"org.webjars.npm" %%% "leaflet"   % "0.7.7" 
) 

bootSnippet := "com.sap.demo.WeatherReport().main(document.getElementById('weatherDiv'));" 

updateBrowsers <<= updateBrowsers.triggeredBy(fastOptJS in Compile) 

這一切,直到我說上leaflet最後的依賴工作的罰款。現在SBT抱怨:

Error:Error while importing SBT project: 
... 
[info] Resolving org.eclipse.jetty#jetty-util;8.1.16.v20140903 ... 
[info] Resolving org.eclipse.jetty#jetty-io;8.1.16.v20140903 ... 
[info] Resolving org.eclipse.jetty#jetty-http;8.1.16.v20140903 ... 
[info] Resolving org.eclipse.jetty#jetty-server;8.1.16.v20140903 ... 
[info] Resolving org.eclipse.jetty.orbit#javax.servlet;3.0.0.v201112011016 ... 
[info] Resolving org.eclipse.jetty#jetty-continuation;8.1.16.v20140903 ... 
[warn] :::::::::::::::::::::::::::::::::::::::::::::: 
[warn] ::   UNRESOLVED DEPENDENCIES   :: 
[warn] :::::::::::::::::::::::::::::::::::::::::::::: 
[warn] :: org.webjars.npm#leaflet_sjs0.6_2.11;0.7.7: not found 
[warn] :::::::::::::::::::::::::::::::::::::::::::::: 
[warn] 
[warn] Note: Unresolved dependencies path: 
[warn]  org.webjars.npm:leaflet_sjs0.6_2.11:0.7.7 (/Developer/Scala/weather-report/build.sbt#L13-19) 
[warn]  +- weatherreport:weatherreport_sjs0.6_2.11:0.1-SNAPSHOT 
[trace] Stack trace suppressed: run 'last *:ssExtractDependencies' for the full output. 
[trace] Stack trace suppressed: run 'last *:update' for the full output. 
[error] (*:ssExtractDependencies) sbt.ResolveException: unresolved dependency: org.webjars.npm#leaflet_sjs0.6_2.11;0.7.7: not found 
[error] (*:update) sbt.ResolveException: unresolved dependency: org.webjars.npm#leaflet_sjs0.6_2.11;0.7.7: not found 
[error] Total time: 1 s, completed 31-Aug-2017 10:26:54 

由於FAS一個我可以從leaflet entry的WebJars網站上說,我已經得到了組/神器/版本正確的信息。

我不清楚爲什麼錯誤消息已將「_sjs0.6_2.11」添加到庫名稱中。這是因爲需要一些特定於ScalaJS的傳單版本?

感謝

克里斯W¯¯

回答

0

你混淆了Webjars,這是包含的.js發表了Maven的,有Scala.js庫,這也.jar文件Maven的發佈庫.jar文件,但包含Scala的。 js'.sjsir文件。

根據在Webjars的JS庫通常與一個Scala.js SBT構建jsDependencies完成,libraryDependencies。因此,他們也應該使用%而不是%%%。例如:

jsDependencies += "org.webjars.npm" % "leaflet" % "0.7.7"/"dist/leaflet.js" 

現在您可能還希望Scala.js外牆使用靜態類型與Leaflet對話。幸運的是,such a facade library already exists。由於外觀庫是一個Scala.js庫(與Webjar中的JS庫相反),因此它將在libraryDependencies中指定,其中%%%。然而,這個特定的圖書館似乎尚未在Maven Central上發佈,因此您可能必須自己在本地發佈它。

+0

謝謝你,但我仍然在這裏失去了一些東西。 現在,我已經添加了jsDependencies行,我收到其他錯誤消息說: [提醒] \t注:未解決的依賴路徑: [提醒] \t \t org.webjars.npm:傳單:0.7.7 ( (org.scalajs.sbtplugin.ScalaJSPluginInternal)ScalaJSPluginInternal.scala#L996) [警告] \t \t + - weatherreport:weatherreport_sjs0.6_2.11:0.1-SNAPSHOT 然而,用於單頁的POM文件存在於Maven的https://開頭repo1.maven.org/maven2/org/webjars/npm/leaflet/0.7.7/leaflet-0.7.7.pom –

+0

不,對不起。這是(not-so-)IntelliJ中的代理問題。如果我從我的公司VPN斷開連接並將IntelliJ設置爲無代理,那麼它可以工作... Grrrr –