From 86d492c0b79b265a596cae1e4d8fd05cc1b11d53 Mon Sep 17 00:00:00 2001 From: Stefan Zeiger Date: Tue, 6 Sep 2016 21:55:16 +0200 Subject: Store buildcharacter.properties in scala-compiler.jar MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In addition to all the individual projects’ version properties files that we already keep in `scala-compiler.jar` we now write a new `scala-buildcharacter.properties` which is identical to the `buildcharacter.properties` written to the root directory by `generateBuildCharacterPropertiesFile`. The new task `extractBuildCharacterPropertiesFile` extracts it from the bootstrap Scala compiler and writes the usual `buildcharacter.properties`. This can be used to reproduce the exact version information for all modules in builds that start from an arbitrary published Scala version instead of being triggered directly by a bootstrap job. --- build.sbt | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'build.sbt') diff --git a/build.sbt b/build.sbt index 1105902a9d..0d27038a9f 100644 --- a/build.sbt +++ b/build.sbt @@ -364,6 +364,7 @@ lazy val reflect = configureAsSubproject(project) lazy val compiler = configureAsSubproject(project) .settings(generatePropertiesFileSettings: _*) + .settings(generateBuildCharacterFileSettings: _*) .settings(Osgi.settings: _*) .settings( name := "scala-compiler", @@ -371,6 +372,8 @@ lazy val compiler = configureAsSubproject(project) 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 @@ -740,6 +743,18 @@ lazy val root: Project = (project in file(".")) publish := {}, publishLocal := {}, commands ++= ScriptCommands.all, + extractBuildCharacterPropertiesFile := { + val jar = (scalaInstance in bootstrap).value.compilerJar + 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 -- cgit v1.2.3