Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support sbt 1.1 #215

Merged
merged 1 commit into from
Dec 6, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ matrix:
jdk: openjdk7
- env: SBT_VERSION="1.0.4"
jdk: oraclejdk8
- env: SBT_VERSION="1.1.0-RC1"
jdk: oraclejdk8
script:
- git config --global user.email "example@example.com"
- git config --global user.name "example"
Expand Down
15 changes: 15 additions & 0 deletions src/main/scala-sbt-0.13/Compat.scala
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,19 @@ object Compat {
val KeyIndex = sbt.KeyIndex
type LoadedBuildUnit = sbt.LoadedBuildUnit

private[sbtrelease] def keyIndexApply(
known: Iterable[ScopedKey[_]],
projects: Map[URI, Set[String]],
configurations: Map[String, Seq[Configuration]]
) = {
KeyIndex.apply(known = known, projects = projects)
}

private[sbtrelease] def keyIndexAggregate(known: Iterable[ScopedKey[_]],
extra: BuildUtil[_],
projects: Map[URI, Set[String]],
configurations: Map[String, Seq[Configuration]]) = {
KeyIndex.aggregate(known = known, extra = extra, projects = projects)
}

}
54 changes: 53 additions & 1 deletion src/main/scala-sbt-1.0/Compat.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import sbt.Def.ScopedKey
import sbt.EvaluateTask.{extractedTaskConfig, nodeView, runTask, withStreams}
import sbt.Keys._
import sbt.internal.Aggregation.KeyValue
import sbt.internal.{Act, Aggregation}
import sbt.internal.{Act, Aggregation, ExtendableKeyIndex}
import sbt.std.Transform.DummyTaskMap

object Compat {
Expand Down Expand Up @@ -81,4 +81,56 @@ object Compat {
type KeyIndex = sbt.internal.KeyIndex
val KeyIndex = sbt.internal.KeyIndex
type LoadedBuildUnit = sbt.internal.LoadedBuildUnit

// https://github.com/sbt/sbt/issues/3792
private[sbtrelease] def keyIndexApply(
known: Iterable[ScopedKey[_]],
projects: Map[URI, Set[String]],
configurations: Map[String, Seq[Configuration]]
): ExtendableKeyIndex = try {
// for sbt 1.1
KeyIndex.asInstanceOf[{
def apply(
known: Iterable[ScopedKey[_]],
projects: Map[URI, Set[String]],
configurations: Map[String, Seq[Configuration]]
): ExtendableKeyIndex
}].apply(known = known, projects = projects, configurations = configurations)
} catch {
case _: NoSuchMethodException =>
// for sbt 1.0.x
KeyIndex.asInstanceOf[{
def apply(
known: Iterable[ScopedKey[_]],
projects: Map[URI, Set[String]],
): ExtendableKeyIndex
}].apply(known = known, projects = projects)
}

// https://github.com/sbt/sbt/issues/3792
private[sbtrelease] def keyIndexAggregate(known: Iterable[ScopedKey[_]],
extra: BuildUtil[_],
projects: Map[URI, Set[String]],
configurations: Map[String, Seq[Configuration]]) = try {
// for sbt 1.1
KeyIndex.asInstanceOf[{
def aggregate(
known: Iterable[ScopedKey[_]],
extra: BuildUtil[_],
projects: Map[URI, Set[String]],
configurations: Map[String, Seq[Configuration]]
): ExtendableKeyIndex
}].aggregate(known = known, extra = extra, projects = projects, configurations = configurations)
} catch {
case _: NoSuchMethodException =>
// for sbt 1.0.x
KeyIndex.asInstanceOf[{
def aggregate(
known: Iterable[ScopedKey[_]],
extra: BuildUtil[_],
projects: Map[URI, Set[String]]
): ExtendableKeyIndex
}].aggregate(known = known, extra = extra, projects = projects)
}

}
6 changes: 4 additions & 2 deletions src/main/scala/Load.scala
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,10 @@ object Load {
val attributeKeys = Index.attributeKeys(data) ++ keys.map(_.key)
val scopedKeys = keys ++ data.allKeys((s, k) => ScopedKey(s, k)).toVector
val projectsMap = projects.mapValues(_.defined.keySet)
val keyIndex = KeyIndex(scopedKeys.toVector, projectsMap)
val aggIndex = KeyIndex.aggregate(scopedKeys.toVector, extra(keyIndex), projectsMap)
val configsMap: Map[String, Seq[Configuration]] =
projects.values.flatMap(bu => bu.defined map { case (k, v) => (k, v.configurations) }).toMap
val keyIndex = keyIndexApply(scopedKeys.toVector, projectsMap, configsMap)
val aggIndex = keyIndexAggregate(scopedKeys.toVector, extra(keyIndex), projectsMap, configsMap)
new StructureIndex(Index.stringToKeyMap(attributeKeys), Index.taskToKeyMap(data), Index.triggers(data), keyIndex, aggIndex)
}

Expand Down