|
32 | 32 | * - to modularize the Scala compiler or library further
|
33 | 33 | */
|
34 | 34 |
|
35 |
| -import java.io.{PrintWriter, StringWriter} |
36 |
| - |
37 | 35 | import sbt.TestResult
|
38 | 36 | import sbt.testing.TestSelector
|
39 | 37 |
|
40 | 38 | import scala.build._
|
41 | 39 | import VersionUtil._
|
| 40 | +import scala.tools.nsc.util.ScalaClassLoader.URLClassLoader |
42 | 41 |
|
43 | 42 | // Non-Scala dependencies:
|
44 | 43 | val junitDep = "junit" % "junit" % "4.11"
|
@@ -117,6 +116,34 @@ lazy val instanceSettings = Seq[Setting[_]](
|
117 | 116 | Quiet.silenceScalaBinaryVersionWarning
|
118 | 117 | )
|
119 | 118 |
|
| 119 | +// be careful with using this instance, as it may cause performance problems (e.g., MetaSpace exhaustion)r |
| 120 | +lazy val quickInstanceSettings = Seq[Setting[_]]( |
| 121 | + organization := "org.scala-lang", |
| 122 | + // we don't cross build Scala itself |
| 123 | + crossPaths := false, |
| 124 | + // do not add Scala library jar as a dependency automatically |
| 125 | + autoScalaLibrary := false, |
| 126 | + // Avoid circular dependencies for scalaInstance (see https://github.com/sbt/sbt/issues/1872) |
| 127 | + managedScalaInstance := false, |
| 128 | + scalaInstance := { |
| 129 | + // TODO: express in terms of distDependencies? |
| 130 | + val cpElems: Seq[java.io.File] = (fullClasspath in Compile in replFrontend).value.map(_.data) ++ (fullClasspath in Compile in scaladoc).value.map(_.data) |
| 131 | + val libraryJar = cpElems.find(_.getPath.endsWith("classes/library")).get |
| 132 | + val compilerJar = cpElems.find(_.getPath.endsWith("classes/compiler")).get |
| 133 | + val extraJars = cpElems.filter(f => (f ne libraryJar) && (f ne compilerJar)) |
| 134 | + val v = (version in Global).value |
| 135 | + new ScalaInstance(v, new URLClassLoader(cpElems.map(_.toURI.toURL).toArray[URL], null), libraryJar, compilerJar, extraJars, Some(v)) |
| 136 | + }, |
| 137 | + // As of sbt 0.13.12 (sbt/sbt#2634) sbt endeavours to align both scalaOrganization and scalaVersion |
| 138 | + // in the Scala artefacts, for example scala-library and scala-compiler. |
| 139 | + // This doesn't work in the scala/scala build because the version of scala-library and the scalaVersion of |
| 140 | + // scala-library are correct to be different. So disable overriding. |
| 141 | + ivyScala ~= (_ map (_ copy (overrideScalaVersion = false))), |
| 142 | + Quiet.silenceScalaBinaryVersionWarning |
| 143 | +) |
| 144 | + |
| 145 | + |
| 146 | + |
120 | 147 | lazy val commonSettings = instanceSettings ++ clearSourceAndResourceDirectories ++ publishSettings ++ Seq[Setting[_]](
|
121 | 148 | // we always assume that Java classes are standalone and do not have any dependency
|
122 | 149 | // on Scala classes
|
@@ -561,6 +588,27 @@ lazy val junit = project.in(file("test") / "junit")
|
561 | 588 | unmanagedSourceDirectories in Test := List(baseDirectory.value)
|
562 | 589 | )
|
563 | 590 |
|
| 591 | +// imported from scalamacros/paradise for the test suite -- TODO: integrate into build structure, get rid of quickInstanceSettings? |
| 592 | +lazy val macroAnnot = project.in(file("test") / "macro-annot") |
| 593 | + .dependsOn(library, reflect, compiler, repl, replFrontend, scaladoc) |
| 594 | + .settings(disableDocs) |
| 595 | + .settings(disablePublishing) |
| 596 | + .settings(quickInstanceSettings) // use quick compiler as Scala Instance |
| 597 | + .settings( |
| 598 | + fork in Test := true, |
| 599 | + javaOptions in Test += "-Xss1M", |
| 600 | + libraryDependencies ++= Seq(junitDep, junitInterfaceDep), |
| 601 | + testOptions += Tests.Argument(TestFrameworks.JUnit, "-q", "-v", |
| 602 | + s"-Dsbt.paths.tests.classpath=${(fullClasspath in Test).value.files.map(_.getAbsolutePath).mkString(java.io.File.pathSeparatorChar.toString)}"), |
| 603 | + |
| 604 | + baseDirectory in Compile := (baseDirectory in ThisBuild).value, |
| 605 | + baseDirectory in Test := (baseDirectory in ThisBuild).value, |
| 606 | + |
| 607 | + scalacOptions += "-Ymacro-annotations", |
| 608 | + scalacOptions += "-Ywarn-unused-import", |
| 609 | + scalacOptions += "-Xfatal-warnings" |
| 610 | + ) |
| 611 | + |
564 | 612 | lazy val scalacheck = project.in(file("test") / "scalacheck")
|
565 | 613 | .dependsOn(library, reflect, compiler, scaladoc)
|
566 | 614 | .settings(clearSourceAndResourceDirectories)
|
@@ -805,6 +853,7 @@ lazy val root: Project = (project in file("."))
|
805 | 853 | val results = ScriptCommands.sequence[(Result[Unit], String)](List(
|
806 | 854 | (Keys.test in Test in junit).result map (_ -> "junit/test"),
|
807 | 855 | (Keys.test in Test in scalacheck).result map (_ -> "scalacheck/test"),
|
| 856 | + (Keys.test in Test in macroAnnot).result map (_ -> "macroAnnot/test"), |
808 | 857 | (testOnly in IntegrationTest in testP).toTask(" -- run").result map (_ -> "partest run"),
|
809 | 858 | (testOnly in IntegrationTest in testP).toTask(" -- pos neg jvm").result map (_ -> "partest pos neg jvm"),
|
810 | 859 | (testOnly in IntegrationTest in testP).toTask(" -- res scalap specialized").result map (_ -> "partest res scalap specialized"),
|
@@ -872,7 +921,7 @@ lazy val root: Project = (project in file("."))
|
872 | 921 | }
|
873 | 922 | )
|
874 | 923 | .aggregate(library, reflect, compiler, interactive, repl, replFrontend,
|
875 |
| - scaladoc, scalap, partest, junit, scalaDist).settings( |
| 924 | + scaladoc, scalap, partest, junit, scalaDist, macroAnnot).settings( |
876 | 925 | sources in Compile := Seq.empty,
|
877 | 926 | onLoadMessage := """|*** Welcome to the sbt build definition for Scala! ***
|
878 | 927 | |Check README.md for more information.""".stripMargin
|
|
0 commit comments