2009-08-16 20:29:08 +02:00
|
|
|
import sbt._
|
|
|
|
|
|
|
|
|
|
class XSbt(info: ProjectInfo) extends ParentProject(info)
|
|
|
|
|
{
|
2009-08-24 04:21:15 +02:00
|
|
|
val launchInterfaceSub = project(launchPath / "interface", "Launcher Interface", new InterfaceProject(_))
|
2009-08-21 14:12:43 +02:00
|
|
|
val launchSub = project(launchPath, "Launcher", new LaunchProject(_), launchInterfaceSub)
|
|
|
|
|
|
2009-08-17 16:51:43 +02:00
|
|
|
val interfaceSub = project("interface", "Interface", new InterfaceProject(_))
|
2009-08-16 20:29:08 +02:00
|
|
|
|
|
|
|
|
val controlSub = project(utilPath / "control", "Control", new Base(_))
|
|
|
|
|
val collectionSub = project(utilPath / "collection", "Collections", new Base(_))
|
2009-08-24 04:21:15 +02:00
|
|
|
val ioSub = project(utilPath / "io", "IO", new IOProject(_), controlSub)
|
2009-08-16 20:29:08 +02:00
|
|
|
val classpathSub = project(utilPath / "classpath", "Classpath", new Base(_))
|
|
|
|
|
|
2009-08-24 04:21:15 +02:00
|
|
|
val compileInterfaceSub = project(compilePath / "interface", "Compiler Interface Src", new CompilerInterfaceProject(_), interfaceSub)
|
2009-08-17 16:51:43 +02:00
|
|
|
|
2009-08-18 06:51:08 +02:00
|
|
|
val ivySub = project("ivy", "Ivy", new IvyProject(_), interfaceSub)
|
2009-08-16 20:29:08 +02:00
|
|
|
val logSub = project(utilPath / "log", "Logging", new Base(_))
|
|
|
|
|
|
2009-08-24 04:21:15 +02:00
|
|
|
val taskSub = project("tasks", "Tasks", new TaskProject(_), controlSub, collectionSub)
|
2009-08-16 20:29:08 +02:00
|
|
|
val cacheSub = project("cache", "Cache", new CacheProject(_), taskSub, ioSub)
|
2009-08-24 04:21:15 +02:00
|
|
|
val compilerSub = project(compilePath, "Compile", new CompileProject(_),
|
|
|
|
|
launchInterfaceSub, interfaceSub, ivySub, ioSub, classpathSub, compileInterfaceSub)
|
2009-08-16 20:29:08 +02:00
|
|
|
|
2009-08-21 14:12:43 +02:00
|
|
|
def launchPath = path("launch")
|
2009-08-18 06:51:08 +02:00
|
|
|
def utilPath = path("util")
|
|
|
|
|
def compilePath = path("compile")
|
2009-08-19 05:25:34 +02:00
|
|
|
|
2009-08-24 04:21:15 +02:00
|
|
|
class LaunchProject(info: ProjectInfo) extends Base(info) with TestWithIO with TestDependencies
|
2009-08-21 14:12:43 +02:00
|
|
|
{
|
|
|
|
|
val ivy = "org.apache.ivy" % "ivy" % "2.0.0"
|
2009-08-24 04:21:15 +02:00
|
|
|
// to test the retrieving and loading of the main sbt, we package and publish the test classes to the local repository
|
|
|
|
|
override def defaultMainArtifact = Artifact(idWithVersion)
|
|
|
|
|
override def projectID = ModuleID(organization, idWithVersion, "test-" + version)
|
|
|
|
|
override def packageAction = packageTask(packageTestPaths, outputPath / (idWithVersion + "-" + projectID.revision +".jar"), packageOptions).dependsOn(rawTestCompile)
|
|
|
|
|
override def deliverProjectDependencies = Nil
|
|
|
|
|
def idWithVersion = "xsbt_" + ScalaVersion.currentString
|
|
|
|
|
lazy val rawTestCompile = super.testCompileAction
|
|
|
|
|
override def testCompileAction = publishLocal dependsOn(rawTestCompile)
|
2009-08-21 14:12:43 +02:00
|
|
|
}
|
2009-08-24 04:21:15 +02:00
|
|
|
trait TestDependencies extends Project
|
2009-08-16 20:29:08 +02:00
|
|
|
{
|
|
|
|
|
val sc = "org.scala-tools.testing" % "scalacheck" % "1.5" % "test->default"
|
2009-08-18 06:51:08 +02:00
|
|
|
val sp = "org.scala-tools.testing" % "specs" % "1.5.0" % "test->default"
|
|
|
|
|
val ju = "junit" % "junit" % "4.5" % "test->default" // required by specs to compile properly
|
2009-08-16 20:29:08 +02:00
|
|
|
}
|
2009-08-17 16:51:43 +02:00
|
|
|
|
|
|
|
|
override def parallelExecution = true
|
2009-08-24 04:21:15 +02:00
|
|
|
class IOProject(info: ProjectInfo) extends Base(info) with TestDependencies
|
|
|
|
|
class TaskProject(info: ProjectInfo) extends Base(info) with TestDependencies
|
2009-08-16 20:29:08 +02:00
|
|
|
class CacheProject(info: ProjectInfo) extends Base(info)
|
|
|
|
|
{
|
|
|
|
|
//override def compileOptions = super.compileOptions ++ List(Unchecked,ExplainTypes, CompileOption("-Xlog-implicits"))
|
|
|
|
|
}
|
2009-08-24 04:21:15 +02:00
|
|
|
class Base(info: ProjectInfo) extends DefaultProject(info) with ManagedBase
|
2009-08-16 20:29:08 +02:00
|
|
|
{
|
|
|
|
|
override def scratch = true
|
|
|
|
|
}
|
2009-08-24 04:21:15 +02:00
|
|
|
class CompileProject(info: ProjectInfo) extends Base(info)
|
|
|
|
|
{
|
|
|
|
|
override def testCompileAction = super.testCompileAction dependsOn(launchSub.testCompile, compileInterfaceSub.`package`, interfaceSub.`package`)
|
|
|
|
|
override def deliverProjectDependencies = Set(super.deliverProjectDependencies.toSeq : _*) - launchInterfaceSub.projectID
|
|
|
|
|
override def testClasspath = super.testClasspath +++ launchSub.testClasspath +++ compileInterfaceSub.jarPath +++ interfaceSub.jarPath
|
|
|
|
|
override def compileOptions = super.compileOptions ++ Seq(CompileOption("-Xno-varargs-conversion"))
|
|
|
|
|
}
|
2009-08-21 14:55:11 +02:00
|
|
|
class IvyProject(info: ProjectInfo) extends Base(info) with TestWithIO
|
2009-08-16 20:29:08 +02:00
|
|
|
{
|
|
|
|
|
val ivy = "org.apache.ivy" % "ivy" % "2.0.0"
|
|
|
|
|
}
|
2009-08-24 04:21:15 +02:00
|
|
|
class InterfaceProject(info: ProjectInfo) extends DefaultProject(info) with ManagedBase
|
2009-08-17 16:51:43 +02:00
|
|
|
{
|
2009-08-18 06:51:08 +02:00
|
|
|
override def mainSources = descendents(mainSourceRoots, "*.java")
|
2009-08-17 16:51:43 +02:00
|
|
|
override def compileOrder = CompileOrder.JavaThenScala
|
|
|
|
|
}
|
2009-08-18 06:51:08 +02:00
|
|
|
class CompilerInterfaceProject(info: ProjectInfo) extends Base(info) with SourceProject
|
|
|
|
|
{
|
2009-08-24 04:21:15 +02:00
|
|
|
// these set up the test environment so that the classes and resources are both in the output resource directory
|
|
|
|
|
// the main compile path is removed so that the plugin (xsbt.Analyzer) is found in the output resource directory so that
|
2009-08-18 06:51:08 +02:00
|
|
|
// the tests can configure that directory as -Xpluginsdir (which requires the scalac-plugin.xml and the classes to be together)
|
2009-08-19 05:25:34 +02:00
|
|
|
override def testCompileAction = super.testCompileAction dependsOn(packageForTest, ioSub.testCompile)
|
2009-08-18 06:51:08 +02:00
|
|
|
override def mainResources = super.mainResources +++ "scalac-plugin.xml"
|
|
|
|
|
override def testClasspath = (super.testClasspath --- super.mainCompilePath) +++ ioSub.testClasspath +++ testPackagePath
|
|
|
|
|
def testPackagePath = outputPath / "test.jar"
|
|
|
|
|
lazy val packageForTest = packageTask(mainClasses +++ mainResources, testPackagePath, packageOptions).dependsOn(compile)
|
|
|
|
|
}
|
2009-08-21 14:55:11 +02:00
|
|
|
trait TestWithIO extends BasicScalaProject
|
|
|
|
|
{
|
|
|
|
|
// use IO from tests
|
|
|
|
|
override def testCompileAction = super.testCompileAction dependsOn(ioSub.testCompile)
|
|
|
|
|
override def testClasspath = super.testClasspath +++ ioSub.testClasspath
|
|
|
|
|
}
|
2009-08-18 06:51:08 +02:00
|
|
|
}
|
|
|
|
|
trait SourceProject extends BasicScalaProject
|
|
|
|
|
{
|
2009-08-24 04:21:15 +02:00
|
|
|
override final def crossScalaVersions = Set.empty
|
|
|
|
|
override def packagePaths = mainResources +++ mainSources
|
|
|
|
|
}
|
|
|
|
|
trait ManagedBase extends BasicScalaProject
|
|
|
|
|
{
|
|
|
|
|
override def deliverScalaDependencies = Nil
|
|
|
|
|
override def crossScalaVersions = Set("2.7.5")
|
|
|
|
|
override def managedStyle = ManagedStyle.Ivy
|
|
|
|
|
override def useDefaultConfigurations = false
|
|
|
|
|
val defaultConf = Configurations.Default
|
|
|
|
|
val testConf = Configurations.Test
|
2009-08-16 20:29:08 +02:00
|
|
|
}
|