dependsOn can now be used inside a .sbt file for a subproject

This commit is contained in:
Anatoly Fayngelerin 2016-06-29 16:47:27 -04:00
parent aa5d8c139d
commit fcedd17270
7 changed files with 33 additions and 4 deletions

View File

@ -4,12 +4,13 @@ import internals.{
DslEntry,
DslConfigs,
DslEnablePlugins,
DslDisablePlugins
DslDisablePlugins,
DslDependsOn
}
package object dsl {
def enablePlugins(ps: AutoPlugin*): DslEntry = DslEnablePlugins(ps)
def disablePlugins(ps: AutoPlugin*): DslEntry = DslDisablePlugins(ps)
def configs(cs: Configuration*): DslEntry = DslConfigs(cs)
}
def dependsOn(deps: ClasspathDep[ProjectReference]*): DslEntry = DslDependsOn(deps)
}

View File

@ -58,4 +58,7 @@ case class DslDisablePlugins(plugins: Seq[AutoPlugin]) extends ProjectManipulati
case class DslConfigs(cs: Seq[Configuration]) extends ProjectManipulation {
override val toFunction: Project => Project = _.configs(cs: _*)
}
/** Represents registering an internal dependency for the current project */
case class DslDependsOn(cs: Seq[ClasspathDep[ProjectReference]]) extends ProjectManipulation {
override val toFunction: Project => Project = _.dependsOn(cs: _*)
}

View File

@ -0,0 +1,9 @@
[@anatolydwnld]: https://github.com/anatolydwnld
### Fixes with compatibility implications
### Improvements
- Add the ability to call dependsOn for the current project inside a build sbt file. By [@anatolydwnld][@anatolydwnld]
### Bug fixes

View File

@ -0,0 +1,11 @@
val projA = project in file("projA")
val projB = project in file("projB")
lazy val check = taskKey[Unit]("Verifies expected build behavior")
check := {
val projBDeps = (dependencyClasspath in (projB, Compile)).value.map(_.data)
val assertion = projBDeps.filter(_.getAbsolutePath.contains("projA")).nonEmpty
assert(assertion, "Unable to find projA classes in projB's dependency list")
}

View File

@ -0,0 +1 @@
name := "projA"

View File

@ -0,0 +1,3 @@
name := "projB"
dependsOn(LocalProject("projA"))

View File

@ -0,0 +1 @@
> check