2017-08-31 95 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 –