mirror of https://github.com/sbt/sbt.git
Port project/extra
This commit is contained in:
parent
32d21d0685
commit
d01f8d3c1b
|
|
@ -11,7 +11,7 @@ import sbt.io.Hash
|
||||||
import sbt.internal.util.Attributed
|
import sbt.internal.util.Attributed
|
||||||
import sbt.internal.inc.ReflectUtilities
|
import sbt.internal.inc.ReflectUtilities
|
||||||
|
|
||||||
private[sbt] trait BuildDef {
|
trait BuildDef {
|
||||||
def projectDefinitions(baseDirectory: File): Seq[Project] = projects
|
def projectDefinitions(baseDirectory: File): Seq[Project] = projects
|
||||||
def projects: Seq[Project] = ReflectUtilities.allVals[Project](this).values.toSeq
|
def projects: Seq[Project] = ReflectUtilities.allVals[Project](this).values.toSeq
|
||||||
// TODO: Should we grab the build core setting shere or in a plugin?
|
// TODO: Should we grab the build core setting shere or in a plugin?
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,43 @@
|
||||||
|
lazy val root = (project in file(".")).
|
||||||
|
settings(
|
||||||
|
autoScalaLibrary := false,
|
||||||
|
libraryDependencies += "log4j" % "log4j" % "1.2.16",
|
||||||
|
retrieveManaged := true,
|
||||||
|
commands ++= Seq(
|
||||||
|
addExtra("add1", addExtra1),
|
||||||
|
addExtra("add2", addExtra2),
|
||||||
|
checkExtra
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
def addExtra(name: String, f: (State, Seq[File]) => State) =
|
||||||
|
Command.command(name) { s =>
|
||||||
|
f(s, (file("lib_managed") ** "*.jar").get)
|
||||||
|
}
|
||||||
|
def checkExtra =
|
||||||
|
Command.command("check") { s =>
|
||||||
|
val loader = Class.forName("org.apache.log4j.Level").getClassLoader
|
||||||
|
val sbtLoader = classOf[sbt.internal.BuildDef].getClassLoader
|
||||||
|
assert(loader eq sbtLoader, "Different loader for sbt and extra: " + sbtLoader + " and " + loader)
|
||||||
|
s
|
||||||
|
}
|
||||||
|
def addExtra1(s: State, extra: Seq[File]): State =
|
||||||
|
{
|
||||||
|
val cs = s.configuration.provider.components()
|
||||||
|
val copied = cs.addToComponent("extra", extra.toArray)
|
||||||
|
if(copied) s.reload else s
|
||||||
|
}
|
||||||
|
def addExtra2(s: State, extra: Seq[File]): State =
|
||||||
|
{
|
||||||
|
val reload = State.defaultReload(s)
|
||||||
|
val currentID = reload.app
|
||||||
|
val currentExtra = currentID.classpathExtra
|
||||||
|
val newExtra = (currentExtra ++ extra).distinct
|
||||||
|
if(newExtra.length == currentExtra.length)
|
||||||
|
s
|
||||||
|
else
|
||||||
|
{
|
||||||
|
val newID = ApplicationID(currentID).copy(extra = extra)
|
||||||
|
s.setResult(Some(reload.copy(app = newID)))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,46 +0,0 @@
|
||||||
import sbt._
|
|
||||||
import Keys._
|
|
||||||
import Import._
|
|
||||||
|
|
||||||
object B extends Build
|
|
||||||
{
|
|
||||||
lazy val root = Project("root", file(".")) settings(
|
|
||||||
autoScalaLibrary := false,
|
|
||||||
libraryDependencies += "log4j" % "log4j" % "1.2.16",
|
|
||||||
retrieveManaged := true,
|
|
||||||
commands ++= Seq(
|
|
||||||
addExtra("add1", addExtra1),
|
|
||||||
addExtra("add2", addExtra2),
|
|
||||||
checkExtra
|
|
||||||
)
|
|
||||||
)
|
|
||||||
def addExtra(name: String, f: (State, Seq[File]) => State) = Command.command(name) { s =>
|
|
||||||
f(s, (file("lib_managed") ** "*.jar").get)
|
|
||||||
}
|
|
||||||
def checkExtra = Command.command("check") { s =>
|
|
||||||
val loader = Class.forName("org.apache.log4j.Level").getClassLoader
|
|
||||||
val sbtLoader = classOf[sbt.Build].getClassLoader
|
|
||||||
assert(loader eq sbtLoader, "Different loader for sbt and extra: " + sbtLoader + " and " + loader)
|
|
||||||
s
|
|
||||||
}
|
|
||||||
def addExtra1(s: State, extra: Seq[File]): State =
|
|
||||||
{
|
|
||||||
val cs = s.configuration.provider.components()
|
|
||||||
val copied = cs.addToComponent("extra", extra.toArray)
|
|
||||||
if(copied) s.reload else s
|
|
||||||
}
|
|
||||||
def addExtra2(s: State, extra: Seq[File]): State =
|
|
||||||
{
|
|
||||||
val reload = State.defaultReload(s)
|
|
||||||
val currentID = reload.app
|
|
||||||
val currentExtra = currentID.classpathExtra
|
|
||||||
val newExtra = (currentExtra ++ extra).distinct
|
|
||||||
if(newExtra.length == currentExtra.length)
|
|
||||||
s
|
|
||||||
else
|
|
||||||
{
|
|
||||||
val newID = ApplicationID(currentID).copy(extra = extra)
|
|
||||||
s.setResult(Some(reload.copy(app = newID)))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Loading…
Reference in New Issue