2017-01-04 157 views
0

我與這個掙扎了很長一段時間,所以任何幫助,將不勝感激。
我有具有相關性,我需要樹蔭sbt-assembly公用庫myCommonLib
當我將它發佈到我的地方常春藤回購,我得到2個版本,一個「正常」的一個(像往常一樣),和一個陰涼的一個(使用捆綁的所有依賴),用「 - 裝配」追加,當然。SBT組裝,常春藤,類路徑

問題是,當我用我的「正常」的依賴,我得到NoClassDefFoundError,指的陰影版本!

我試圖從classpath中像這樣完全刪除:

dependencyClasspath in Runtime := { 
    val allFiles: Seq[Attributed[File]] = (dependencyClasspath in Runtime).value 
    allFiles.filterNot(_.data.getName.toLowerCase.contains("-assembly")) 
} 

,但它不工作,還是同樣的錯誤。

<artifact name="myCommonLib_2.11" type="jar" ext="jar" conf="compile,runtime,test,provided,optional,sources,docs,pom" e:classifier="assembly"/> 

我缺少什麼:

然而,當我從常春藤XML它的工作將其刪除(註釋掉)?

回答

0

我已經成功地使其工作,現在...
看來當我指定確切的神器,這樣的工作:

val myCommonLibArtifact = Artifact(
    name="myCommonLib", `type`="jar", extension="jar", classifier=None, 
    configurations=Seq(Compile), url=None, extraAttributes=Map()) 

libraryDependencies ++= Seq(
    "ba.sake" %% "myCommonLib" % "0.0.1" artifacts (myCommonLibArtifact)  
) 
0

你可以在你的構建做這個

libraryDependencies ++= Seq(
    "some" % "myCommonLib" % "1.0" excludeAll(
     ExclusionRule(organization = "yourOrganisation", name = "dependency name"), 
     ... 
) 

這裏必要的文件SBT排除:http://www.scala-sbt.org/0.12.2/api/sbt/ExclusionRule.html

+0

謝謝,但[SBT文檔(http://www.scala-sbt.org/0.13/docs/Library-Management.html#E xclude +傳遞+依賴性)說,「要排除某些**傳遞依賴**的依賴關係,請使用EXCLUDEALL或排除方法」。這不是傳遞依賴,它是模塊本身的一部分..(只是另一個工件) –