diff options
Diffstat (limited to 'build.sbt')
-rw-r--r-- | build.sbt | 206 |
1 files changed, 126 insertions, 80 deletions
@@ -39,6 +39,7 @@ val scalaSwingDep = scalaDep("org.scala-lang.modules", "scala-swi val scalaXmlDep = scalaDep("org.scala-lang.modules", "scala-xml") val scalaParserCombinatorsDep = scalaDep("org.scala-lang.modules", "scala-parser-combinators") 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" @@ -86,10 +87,12 @@ lazy val publishSettings : Seq[Setting[_]] = Seq( // should not be set directly. It is the same as the Maven version and derived automatically from `baseVersion` and // `baseVersionSuffix`. globalVersionSettings -baseVersion in Global := "2.12.0" +baseVersion in Global := "2.12.1" baseVersionSuffix in Global := "SNAPSHOT" mimaReferenceVersion in Global := Some("2.12.0-RC1") +scalaVersion in Global := versionProps("starr.version") + lazy val commonSettings = clearSourceAndResourceDirectories ++ publishSettings ++ Seq[Setting[_]]( organization := "org.scala-lang", // we don't cross build Scala itself @@ -103,12 +106,20 @@ lazy val commonSettings = clearSourceAndResourceDirectories ++ publishSettings + // 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)) + val jars = s.jars + val libraryJar = jars.find(_.getName contains "-library").get + val compilerJar = jars.find(_.getName contains "-compiler").get + val extraJars = jars.filter(f => (f ne libraryJar) && (f ne compilerJar)) + val s2 = new ScalaInstance(s.version, s.loader, libraryJar, compilerJar, extraJars, Some(s.actualVersion)) assert(s2.isManagedVersion) s2 } }, - scalaVersion := (scalaVersion in bootstrap).value, + // As of sbt 0.13.12 (sbt/sbt#2634) sbt endeavours to align both scalaOrganization and scalaVersion + // in the Scala artefacts, for example scala-library and scala-compiler. + // This doesn't work in the scala/scala build because the version of scala-library and the scalaVersion of + // scala-library are correct to be different. So disable overriding. + ivyScala ~= (_ map (_ copy (overrideScalaVersion = false))), // we always assume that Java classes are standalone and do not have any dependency // on Scala classes compileOrder := CompileOrder.JavaThenScala, @@ -141,7 +152,7 @@ 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")), + incOptions := (incOptions in LocalProject("root")).value, homepage := Some(url("http://www.scala-lang.org")), startYear := Some(2002), licenses += (("BSD 3-Clause", url("http://www.scala-lang.org/license.html"))), @@ -190,7 +201,7 @@ lazy val commonSettings = clearSourceAndResourceDirectories ++ publishSettings + // directly to stdout outputStrategy in run := Some(StdoutOutput), Quiet.silenceScalaBinaryVersionWarning -) +) ++ removePomDependencies /** Extra post-processing for the published POM files. These are needed to create POMs that * are equivalent to the ones from the Ant build. In the long term this should be removed and @@ -219,10 +230,16 @@ def fixPom(extra: (String, scala.xml.Node)*): Setting[_] = { ) ++ extra) } } +val pomDependencyExclusions = + settingKey[Seq[(String, String)]]("List of (groupId, artifactId) pairs to exclude from the POM and ivy.xml") + +pomDependencyExclusions in Global := Nil + /** Remove unwanted dependencies from the POM and ivy.xml. */ -def removePomDependencies(deps: (String, String)*): Seq[Setting[_]] = Seq( +lazy val removePomDependencies: Seq[Setting[_]] = Seq( pomPostProcess := { n => val n2 = pomPostProcess.value.apply(n) + val deps = pomDependencyExclusions.value import scala.xml._ import scala.xml.transform._ new RuleTransformer(new RewriteRule { @@ -240,6 +257,7 @@ def removePomDependencies(deps: (String, String)*): Seq[Setting[_]] = Seq( import scala.xml._ import scala.xml.transform._ val f = deliverLocal.value + val deps = pomDependencyExclusions.value val e = new RuleTransformer(new RewriteRule { override def transform(node: Node) = node match { case e: Elem if e.label == "dependency" && { @@ -291,7 +309,7 @@ def filterDocSources(ff: FileFilter): Seq[Setting[_]] = Seq( // binaries of the library on the classpath. Specifically, we get this error: // (library/compile:doc) scala.reflect.internal.FatalError: package class scala does not have a member Int dependencyClasspath in (Compile, doc) += (classDirectory in Compile).value, - doc in Compile <<= doc in Compile dependsOn (compile in Compile) + doc in Compile := (doc in Compile).dependsOn(compile in Compile).value ) def regexFileFilter(s: String): FileFilter = new FileFilter { @@ -300,13 +318,11 @@ def regexFileFilter(s: String): FileFilter = new FileFilter { } // This project provides the STARR scalaInstance for bootstrapping -lazy val bootstrap = (project in file("target/bootstrap")).settings( - scalaVersion := versionProps("starr.version") -) +lazy val bootstrap = project in file("target/bootstrap") lazy val library = configureAsSubproject(project) - .settings(generatePropertiesFileSettings: _*) - .settings(Osgi.settings: _*) + .settings(generatePropertiesFileSettings) + .settings(Osgi.settings) .settings( name := "scala-library", description := "Scala Standard Library", @@ -320,6 +336,8 @@ lazy val library = configureAsSubproject(project) "-doc-root-content", (sourceDirectory in Compile).value + "/rootdoc.txt" ) }, + // macros in library+reflect are hard-wired to implementations with `FastTrack`. + incOptions := incOptions.value.withRecompileOnMacroDef(false), includeFilter in unmanagedResources in Compile := "*.tmpl" | "*.xml" | "*.js" | "*.css" | "rootdoc.txt", // Include *.txt files in source JAR: mappings in Compile in packageSrc ++= { @@ -332,19 +350,23 @@ lazy val library = configureAsSubproject(project) "/project/name" -> <name>Scala Library</name>, "/project/description" -> <description>Standard library for the Scala Programming Language</description>, "/project/packaging" -> <packaging>jar</packaging> - ) + ), + // Remove the dependency on "forkjoin" from the POM because it is included in the JAR: + pomDependencyExclusions += ((organization.value, "forkjoin")) ) .settings(filterDocSources("*.scala" -- (regexFileFilter(".*/runtime/.*\\$\\.scala") || regexFileFilter(".*/runtime/ScalaRunTime\\.scala") || - regexFileFilter(".*/runtime/StringAdd\\.scala"))): _*) - .settings(MiMa.settings: _*) + regexFileFilter(".*/runtime/StringAdd\\.scala")))) + .settings(MiMa.settings) lazy val reflect = configureAsSubproject(project) - .settings(generatePropertiesFileSettings: _*) - .settings(Osgi.settings: _*) + .settings(generatePropertiesFileSettings) + .settings(Osgi.settings) .settings( name := "scala-reflect", description := "Scala Reflection Library", + // macros in library+reflect are hard-wired to implementations with `FastTrack`. + incOptions := incOptions.value.withRecompileOnMacroDef(false), Osgi.bundleName := "Scala Reflect", scalacOptions in Compile in doc ++= Seq( "-skip-packages", "scala.reflect.macros.internal:scala.reflect.internal:scala.reflect.io" @@ -359,18 +381,21 @@ lazy val reflect = configureAsSubproject(project) "/project/packaging" -> <packaging>jar</packaging> ) ) - .settings(MiMa.settings: _*) + .settings(MiMa.settings) .dependsOn(library) lazy val compiler = configureAsSubproject(project) - .settings(generatePropertiesFileSettings: _*) - .settings(Osgi.settings: _*) + .settings(generatePropertiesFileSettings) + .settings(generateBuildCharacterFileSettings) + .settings(Osgi.settings) .settings( name := "scala-compiler", description := "Scala Compiler", libraryDependencies ++= Seq(antDep, asmDep), // These are only needed for the POM: libraryDependencies ++= Seq(scalaXmlDep, jlineDep % "optional"), + buildCharacterPropertiesFile := (resourceManaged in Compile).value / "scala-buildcharacter.properties", + resourceGenerators in Compile += generateBuildCharacterPropertiesFile.map(file => Seq(file)).taskValue, // this a way to make sure that classes from interactive and scaladoc projects // end up in compiler jar. note that we need to use LocalProject references // (with strings) to deal with mutual recursion @@ -393,6 +418,16 @@ lazy val compiler = configureAsSubproject(project) (unmanagedResourceDirectories in Compile in LocalProject("repl")).value base ** ((includeFilter in unmanagedResources in Compile).value || "*.scala" || "*.psd" || "*.ai" || "*.java") pair relativeTo(base) }, + // Include the additional projects in the scaladoc JAR: + sources in Compile in doc ++= { + val base = + (unmanagedSourceDirectories in Compile in LocalProject("interactive")).value ++ + (unmanagedSourceDirectories in Compile in LocalProject("scaladoc")).value ++ + (unmanagedSourceDirectories in Compile in LocalProject("repl")).value + ((base ** ("*.scala" || "*.java")) + --- (base ** "Scaladoc*ModelTest.scala") // exclude test classes that depend on partest + ).get + }, scalacOptions in Compile in doc ++= Seq( "-doc-root-content", (sourceDirectory in Compile).value + "/rootdoc.txt" ), @@ -413,17 +448,14 @@ lazy val compiler = configureAsSubproject(project) "/project/description" -> <description>Compiler for the Scala Programming Language</description>, "/project/packaging" -> <packaging>jar</packaging> ), - apiURL := None + apiURL := None, + pomDependencyExclusions ++= List(("org.apache.ant", "ant"), ("org.scala-lang.modules", "scala-asm")) ) - .settings(removePomDependencies( - ("org.apache.ant", "ant"), - ("org.scala-lang.modules", "scala-asm") - ): _*) .dependsOn(library, reflect) lazy val interactive = configureAsSubproject(project) - .settings(disableDocs: _*) - .settings(disablePublishing: _*) + .settings(disableDocs) + .settings(disablePublishing) .settings( name := "scala-compiler-interactive", description := "Scala Interactive Compiler" @@ -431,17 +463,17 @@ lazy val interactive = configureAsSubproject(project) .dependsOn(compiler) lazy val repl = configureAsSubproject(project) - .settings(disableDocs: _*) - .settings(disablePublishing: _*) + .settings(disableDocs) + .settings(disablePublishing) .settings( connectInput in run := true, - run <<= (run in Compile).partialInput(" -usejavacp") // Automatically add this so that `repl/run` works without additional arguments. + run := (run in Compile).partialInput(" -usejavacp").evaluated // Automatically add this so that `repl/run` works without additional arguments. ) .dependsOn(compiler, interactive) lazy val replJline = configureAsSubproject(Project("repl-jline", file(".") / "src" / "repl-jline")) - .settings(disableDocs: _*) - .settings(disablePublishing: _*) + .settings(disableDocs) + .settings(disablePublishing) .settings( libraryDependencies += jlineDep, name := "scala-repl-jline" @@ -449,8 +481,8 @@ lazy val replJline = configureAsSubproject(Project("repl-jline", file(".") / "sr .dependsOn(repl) lazy val replJlineEmbedded = Project("repl-jline-embedded", file(".") / "target" / "repl-jline-embedded-src-dummy") - .settings(scalaSubprojectSettings: _*) - .settings(disablePublishing: _*) + .settings(scalaSubprojectSettings) + .settings(disablePublishing) .settings( name := "scala-repl-jline-embedded", // There is nothing to compile for this project. Instead we use the compile task to create @@ -458,7 +490,7 @@ lazy val replJlineEmbedded = Project("repl-jline-embedded", file(".") / "target" // quick/repl-jline and quick/repl-jline-shaded on the classpath for quick/bin scripts. // This is different from the Ant build where all parts are combined into quick/repl, but // it is cleaner because it avoids circular dependencies. - compile in Compile <<= (compile in Compile).dependsOn(Def.task { + compile in Compile := (compile in Compile).dependsOn(Def.task { import java.util.jar._ import collection.JavaConverters._ val inputs: Iterator[JarJar.Entry] = { @@ -480,15 +512,15 @@ lazy val replJlineEmbedded = Project("repl-jline-embedded", file(".") / "target" ) val outdir = (classDirectory in Compile).value JarJar(inputs, outdir, config) - }), + }).value, connectInput in run := true ) .dependsOn(replJline) lazy val scaladoc = configureAsSubproject(project) - .settings(disableDocs: _*) - .settings(disablePublishing: _*) + .settings(disableDocs) + .settings(disablePublishing) .settings( name := "scala-compiler-doc", description := "Scala Documentation Generator", @@ -512,11 +544,11 @@ lazy val scalap = configureAsSubproject(project) lazy val partestExtras = Project("partest-extras", file(".") / "src" / "partest-extras") .dependsOn(replJlineEmbedded) - .settings(commonSettings: _*) - .settings(generatePropertiesFileSettings: _*) - .settings(clearSourceAndResourceDirectories: _*) - .settings(disableDocs: _*) - .settings(disablePublishing: _*) + .settings(commonSettings) + .settings(generatePropertiesFileSettings) + .settings(clearSourceAndResourceDirectories) + .settings(disableDocs) + .settings(disablePublishing) .settings( name := "scala-partest-extras", description := "Scala Compiler Testing Tool (compiler-specific extras)", @@ -526,16 +558,17 @@ lazy val partestExtras = Project("partest-extras", file(".") / "src" / "partest- lazy val junit = project.in(file("test") / "junit") .dependsOn(library, reflect, compiler, partestExtras, scaladoc) - .settings(clearSourceAndResourceDirectories: _*) - .settings(commonSettings: _*) - .settings(disableDocs: _*) - .settings(disablePublishing: _*) + .settings(clearSourceAndResourceDirectories) + .settings(commonSettings) + .settings(disableDocs) + .settings(disablePublishing) .settings( fork in Test := true, javaOptions in Test += "-Xss1M", libraryDependencies ++= Seq(junitDep, junitInterfaceDep, jolDep), testOptions += Tests.Argument(TestFrameworks.JUnit, "-a", "-v"), - testFrameworks -= new TestFramework("org.scalacheck.ScalaCheckFramework"), + // testFrameworks -= new TestFramework("org.scalacheck.ScalaCheckFramework"), + unmanagedSourceDirectories in Compile := Nil, unmanagedSourceDirectories in Test := List(baseDirectory.value) ) @@ -549,10 +582,10 @@ lazy val osgiTestEclipse = osgiTestProject( def osgiTestProject(p: Project, framework: ModuleID) = p .dependsOn(library, reflect, compiler) - .settings(clearSourceAndResourceDirectories: _*) - .settings(commonSettings: _*) - .settings(disableDocs: _*) - .settings(disablePublishing: _*) + .settings(clearSourceAndResourceDirectories) + .settings(commonSettings) + .settings(disableDocs) + .settings(disablePublishing) .settings( fork in Test := true, parallelExecution in Test := false, @@ -572,7 +605,7 @@ def osgiTestProject(p: Project, framework: ModuleID) = p framework % "test" ) }, - Keys.test in Test <<= Keys.test in Test dependsOn (packageBin in Compile), + Keys.test in Test := (Keys.test in Test).dependsOn(packageBin in Compile).value, 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, @@ -589,9 +622,9 @@ def osgiTestProject(p: Project, framework: ModuleID) = p ) lazy val partestJavaAgent = Project("partest-javaagent", file(".") / "src" / "partest-javaagent") - .settings(commonSettings: _*) - .settings(generatePropertiesFileSettings: _*) - .settings(disableDocs: _*) + .settings(commonSettings) + .settings(generatePropertiesFileSettings) + .settings(disableDocs) .settings( libraryDependencies += asmDep, publishLocal := {}, @@ -609,12 +642,12 @@ lazy val partestJavaAgent = Project("partest-javaagent", file(".") / "src" / "pa lazy val test = project .dependsOn(compiler, interactive, replJlineEmbedded, scalap, partestExtras, partestJavaAgent, scaladoc) .configs(IntegrationTest) - .settings(commonSettings: _*) - .settings(disableDocs: _*) - .settings(disablePublishing: _*) - .settings(Defaults.itSettings: _*) + .settings(commonSettings) + .settings(disableDocs) + .settings(disablePublishing) + .settings(Defaults.itSettings) .settings( - libraryDependencies ++= Seq(asmDep, partestDep, scalaXmlDep), + libraryDependencies ++= Seq(asmDep, partestDep, scalaXmlDep, scalacheckDep), libraryDependencies ++= { // Resolve the JARs for all test/files/lib/*.jar.desired.sha1 files through Ivy val baseDir = (baseDirectory in ThisBuild).value @@ -631,8 +664,8 @@ lazy val test = project fork in IntegrationTest := true, javaOptions in IntegrationTest += "-Xmx2G", testFrameworks += new TestFramework("scala.tools.partest.sbt.Framework"), - testFrameworks -= new TestFramework("org.scalacheck.ScalaCheckFramework"), - testOptions in IntegrationTest += Tests.Argument("-Dpartest.java_opts=-Xmx1024M -Xms64M -XX:MaxPermSize=128M"), + // testFrameworks -= new TestFramework("org.scalacheck.ScalaCheckFramework"), + testOptions in IntegrationTest += Tests.Argument("-Dpartest.java_opts=-Xmx1024M -Xms64M"), testOptions in IntegrationTest += Tests.Argument("-Dpartest.scalac_opts=" + (scalacOptions in Compile).value.mkString(" ")), testOptions in IntegrationTest += Tests.Setup { () => val cp = (dependencyClasspath in Test).value @@ -663,16 +696,16 @@ lazy val test = project ) lazy val manual = configureAsSubproject(project) - .settings(disableDocs: _*) - .settings(disablePublishing: _*) + .settings(disableDocs) + .settings(disablePublishing) .settings( libraryDependencies ++= Seq(scalaXmlDep, antDep, "org.scala-lang" % "scala-library" % scalaVersion.value), classDirectory in Compile := (target in Compile).value / "classes" ) lazy val libraryAll = Project("library-all", file(".") / "target" / "library-all-src-dummy") - .settings(commonSettings: _*) - .settings(disableDocs: _*) + .settings(commonSettings) + .settings(disableDocs) .settings( name := "scala-library-all", publishArtifact in (Compile, packageBin) := false, @@ -687,8 +720,8 @@ lazy val libraryAll = Project("library-all", file(".") / "target" / "library-all .dependsOn(library, reflect) lazy val scalaDist = Project("scala-dist", file(".") / "target" / "scala-dist-dist-src-dummy") - .settings(commonSettings: _*) - .settings(disableDocs: _*) + .settings(commonSettings) + .settings(disableDocs) .settings( mappings in Compile in packageBin ++= { val binBaseDir = buildDirectory.value / "pack" @@ -733,13 +766,23 @@ lazy val scalaDist = Project("scala-dist", file(".") / "target" / "scala-dist-di .dependsOn(libraryAll, compiler, scalap) lazy val root: Project = (project in file(".")) - .settings(disableDocs: _*) - .settings(disablePublishing: _*) - .settings(generateBuildCharacterFileSettings: _*) + .settings(disableDocs) + .settings(disablePublishing) + .settings(generateBuildCharacterFileSettings) .settings( - publish := {}, - publishLocal := {}, commands ++= ScriptCommands.all, + extractBuildCharacterPropertiesFile := { + val jar = (scalaInstance in bootstrap).value.allJars.find(_.getName contains "-compiler").get + val bc = buildCharacterPropertiesFile.value + val packagedName = "scala-buildcharacter.properties" + IO.withTemporaryDirectory { tmp => + val extracted = IO.unzip(jar, tmp, new SimpleFilter(_ == packagedName)).headOption.getOrElse { + throw new RuntimeException(s"No file $packagedName found in bootstrap compiler $jar") + } + IO.copyFile(extracted, bc) + bc + } + }, // Generate (Product|TupleN|Function|AbstractFunction)*.scala files and scaladoc stubs for all AnyVal sources. // They should really go into a managedSources dir instead of overwriting sources checked into git but scaladoc // source links (could be fixed by shipping these sources with the scaladoc bundles) and scala-js source maps @@ -841,15 +884,15 @@ lazy val dist = (project in file("dist")) .settings( libraryDependencies ++= Seq(scalaSwingDep, jlineDep), mkBin := mkBinImpl.value, - mkQuick <<= Def.task { + mkQuick := Def.task { val cp = (fullClasspath in IntegrationTest in LocalProject("test")).value val propsFile = (buildDirectory in ThisBuild).value / "quick" / "partest.properties" 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 { (buildDirectory in ThisBuild).value / "pack" } dependsOn (packagedArtifact in (Compile, packageBin), mkBin), + }.dependsOn((distDependencies.map(products in Runtime in _) :+ mkBin): _*).value, + mkPack := Def.task { (buildDirectory in ThisBuild).value / "pack" }.dependsOn(packagedArtifact in (Compile, packageBin), mkBin).value, target := (baseDirectory in ThisBuild).value / "target" / thisProject.value.id, packageBin in Compile := { val extraDeps = Set(scalaSwingDep, scalaParserCombinatorsDep, scalaXmlDep) @@ -866,7 +909,10 @@ lazy val dist = (project in file("dist")) }, cleanFiles += (buildDirectory in ThisBuild).value / "quick", cleanFiles += (buildDirectory in ThisBuild).value / "pack", - packagedArtifact in (Compile, packageBin) <<= (packagedArtifact in (Compile, packageBin)).dependsOn(distDependencies.map(packagedArtifact in (Compile, packageBin) in _): _*) + packagedArtifact in (Compile, packageBin) := + (packagedArtifact in (Compile, packageBin)) + .dependsOn(distDependencies.map(packagedArtifact in (Compile, packageBin) in _): _*) + .value ) .dependsOn(distDependencies.map(p => p: ClasspathDep[ProjectReference]): _*) @@ -884,8 +930,8 @@ lazy val dist = (project in file("dist")) def configureAsSubproject(project: Project): Project = { val base = file(".") / "src" / project.id (project in base) - .settings(scalaSubprojectSettings: _*) - .settings(generatePropertiesFileSettings: _*) + .settings(scalaSubprojectSettings) + .settings(generatePropertiesFileSettings) } lazy val buildDirectory = settingKey[File]("The directory where all build products go. By default ./build") |