summaryrefslogtreecommitdiff
path: root/build.sbt
diff options
context:
space:
mode:
authorLukas Rytz <lukas.rytz@gmail.com>2016-06-19 14:12:13 +0200
committerLukas Rytz <lukas.rytz@gmail.com>2016-06-21 11:23:03 +0200
commite4c2d68fcf2aebe062faf2bdad08e07704b66d9a (patch)
tree5e1ba660b36a285e50652883bca96e7514fe592b /build.sbt
parentb3283669e05dc706274e944ffd3750892c16e4dd (diff)
parentaaf7bc0b948ee073934885f8240193a4ba2b3bb8 (diff)
downloadscala-e4c2d68fcf2aebe062faf2bdad08e07704b66d9a.tar.gz
scala-e4c2d68fcf2aebe062faf2bdad08e07704b66d9a.tar.bz2
scala-e4c2d68fcf2aebe062faf2bdad08e07704b66d9a.zip
Merge commit 'aaf7bc0' into merge-2.11-to-2.12-june-19
Diffstat (limited to 'build.sbt')
-rw-r--r--build.sbt179
1 files changed, 128 insertions, 51 deletions
diff --git a/build.sbt b/build.sbt
index b8b8b8204b..98ea8f0b32 100644
--- a/build.sbt
+++ b/build.sbt
@@ -55,22 +55,20 @@
import VersionUtil._
-val bootstrapScalaVersion = versionProps("starr.version")
-
-def withoutScalaLang(moduleId: ModuleID): ModuleID = moduleId exclude("org.scala-lang", "*")
-
-// exclusion of the scala-library transitive dependency avoids eviction warnings during `update`.
-val scalaParserCombinatorsDep = withoutScalaLang("org.scala-lang.modules" %% "scala-parser-combinators" % versionNumber("scala-parser-combinators"))
-val scalaSwingDep = withoutScalaLang("org.scala-lang.modules" %% "scala-swing" % versionNumber("scala-swing"))
-val scalaXmlDep = withoutScalaLang("org.scala-lang.modules" %% "scala-xml" % versionNumber("scala-xml"))
-val partestDep = withoutScalaLang("org.scala-lang.modules" %% "scala-partest" % versionNumber("partest"))
-val junitDep = "junit" % "junit" % "4.11"
-val junitInterfaceDep = "com.novocode" % "junit-interface" % "0.11" % "test"
-val jolDep = "org.openjdk.jol" % "jol-core" % "0.5"
-val asmDep = "org.scala-lang.modules" % "scala-asm" % versionProps("scala-asm.version")
-val jlineDep = "jline" % "jline" % versionProps("jline.version")
-val antDep = "org.apache.ant" % "ant" % "1.9.4"
-val scalacheckDep = withoutScalaLang("org.scalacheck" %% "scalacheck" % versionNumber("scalacheck") % "it")
+// Scala dependencies:
+val scalaParserCombinatorsDep = scalaDep("org.scala-lang.modules", "scala-parser-combinators")
+val scalaSwingDep = scalaDep("org.scala-lang.modules", "scala-swing")
+val scalaXmlDep = scalaDep("org.scala-lang.modules", "scala-xml")
+val partestDep = scalaDep("org.scala-lang.modules", "scala-partest", versionProp = "partest")
+val scalacheckDep = scalaDep("org.scalacheck", "scalacheck", scope = "it")
+
+// Non-Scala dependencies:
+val junitDep = "junit" % "junit" % "4.11"
+val junitInterfaceDep = "com.novocode" % "junit-interface" % "0.11" % "test"
+val jolDep = "org.openjdk.jol" % "jol-core" % "0.5"
+val asmDep = "org.scala-lang.modules" % "scala-asm" % versionProps("scala-asm.version")
+val jlineDep = "jline" % "jline" % versionProps("jline.version")
+val antDep = "org.apache.ant" % "ant" % "1.9.4"
/** Publish to ./dists/maven-sbt, similar to the ANT build which publishes to ./dists/maven. This
* can be used to compare the output of the sbt and ANT builds during the transition period. Any
@@ -114,20 +112,27 @@ lazy val publishSettings : Seq[Setting[_]] = Seq(
globalVersionSettings
baseVersion in Global := "2.12.0"
baseVersionSuffix in Global := "SNAPSHOT"
+mimaReferenceVersion in Global := Some("2.11.0")
lazy val commonSettings = clearSourceAndResourceDirectories ++ publishSettings ++ Seq[Setting[_]](
organization := "org.scala-lang",
- scalaVersion := bootstrapScalaVersion,
// we don't cross build Scala itself
crossPaths := false,
// do not add Scala library jar as a dependency automatically
autoScalaLibrary := false,
- // we also do not add scala instance automatically because it introduces
- // a circular instance, see: https://github.com/sbt/sbt/issues/1872
+ // Avoid circular dependencies for scalaInstance (see https://github.com/sbt/sbt/issues/1872)
managedScalaInstance := false,
- // this is a way to workaround issue described in https://github.com/sbt/sbt/issues/1872
- // check it out for more details
- scalaInstance := ScalaInstance(scalaVersion.value, appConfiguration.value.provider.scalaProvider.launcher getScala scalaVersion.value),
+ scalaInstance := {
+ val s = (scalaInstance in bootstrap).value
+ // sbt claims that s.isManagedVersion is false even though s was resolved by Ivy
+ // We create a managed copy to prevent sbt from putting it on the classpath where we don't want it
+ if(s.isManagedVersion) s else {
+ val s2 = new ScalaInstance(s.version, s.loader, s.libraryJar, s.compilerJar, s.extraJars, Some(s.actualVersion))
+ assert(s2.isManagedVersion)
+ s2
+ }
+ },
+ scalaVersion := (scalaVersion in bootstrap).value,
// we always assume that Java classes are standalone and do not have any dependency
// on Scala classes
compileOrder := CompileOrder.JavaThenScala,
@@ -148,7 +153,7 @@ lazy val commonSettings = clearSourceAndResourceDirectories ++ publishSettings +
target := (baseDirectory in ThisBuild).value / "target" / thisProject.value.id,
classDirectory in Compile := buildDirectory.value / "quick/classes" / thisProject.value.id,
target in Compile in doc := buildDirectory.value / "scaladoc" / thisProject.value.id,
- // given that classDirectory and doc target are overriden to be _outside_ of target directory, we have
+ // given that classDirectory and doc target are overridden to be _outside_ of target directory, we have
// to make sure they are being cleaned properly
cleanFiles += (classDirectory in Compile).value,
cleanFiles += (target in Compile in doc).value,
@@ -163,9 +168,10 @@ lazy val commonSettings = clearSourceAndResourceDirectories ++ publishSettings +
"-sourcepath", (baseDirectory in ThisBuild).value.toString,
"-doc-source-url", s"https://github.com/scala/scala/tree/${versionProperties.value.githubTree}€{FILE_PATH}.scala#L1"
),
+ incOptions <<= (incOptions in LocalProject("root")),
homepage := Some(url("http://www.scala-lang.org")),
startYear := Some(2002),
- licenses += ("BSD 3-Clause", url("http://www.scala-lang.org/license.html")),
+ licenses += (("BSD 3-Clause", url("http://www.scala-lang.org/license.html"))),
apiURL := Some(url("http://www.scala-lang.org/api/" + versionProperties.value.mavenVersion + "/")),
pomIncludeRepository := { _ => false },
pomExtra := {
@@ -210,8 +216,7 @@ lazy val commonSettings = clearSourceAndResourceDirectories ++ publishSettings +
// Don't log process output (e.g. of forked `compiler/runMain ...Main`), just pass it
// directly to stdout
outputStrategy in run := Some(StdoutOutput),
- Quiet.silenceScalaBinaryVersionWarning,
- Quiet.silenceIvyUpdateInfoLogging
+ Quiet.silenceScalaBinaryVersionWarning
)
/** Extra post-processing for the published POM files. These are needed to create POMs that
@@ -247,7 +252,7 @@ def removePomDependencies(deps: (String, String)*): Seq[Setting[_]] = Seq(
val n2 = pomPostProcess.value.apply(n)
import scala.xml._
import scala.xml.transform._
- (new RuleTransformer(new RewriteRule {
+ new RuleTransformer(new RewriteRule {
override def transform(node: Node) = node match {
case e: Elem if e.label == "dependency" &&
deps.exists { case (g, a) =>
@@ -256,13 +261,13 @@ def removePomDependencies(deps: (String, String)*): Seq[Setting[_]] = Seq(
} => Seq.empty
case n => Seq(n)
}
- })).transform(Seq(n2)).head
+ }).transform(Seq(n2)).head
},
deliverLocal := {
import scala.xml._
import scala.xml.transform._
val f = deliverLocal.value
- val e = (new RuleTransformer(new RewriteRule {
+ val e = new RuleTransformer(new RewriteRule {
override def transform(node: Node) = node match {
case e: Elem if e.label == "dependency" && {
val org = e.attribute("org").getOrElse("").toString
@@ -273,7 +278,7 @@ def removePomDependencies(deps: (String, String)*): Seq[Setting[_]] = Seq(
} => Seq.empty
case n => Seq(n)
}
- })).transform(Seq(XML.loadFile(f))).head
+ }).transform(Seq(XML.loadFile(f))).head
XML.save(f.getAbsolutePath, e, xmlDecl = true)
f
}
@@ -306,7 +311,7 @@ lazy val setJarLocation: Setting[_] =
lazy val scalaSubprojectSettings: Seq[Setting[_]] = commonSettings :+ setJarLocation
def filterDocSources(ff: FileFilter): Seq[Setting[_]] = Seq(
- sources in (Compile, doc) ~= (_.filter(ff.accept _)),
+ sources in (Compile, doc) ~= (_.filter(ff.accept)),
// Excluded sources may still be referenced by the included sources, so we add the compiler
// output to the scaladoc classpath to resolve them. For the `library` project this is
// always required because otherwise the compiler cannot even initialize Definitions without
@@ -323,6 +328,11 @@ def regexFileFilter(s: String): FileFilter = new FileFilter {
def accept(f: File) = pat.matcher(f.getAbsolutePath.replace('\\', '/')).matches()
}
+// This project provides the STARR scalaInstance for bootstrapping
+lazy val bootstrap = (project in file("target/bootstrap")).settings(
+ scalaVersion := versionProps("starr.version")
+)
+
lazy val library = configureAsSubproject(project)
.settings(generatePropertiesFileSettings: _*)
.settings(Osgi.settings: _*)
@@ -356,6 +366,7 @@ lazy val library = configureAsSubproject(project)
.settings(filterDocSources("*.scala" -- (regexFileFilter(".*/runtime/.*\\$\\.scala") ||
regexFileFilter(".*/runtime/ScalaRunTime\\.scala") ||
regexFileFilter(".*/runtime/StringAdd\\.scala"))): _*)
+ .settings(MiMa.settings: _*)
lazy val reflect = configureAsSubproject(project)
.settings(generatePropertiesFileSettings: _*)
@@ -377,6 +388,7 @@ lazy val reflect = configureAsSubproject(project)
"/project/packaging" -> <packaging>jar</packaging>
)
)
+ .settings(MiMa.settings: _*)
.dependsOn(library)
lazy val compiler = configureAsSubproject(project)
@@ -553,6 +565,56 @@ lazy val junit = project.in(file("test") / "junit")
unmanagedSourceDirectories in Test := List(baseDirectory.value)
)
+lazy val osgiTestFelix = osgiTestProject(
+ project.in(file(".") / "target" / "osgiTestFelix"),
+ "org.apache.felix" % "org.apache.felix.framework" % "4.4.0")
+
+lazy val osgiTestEclipse = osgiTestProject(
+ project.in(file(".") / "target" / "osgiTestEclipse"),
+ "org.eclipse.osgi" % "org.eclipse.osgi" % "3.7.1")
+
+def osgiTestProject(p: Project, framework: ModuleID) = p
+ .dependsOn(library, reflect, compiler)
+ .settings(clearSourceAndResourceDirectories: _*)
+ .settings(commonSettings: _*)
+ .settings(disableDocs: _*)
+ .settings(disablePublishing: _*)
+ .settings(
+ fork in Test := true,
+ parallelExecution in Test := false,
+ libraryDependencies ++= {
+ val paxExamVersion = "3.5.0" // Last version which supports Java 6
+ Seq(
+ junitDep,
+ junitInterfaceDep,
+ "org.ops4j.pax.exam" % "pax-exam-container-native" % paxExamVersion
+ exclude("org.osgi", "org.osgi.core"), // Avoid dragging in a dependency which requires Java >6
+ "org.osgi" % "org.osgi.core" % "4.2.0" % "provided", // The framework (Felix / Eclipse) provides the classes
+ "org.ops4j.pax.exam" % "pax-exam-junit4" % paxExamVersion,
+ "org.ops4j.pax.exam" % "pax-exam-link-assembly" % paxExamVersion,
+ "org.ops4j.pax.url" % "pax-url-aether" % "2.2.0",
+ "org.ops4j.pax.swissbox" % "pax-swissbox-tracker" % "1.8.0",
+ "ch.qos.logback" % "logback-core" % "1.1.2",
+ "ch.qos.logback" % "logback-classic" % "1.1.2",
+ framework % "test"
+ )
+ },
+ Keys.test in Test <<= Keys.test in Test dependsOn (packageBin in Compile),
+ testOptions += Tests.Argument(TestFrameworks.JUnit, "-a", "-v", "-q"),
+ unmanagedSourceDirectories in Test := List((baseDirectory in ThisBuild).value / "test" / "osgi" / "src"),
+ unmanagedResourceDirectories in Compile := (unmanagedSourceDirectories in Test).value,
+ includeFilter in unmanagedResources in Compile := "*.xml",
+ packageBin in Compile := { // Put the bundle JARs required for the tests into build/osgi
+ val targetDir = (buildDirectory in ThisBuild).value / "osgi"
+ val mappings = ((mkPack in dist).value / "lib").listFiles.collect {
+ case f if f.getName.startsWith("scala-") && f.getName.endsWith(".jar") => (f, targetDir / f.getName)
+ }
+ IO.copy(mappings, overwrite = true)
+ targetDir
+ },
+ cleanFiles += (buildDirectory in ThisBuild).value / "osgi"
+ )
+
lazy val partestJavaAgent = Project("partest-javaagent", file(".") / "src" / "partest-javaagent")
.settings(commonSettings: _*)
.settings(generatePropertiesFileSettings: _*)
@@ -582,8 +644,15 @@ lazy val test = project
.settings(Defaults.itSettings: _*)
.settings(
libraryDependencies ++= Seq(asmDep, partestDep, scalaXmlDep, scalacheckDep),
- unmanagedBase in IntegrationTest := baseDirectory.value / "files" / "lib",
- unmanagedJars in IntegrationTest <+= (unmanagedBase) (j => Attributed.blank(j)) map(identity),
+ libraryDependencies ++= {
+ // Resolve the JARs for all test/files/lib/*.jar.desired.sha1 files through Ivy
+ val baseDir = (baseDirectory in ThisBuild).value
+ (baseDir / "test/files/lib").list.toSeq.filter(_.endsWith(".jar.desired.sha1"))
+ .map(f => bootstrapDep(baseDir, "test/files/lib", f.dropRight(17)))
+ },
+ // Two hardcoded depenencies in partest, resolved in the otherwise unused scope "test":
+ libraryDependencies += bootstrapDep((baseDirectory in ThisBuild).value, "test/files/codelib", "code") % "test",
+ libraryDependencies += bootstrapDep((baseDirectory in ThisBuild).value, "test/files/speclib", "instrumented") % "test",
// no main sources
sources in Compile := Seq.empty,
// test sources are compiled in partest run, not here
@@ -591,18 +660,24 @@ lazy val test = project
fork in IntegrationTest := true,
javaOptions in IntegrationTest += "-Xmx1G",
testFrameworks += new TestFramework("scala.tools.partest.sbt.Framework"),
- testOptions in IntegrationTest += Tests.Setup( () => root.base.getAbsolutePath + "/pull-binary-libs.sh" ! ),
testOptions in IntegrationTest += Tests.Argument("-Dpartest.java_opts=-Xmx1024M -Xms64M -XX:MaxPermSize=128M"),
- definedTests in IntegrationTest += (
- new sbt.TestDefinition(
- "partest",
- // marker fingerprint since there are no test classes
- // to be discovered by sbt:
- new sbt.testing.AnnotatedFingerprint {
- def isModule = true
- def annotationName = "partest"
- }, true, Array())
- )
+ testOptions in IntegrationTest += Tests.Argument("-Dpartest.scalac_opts=" + (scalacOptions in Compile).value.mkString(" ")),
+ testOptions in IntegrationTest += Tests.Setup { () =>
+ val cp = (dependencyClasspath in Test).value
+ val baseDir = (baseDirectory in ThisBuild).value
+ // Copy code.jar and instrumented.jar to the location where partest expects them
+ copyBootstrapJar(cp, baseDir, "test/files/codelib", "code")
+ copyBootstrapJar(cp, baseDir, "test/files/speclib", "instrumented")
+ },
+ definedTests in IntegrationTest += new sbt.TestDefinition(
+ "partest",
+ // marker fingerprint since there are no test classes
+ // to be discovered by sbt:
+ new sbt.testing.AnnotatedFingerprint {
+ def isModule = true
+ def annotationName = "partest"
+ }, true, Array()
+ )
)
lazy val manual = configureAsSubproject(project)
@@ -676,7 +751,7 @@ lazy val scalaDist = Project("scala-dist", file(".") / "target" / "scala-dist-di
)
.dependsOn(libraryAll, compiler, scalap)
-lazy val root = (project in file("."))
+lazy val root: Project = (project in file("."))
.settings(disableDocs: _*)
.settings(disablePublishing: _*)
.settings(generateBuildCharacterFileSettings: _*)
@@ -694,7 +769,8 @@ lazy val root = (project in file("."))
GenerateAnyVals.run(dir.getAbsoluteFile)
state
},
- Quiet.silenceIvyUpdateInfoLogging
+ antStyle := false,
+ incOptions := incOptions.value.withNameHashing(!antStyle.value).withAntStyle(antStyle.value)
)
.aggregate(library, reflect, compiler, interactive, repl, replJline, replJlineEmbedded,
scaladoc, scalap, partestExtras, junit, libraryAll, scalaDist).settings(
@@ -717,8 +793,9 @@ lazy val dist = (project in file("dist"))
val props = new java.util.Properties()
props.setProperty("partest.classpath", cp.map(_.data.getAbsolutePath).mkString(sys.props("path.separator")))
IO.write(props, null, propsFile)
+ (buildDirectory in ThisBuild).value / "quick"
} dependsOn ((distDependencies.map(products in Runtime in _) :+ mkBin): _*),
- mkPack <<= Def.task {} dependsOn (packagedArtifact in (Compile, packageBin), mkBin),
+ mkPack <<= Def.task { (buildDirectory in ThisBuild).value / "pack" } dependsOn (packagedArtifact in (Compile, packageBin), mkBin),
target := (baseDirectory in ThisBuild).value / "target" / thisProject.value.id,
packageBin in Compile := {
val extraDeps = Set(scalaSwingDep, scalaParserCombinatorsDep, scalaXmlDep)
@@ -729,7 +806,7 @@ lazy val dist = (project in file("dist"))
case (Some(m), f) if extraModules contains uniqueModule(m) => f
}
val jlineJAR = (dependencyClasspath in Compile).value.find(_.get(moduleID.key) == Some(jlineDep)).get.data
- val mappings = extraJars.map(f => (f, targetDir / f.getName)) :+ (jlineJAR, targetDir / "jline.jar")
+ val mappings = extraJars.map(f => (f, targetDir / f.getName)) :+ ((jlineJAR, targetDir / "jline.jar"))
IO.copy(mappings, overwrite = true)
targetDir
},
@@ -759,8 +836,8 @@ def configureAsSubproject(project: Project): Project = {
lazy val buildDirectory = settingKey[File]("The directory where all build products go. By default ./build")
lazy val mkBin = taskKey[Seq[File]]("Generate shell script (bash or Windows batch).")
-lazy val mkQuick = taskKey[Unit]("Generate a full build, including scripts, in build/quick")
-lazy val mkPack = taskKey[Unit]("Generate a full build, including scripts, in build/pack")
+lazy val mkQuick = taskKey[File]("Generate a full build, including scripts, in build/quick")
+lazy val mkPack = taskKey[File]("Generate a full build, including scripts, in build/pack")
// Defining these settings is somewhat redundant as we also redefine settings that depend on them.
// However, IntelliJ's project import works better when these are set correctly.
@@ -884,7 +961,7 @@ intellij := {
def moduleDep(name: String, jars: Seq[File]) = {
val entries = jars.map(f => s""" <root url="jar://${f.toURI.getRawPath}!/" />""").mkString("\n")
- s"""| <library name="${name}-deps">
+ s"""| <library name="$name-deps">
| <CLASSES>
|$entries
| </CLASSES>