2014-04-20 64 views
0

我曾經在我的build.sbt文件中爲我的播放定義了我的依賴關係!應用程序,但現在我有多個項目我試着現在我build.scala文件這樣做:sbt maven本地解析器在使用Build.scala時不起作用

resolvers += Resolver.mavenLocal 

val webDependencies = Seq(
.. 
.. 
"com.example" % "blah" % "0.0.1-SNAPSHOT" 
) 

當我嘗試運行或編譯它說,它不能解決由於某種原因的依賴。我在build.sbt中有完全相同的東西,它工作,但現在它在build.scala中不起作用。

錯誤表明這一點:

[info] Resolving com.example#blah;0.0.1-SNAPSHOT ... 
[warn] module not found: com.example#blah;0.0.1-SNAPSHOT 
[warn] ==== local: tried 
[warn] /Users/blankman/.ivy2/local/com.example/blah/0.0.1-SNAPSHOT/ivys/ivy.xml 
[warn] ==== public: tried 
[warn] http://repo1.maven.org/maven2/org/blah/blah/0.0.1-SNAPSHOT/blah-0.0.1-SNAPSHOT.pom 
[warn] ==== Typesafe Releases Repository: tried 
[warn] http://repo.typesafe.com/typesafe/releases/org/blah/blah/0.0.1-SNAPSHOT/blah-0.0.1-SNAPSHOT.pom 
[warn] ==== Typesafe Releases Repository: tried 
[warn] http://repo.typesafe.com/typesafe/releases/org/blah/blah/0.0.1-SNAPSHOT/blah-0.0.1-SNAPSHOT.pom 
[info] Resolving org.fusesource.jansi#jansi;1.4 ... 
[warn] :::::::::::::::::::::::::::::::::::::::::::::: 
[warn] ::   UNRESOLVED DEPENDENCIES   :: 
[warn] :::::::::::::::::::::::::::::::::::::::::::::: 
[warn] :: com.example#blah;0.0.1-SNAPSHOT: not found 
[warn] :::::::::::::::::::::::::::::::::::::::::::::: 

爲什麼它會停止工作,我如何能解決這個問題的任何想法?

回答

2

該解決方案適用於我:

val buildResolvers = resolvers ++= Seq(
    "Local Maven Repository" at "file://"+Path.userHome.absolutePath+"/.m2/repository", 
    "Typesafe Repo"    at "http://repo.typesafe.com/typesafe/releases/", 
    "Sonatype Snapshots"  at "http://oss.sonatype.org/content/repositories/snapshots", 
    "Sonatype Releases"   at "http://oss.sonatype.org/content/repositories/releases" 
) 

def MyProject(name: String) = { 
    Project(id = name, base = file(name)). 
     settings(buildResolvers:_*) 

主要的區別我看到的是,我明確地添加解析器的設置項目。

+0

你能告訴我在文檔的哪裏可以找到設置的所有選項嗎?謝謝! – Blankman

+0

不幸的是沒有。我通過試驗和錯誤的方法學習sbt,並通過查看[akka構建文件](https://github.com/akka/akka/blob/master/project/AkkaBuild.scala)。這是巨大的,但很好地結合了所有'最佳實踐'。 –

+0

和Josh Suereth的精彩演講:http://jsuereth.com/scala/2013/06/11/effective-sbt.html –