如何排除其它子项目中多建立传递依赖? [英] How to exclude transitive dependencies of other subproject in multiproject builds?
问题描述
在 Build.scala
我有项目之间的依赖关系:
In Build.scala
I have a dependency between projects:
val coreLib = Projects.coreLib()
val consoleApp = Projects.consoleApp().dependsOn(coreLib)
val androidApp = Projects.androidProject().dependsOn(coreLib/*, exclusions = xpp */)
核心库项目定义的 libraryDependencies
(XPP解析器)图书馆,我要排除在 androidApp
由于Android框架有其自己的XPP实现开箱即用的。
Core library project defines a library in its libraryDependencies
(XPP parser), which I want to exclude in androidApp
, since Android framework have its own XPP implementation out of the box.
我怎样才能排除 corelib的
的传递依赖XPP库 androidApp
的项目?
How can I exclude XPP library from transitive dependencies of coreLib
in androidApp
project?
编辑:
根据我的研究排除可能只是为的moduleId
这是用于与 libraryDependency
。与此同时 dependsOn
将所有传递依赖到classpath中,有没有办法在API来排除该项目的一些传递性依赖,你 dependsOn
According to my research exclusion is possible ONLY to ModuleID
which is used in conjunction with libraryDependency
. Meanwhile dependsOn
puts all transitive dependencies to classpath, there is no way in api to exclude some transitive dependencies of this project, you dependsOn
联系方式:
我跑SBT 0.13.5当前。
I'm running sbt 0.13.5 currently.
libraryDependencies
commonLib,以及它在build.sbt供应,使该项目可重新作为独立的,和各种设置,因为它感觉的供应权,自然的方式在 SBT
设置。
libraryDependencies
of commonLib as well as it various settings supplied in build.sbt so that this project could be reused as standalone, and because it feels right and natural way of supplying settings in sbt
.
推荐答案
这似乎为我工作:
val someApp = project.settings(
libraryDependencies += "junit" % "junit" % "4.11"
)
val androidApp = project.dependsOn(someApp).settings(
projectDependencies := {
Seq(
(projectID in someApp).value.exclude("junit", "junit")
)
}
)
什么projectDepenendencies正在做的是什么SBT,在默认情况下,会尝试做。这将任何项目间的依赖关系到的moduleId
■哪些常春藤将解决期间使用。因为项目
API有没有办法目前指定排除,我们绕过这个自动层和手动声明常春藤依赖也是如此。
What the projectDepenendencies is doing is what sbt, by default, attempts to do. It converts any inter-project dependencies into ModuleID
s which Ivy will use during resolution. Because the Project
API has no way to specify excludes currently, we bypass this automatic layer and manually declare the Ivy dependency as well.
结果:
> show someApp/update
...
[info] Update report:
...
[info] compile:
[info] org.scala-lang:scala-library:2.10.4 (): (Artifact(scala-library,jar,jar,None,List(),None,Map()),/home/jsuereth/.sbt/boot/scala-2.10.4/lib/scala-library.jar)
[info] junit:junit:4.11: (Artifact(junit,jar,jar,None,ArraySeq(master),None,Map()),/home/jsuereth/.ivy2/cache/junit/junit/jars/junit-4.11.jar)
[info] org.hamcrest:hamcrest-core:1.3: (Artifact(hamcrest-core,jar,jar,None,ArraySeq(master),None,Map()),/home/jsuereth/.ivy2/cache/org.hamcrest/hamcrest-core/jars/hamcrest-core-1.3.jar)
...
和使用JUnit / hamcrest依赖项目除外:
And the dependent project with junit/hamcrest excluded:
> show androidApp/update
...
[info] Update report:
...
[info] compile:
[info] org.scala-lang:scala-library:2.10.4 (): (Artifact(scala-library,jar,jar,None,List(),None,Map()),/home/jsuereth/.sbt/boot/scala-2.10.4/lib/scala-library.jar)
[info] someapp:someapp_2.10:0.1-SNAPSHOT:
...
这篇关于如何排除其它子项目中多建立传递依赖?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!