mirror of https://github.com/sbt/sbt.git
generalize addArtifact arguments to Initialize[...]. fixes #207
This commit is contained in:
parent
d15504d970
commit
7702d30f40
|
|
@ -1037,11 +1037,13 @@ trait BuildExtra extends BuildCommon
|
||||||
val pkgd = packagedArtifacts <<= (packagedArtifacts, taskDef) map ( (pas,file) => pas updated (a, file) )
|
val pkgd = packagedArtifacts <<= (packagedArtifacts, taskDef) map ( (pas,file) => pas updated (a, file) )
|
||||||
seq( artifacts += a, pkgd )
|
seq( artifacts += a, pkgd )
|
||||||
}
|
}
|
||||||
def addArtifact(artifact: ScopedSetting[Artifact], taskDef: ScopedTask[File]): SettingsDefinition =
|
def addArtifact(artifact: Initialize[Artifact], taskDef: Initialize[Task[File]]): SettingsDefinition =
|
||||||
{
|
{
|
||||||
val art = artifacts <<= (artifact, artifacts)( _ +: _ )
|
val artLocal = SettingKey.local[Artifact]
|
||||||
val pkgd = packagedArtifacts <<= (packagedArtifacts, artifact, taskDef) map ( (pas,a,file) => pas updated (a, file))
|
val taskLocal = TaskKey.local[File]
|
||||||
seq( art, pkgd )
|
val art = artifacts <<= (artLocal, artifacts)( _ +: _ )
|
||||||
|
val pkgd = packagedArtifacts <<= (packagedArtifacts, artLocal, taskLocal) map ( (pas,a,file) => pas updated (a, file))
|
||||||
|
seq( artLocal <<= artifact, taskLocal <<= taskDef, art, pkgd )
|
||||||
}
|
}
|
||||||
|
|
||||||
def seq(settings: Setting[_]*): SettingsDefinition = new Project.SettingList(settings)
|
def seq(settings: Setting[_]*): SettingsDefinition = new Project.SettingList(settings)
|
||||||
|
|
|
||||||
|
|
@ -198,19 +198,19 @@ trait Init[Scope]
|
||||||
def flattenLocals(compiled: CompiledMap): Map[ScopedKey[_],Flattened] =
|
def flattenLocals(compiled: CompiledMap): Map[ScopedKey[_],Flattened] =
|
||||||
{
|
{
|
||||||
import collection.breakOut
|
import collection.breakOut
|
||||||
val locals = compiled.flatMap { case (key, comp) => if(key.key.isLocal) Seq[Compiled[_]](comp) else Nil }(breakOut)
|
val locals = compiled flatMap { case (key, comp) => if(key.key.isLocal) Seq[Compiled[_]](comp) else Nil }
|
||||||
val ordered = Dag.topologicalSort(locals)(_.dependencies.flatMap(dep => if(dep.key.isLocal) Seq[Compiled[_]](compiled(dep)) else Nil))
|
val ordered = Dag.topologicalSort(locals)(_.dependencies.flatMap(dep => if(dep.key.isLocal) Seq[Compiled[_]](compiled(dep)) else Nil))
|
||||||
def flatten(cmap: Map[ScopedKey[_],Flattened], key: ScopedKey[_], deps: Iterable[ScopedKey[_]]): Flattened =
|
def flatten(cmap: Map[ScopedKey[_],Flattened], key: ScopedKey[_], deps: Iterable[ScopedKey[_]]): Flattened =
|
||||||
new Flattened(key, deps.flatMap(dep => if(dep.key.isLocal) cmap(dep).dependencies else dep :: Nil))
|
new Flattened(key, deps.flatMap(dep => if(dep.key.isLocal) cmap(dep).dependencies else dep :: Nil))
|
||||||
|
|
||||||
val empty = Map.empty[ScopedKey[_],Flattened]
|
val empty = Map.empty[ScopedKey[_],Flattened]
|
||||||
val flattenedLocals = (empty /: ordered) { (cmap, c) => cmap.updated(c.key, flatten(cmap, c.key, c.dependencies)) }
|
val flattenedLocals = (empty /: ordered) { (cmap, c) => cmap.updated(c.key, flatten(cmap, c.key, c.dependencies)) }
|
||||||
compiled.flatMap{ case (key, comp) =>
|
compiled flatMap{ case (key, comp) =>
|
||||||
if(key.key.isLocal)
|
if(key.key.isLocal)
|
||||||
Nil
|
Nil
|
||||||
else
|
else
|
||||||
Seq[ (ScopedKey[_], Flattened)]( (key, flatten(flattenedLocals, key, comp.dependencies)) )
|
Seq[ (ScopedKey[_], Flattened)]( (key, flatten(flattenedLocals, key, comp.dependencies)) )
|
||||||
}(breakOut)
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sealed trait Initialize[T]
|
sealed trait Initialize[T]
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue