mirror of https://github.com/sbt/sbt.git
Correct handling of resolving ThisProject
In ca71b4b902 I went about fixing the
inexhaustive matching in Scope's resolveProjectBuild and
resolveProjectRef. Looking back the change was wrong.
For resolveProjectBuild the new implementation is less wrong, but still
not great, seeing as it doesn't actually do any build resolving.
For resolveProjectRef the new implementation now blows up instead of
lies. Which means it's less leneant, more "fail-fast".
isProjectThis is unused; remnant of the pre-AutoPlugin days when build
settings where defined in Plugin.settings.
This commit is contained in:
parent
05c2c506b2
commit
f4b2fc4228
|
|
@ -391,6 +391,8 @@ lazy val mainProj = (project in file("main"))
|
||||||
exclude[DirectMissingMethodProblem]("sbt.internal.KeyIndex.*"),
|
exclude[DirectMissingMethodProblem]("sbt.internal.KeyIndex.*"),
|
||||||
// Removed unused val. internal.
|
// Removed unused val. internal.
|
||||||
exclude[DirectMissingMethodProblem]("sbt.internal.RelayAppender.jsonFormat"),
|
exclude[DirectMissingMethodProblem]("sbt.internal.RelayAppender.jsonFormat"),
|
||||||
|
// Removed unused def. internal.
|
||||||
|
exclude[DirectMissingMethodProblem]("sbt.internal.Load.isProjectThis"),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
.configure(
|
.configure(
|
||||||
|
|
|
||||||
|
|
@ -97,8 +97,7 @@ object Scope {
|
||||||
case LocalProject(id) => ProjectRef(current, id)
|
case LocalProject(id) => ProjectRef(current, id)
|
||||||
case RootProject(uri) => RootProject(resolveBuild(current, uri))
|
case RootProject(uri) => RootProject(resolveBuild(current, uri))
|
||||||
case ProjectRef(uri, id) => ProjectRef(resolveBuild(current, uri), id)
|
case ProjectRef(uri, id) => ProjectRef(resolveBuild(current, uri), id)
|
||||||
case ThisProject =>
|
case ThisProject => ThisProject // haven't exactly "resolved" anything..
|
||||||
RootProject(current) // Is this right? It was an inexhaustive match before..
|
|
||||||
}
|
}
|
||||||
def resolveBuild(current: URI, uri: URI): URI =
|
def resolveBuild(current: URI, uri: URI): URI =
|
||||||
if (!uri.isAbsolute && current.isOpaque && uri.getSchemeSpecificPart == ".")
|
if (!uri.isAbsolute && current.isOpaque && uri.getSchemeSpecificPart == ".")
|
||||||
|
|
@ -118,13 +117,11 @@ object Scope {
|
||||||
rootProject: URI => String,
|
rootProject: URI => String,
|
||||||
ref: ProjectReference): ProjectRef =
|
ref: ProjectReference): ProjectRef =
|
||||||
ref match {
|
ref match {
|
||||||
case LocalRootProject => ProjectRef(current, rootProject(current))
|
case LocalRootProject => ProjectRef(current, rootProject(current))
|
||||||
case LocalProject(id) => ProjectRef(current, id)
|
case LocalProject(id) => ProjectRef(current, id)
|
||||||
case RootProject(uri) =>
|
case RootProject(uri) => val u = resolveBuild(current, uri); ProjectRef(u, rootProject(u))
|
||||||
val res = resolveBuild(current, uri); ProjectRef(res, rootProject(res))
|
|
||||||
case ProjectRef(uri, id) => ProjectRef(resolveBuild(current, uri), id)
|
case ProjectRef(uri, id) => ProjectRef(resolveBuild(current, uri), id)
|
||||||
case ThisProject =>
|
case ThisProject => sys.error("Cannot resolve ThisProject w/o the current project")
|
||||||
ProjectRef(current, rootProject(current)) // Is this right? It was an inexhaustive match before..
|
|
||||||
}
|
}
|
||||||
def resolveBuildRef(current: URI, ref: BuildReference): BuildRef =
|
def resolveBuildRef(current: URI, ref: BuildReference): BuildRef =
|
||||||
ref match {
|
ref match {
|
||||||
|
|
|
||||||
|
|
@ -363,12 +363,6 @@ private[sbt] object Load {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
def isProjectThis(s: Setting[_]): Boolean =
|
|
||||||
s.key.scope.project match {
|
|
||||||
case This | Select(ThisProject) => true
|
|
||||||
case _ => false
|
|
||||||
}
|
|
||||||
|
|
||||||
def buildConfigurations(
|
def buildConfigurations(
|
||||||
loaded: LoadedBuild,
|
loaded: LoadedBuild,
|
||||||
rootProject: URI => String,
|
rootProject: URI => String,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue