mirror of https://github.com/sbt/sbt.git
give builders access to resolved build before deciding if they are applicable
This commit is contained in:
parent
5fd3c1d2e5
commit
bec7d3fb28
|
|
@ -45,7 +45,7 @@ object BuildLoader
|
||||||
/** in: Build URI and staging directory
|
/** in: Build URI and staging directory
|
||||||
* out: None if unhandled or Some containing the retrieve function, which returns the directory retrieved to (can be the same as the staging directory) */
|
* out: None if unhandled or Some containing the retrieve function, which returns the directory retrieved to (can be the same as the staging directory) */
|
||||||
type Resolver = ResolveInfo => Option[() => File]
|
type Resolver = ResolveInfo => Option[() => File]
|
||||||
type Builder = BuildInfo => Option[File => BuildUnit]
|
type Builder = BuildInfo => Option[() => BuildUnit]
|
||||||
type Transformer = TransformInfo => BuildUnit
|
type Transformer = TransformInfo => BuildUnit
|
||||||
type Loader = LoadInfo => Option[() => BuildUnit]
|
type Loader = LoadInfo => Option[() => BuildUnit]
|
||||||
|
|
||||||
|
|
@ -67,7 +67,7 @@ object BuildLoader
|
||||||
def state: State
|
def state: State
|
||||||
}
|
}
|
||||||
final class ResolveInfo(val uri: URI, val staging: File, val config: LoadBuildConfiguration, val state: State) extends Info
|
final class ResolveInfo(val uri: URI, val staging: File, val config: LoadBuildConfiguration, val state: State) extends Info
|
||||||
final class BuildInfo(val uri: URI, val config: LoadBuildConfiguration, val state: State) extends Info
|
final class BuildInfo(val uri: URI, val base: File, val config: LoadBuildConfiguration, val state: State) extends Info
|
||||||
final class TransformInfo(val uri: URI, val base: File, val unit: BuildUnit, val config: LoadBuildConfiguration, val state: State) extends Info {
|
final class TransformInfo(val uri: URI, val base: File, val unit: BuildUnit, val config: LoadBuildConfiguration, val state: State) extends Info {
|
||||||
def setUnit(newUnit: BuildUnit): TransformInfo = new TransformInfo(uri, base, newUnit, config, state)
|
def setUnit(newUnit: BuildUnit): TransformInfo = new TransformInfo(uri, base, newUnit, config, state)
|
||||||
}
|
}
|
||||||
|
|
@ -85,10 +85,10 @@ object BuildLoader
|
||||||
val cs = info.components
|
val cs = info.components
|
||||||
for {
|
for {
|
||||||
resolve <- cs.resolver(new ResolveInfo(uri, staging, config, state))
|
resolve <- cs.resolver(new ResolveInfo(uri, staging, config, state))
|
||||||
build <- cs.builder(new BuildInfo(uri, config, state))
|
|
||||||
} yield () => {
|
|
||||||
val base = resolve()
|
val base = resolve()
|
||||||
val unit = build(base)
|
build <- cs.builder(new BuildInfo(uri, base, config, state))
|
||||||
|
} yield () => {
|
||||||
|
val unit = build()
|
||||||
cs.transformer(new TransformInfo(uri, base, unit, config, state))
|
cs.transformer(new TransformInfo(uri, base, unit, config, state))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -99,7 +99,7 @@ final class BuildLoader(
|
||||||
val state: State,
|
val state: State,
|
||||||
val config: LoadBuildConfiguration,
|
val config: LoadBuildConfiguration,
|
||||||
val resolvers: MultiHandler[ResolveInfo, ()=>File],
|
val resolvers: MultiHandler[ResolveInfo, ()=>File],
|
||||||
val builders: MultiHandler[BuildInfo, File=>BuildUnit],
|
val builders: MultiHandler[BuildInfo, ()=>BuildUnit],
|
||||||
val transformer: Transformer,
|
val transformer: Transformer,
|
||||||
val full: MultiHandler[LoadInfo, ()=>BuildUnit])
|
val full: MultiHandler[LoadInfo, ()=>BuildUnit])
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -227,9 +227,9 @@ object Load
|
||||||
|
|
||||||
def load(file: File, s: State, config: LoadBuildConfiguration): PartBuild =
|
def load(file: File, s: State, config: LoadBuildConfiguration): PartBuild =
|
||||||
{
|
{
|
||||||
val fail = (uri: URI) => error("Invalid build URI: " + uri)
|
val fail = (uri: URI) => error("Invalid build URI (no handler available): " + uri)
|
||||||
val resolver = (info: BuildLoader.ResolveInfo) => RetrieveUnit(info.staging, info.uri)
|
val resolver = (info: BuildLoader.ResolveInfo) => RetrieveUnit(info.staging, info.uri)
|
||||||
val build = (info: BuildLoader.BuildInfo) => Some((base: File) => loadUnit(info.uri, base, info.state, info.config))
|
val build = (info: BuildLoader.BuildInfo) => Some(() => loadUnit(info.uri, info.base, info.state, info.config))
|
||||||
val components = BuildLoader.components(resolver, build, full = BuildLoader.componentLoader)
|
val components = BuildLoader.components(resolver, build, full = BuildLoader.componentLoader)
|
||||||
val builtinLoader = BuildLoader(components, fail, s, config)
|
val builtinLoader = BuildLoader(components, fail, s, config)
|
||||||
load(file, builtinLoader)
|
load(file, builtinLoader)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue