@@ -433,6 +433,54 @@ object Build {
433433
434434 private lazy val currentYear : String = java.util.Calendar .getInstance().get(java.util.Calendar .YEAR ).toString
435435
436+ private val shellBanner : String =
437+ """ %n ________ ___ / / ___
438+ |%n / __/ __// _ | / / / _ |
439+ |%n __\\ \\ / /__/ __ |/ /__/ __ |
440+ |%n /____/\\ ___/_/ |_/____/_/ | |
441+ |%n |/ %s""" .stripMargin.replace(" \n " , " " )
442+
443+ // Common generator for properties files
444+ lazy val generatePropertiesFile = (fileName : String , contents : Def .Initialize [String ]) => Def .task {
445+ val file = (Compile / resourceManaged).value / fileName
446+ val data = contents.value
447+ if (! (file.exists && IO .read(file) == data)) {
448+ IO .write(file, data)
449+ }
450+ Seq (file)
451+ }
452+
453+ // Generate compiler.properties consumed by sbt
454+ lazy val generateCompilerProperties : Def .Initialize [Task [Seq [File ]]] = {
455+ import java .util ._
456+ import java .text ._
457+ val dateFormat = new SimpleDateFormat (" yyyyMMdd-HHmmss" )
458+ dateFormat.setTimeZone(TimeZone .getTimeZone(" GMT" ))
459+
460+ val fileName = " compiler.properties"
461+ val contents = Def .setting {
462+ s """ version.number= ${version.value}
463+ |maven.version.number= ${version.value}
464+ |git.hash= ${VersionUtil .gitHash}
465+ |copyright.string=Copyright 2002- $currentYear, LAMP/EPFL
466+ | """ .stripMargin
467+ }
468+ generatePropertiesFile(fileName, contents)
469+ }
470+
471+ // Generate library.properties consumed by scala.util.Properties
472+ lazy val generateLibraryProperties : Def .Initialize [Task [Seq [File ]]] = {
473+ val fileName = " library.properties"
474+ val contents = Def .setting {
475+ s """ version.number= ${version.value}
476+ |maven.version.number= ${version.value}
477+ |copyright.string=Copyright 2002- $currentYear, LAMP/EPFL
478+ |shell.banner= ${shellBanner}
479+ | """ .stripMargin
480+ }
481+ generatePropertiesFile(fileName, contents)
482+ }
483+
436484 def scalacOptionsDocSettings (includeExternalMappings : Boolean = true ) = {
437485 val extMap = Seq (" -external-mappings:" +
438486 (if (includeExternalMappings) " .*scala/.*::scaladoc3::https://dotty.epfl.ch/api/," else " " ) +
@@ -700,25 +748,7 @@ object Build {
700748 scalacOptions += " -Wconf:cat=deprecation&origin=scala\\ .collection\\ .mutable\\ .AnyRefMap.*:s" ,
701749
702750 // Generate compiler.properties, used by sbt
703- (Compile / resourceGenerators) += Def .task {
704- import java .util ._
705- import java .text ._
706- val file = (Compile / resourceManaged).value / " compiler.properties"
707- val dateFormat = new SimpleDateFormat (" yyyyMMdd-HHmmss" )
708- dateFormat.setTimeZone(TimeZone .getTimeZone(" GMT" ))
709- val contents = // 2.11.11.v20170413-090219-8a413ba7cc
710- s """ version.number= ${version.value}
711- |maven.version.number= ${version.value}
712- |git.hash= ${VersionUtil .gitHash}
713- |copyright.string=Copyright 2002- $currentYear, LAMP/EPFL
714- """ .stripMargin
715-
716- if (! (file.exists && IO .read(file) == contents)) {
717- IO .write(file, contents)
718- }
719-
720- Seq (file)
721- }.taskValue,
751+ (Compile / resourceGenerators) += generateCompilerProperties.taskValue,
722752
723753 // get libraries onboard
724754 libraryDependencies ++= Seq (
@@ -1916,6 +1946,8 @@ object Build {
19161946 customMimaReportBinaryIssues(" MiMaFilters.Scala3Library" ),
19171947 // Should we also patch .sjsir files
19181948 keepSJSIR := false ,
1949+ // Generate library.properties, used by scala.util.Properties
1950+ Compile / resourceGenerators += generateLibraryProperties.taskValue
19191951 )
19201952
19211953 /* Configuration of the org.scala-lang:scala3-library_3:*.**.**-nonbootstrapped project */
@@ -2041,6 +2073,8 @@ object Build {
20412073 customMimaReportBinaryIssues(" MiMaFilters.Scala3Library" ),
20422074 // Should we also patch .sjsir files
20432075 keepSJSIR := false ,
2076+ // Generate Scala 3 runtime properties overlay
2077+ Compile / resourceGenerators += generateLibraryProperties.taskValue,
20442078 )
20452079
20462080 /* Configuration of the org.scala-lang:scala3-library_3:*.**.**-bootstrapped project */
@@ -2444,25 +2478,7 @@ object Build {
24442478 // Project specific target folder. sbt doesn't like having two projects using the same target folder
24452479 target := target.value / " scala3-compiler-nonbootstrapped" ,
24462480 // Generate compiler.properties, used by sbt
2447- Compile / resourceGenerators += Def .task {
2448- import java .util ._
2449- import java .text ._
2450- val file = (Compile / resourceManaged).value / " compiler.properties"
2451- val dateFormat = new SimpleDateFormat (" yyyyMMdd-HHmmss" )
2452- dateFormat.setTimeZone(TimeZone .getTimeZone(" GMT" ))
2453- val contents = // 2.11.11.v20170413-090219-8a413ba7cc
2454- s """ version.number= ${version.value}
2455- |maven.version.number= ${version.value}
2456- |git.hash= ${VersionUtil .gitHash}
2457- |copyright.string=Copyright 2002- $currentYear, LAMP/EPFL
2458- """ .stripMargin
2459-
2460- if (! (file.exists && IO .read(file) == contents)) {
2461- IO .write(file, contents)
2462- }
2463-
2464- Seq (file)
2465- }.taskValue,
2481+ Compile / resourceGenerators += generateCompilerProperties.taskValue,
24662482 // sbt adds all the projects to scala-tool config which breaks building the scalaInstance
24672483 // as a workaround, I build it manually by only adding the compiler
24682484 managedScalaInstance := false ,
@@ -2612,25 +2628,7 @@ object Build {
26122628 // Project specific target folder. sbt doesn't like having two projects using the same target folder
26132629 target := target.value / " scala3-compiler-bootstrapped" ,
26142630 // Generate compiler.properties, used by sbt
2615- Compile / resourceGenerators += Def .task {
2616- import java .util ._
2617- import java .text ._
2618- val file = (Compile / resourceManaged).value / " compiler.properties"
2619- val dateFormat = new SimpleDateFormat (" yyyyMMdd-HHmmss" )
2620- dateFormat.setTimeZone(TimeZone .getTimeZone(" GMT" ))
2621- val contents = // 2.11.11.v20170413-090219-8a413ba7cc
2622- s """ version.number= ${version.value}
2623- |maven.version.number= ${version.value}
2624- |git.hash= ${VersionUtil .gitHash}
2625- |copyright.string=Copyright 2002- $currentYear, LAMP/EPFL
2626- """ .stripMargin
2627-
2628- if (! (file.exists && IO .read(file) == contents)) {
2629- IO .write(file, contents)
2630- }
2631-
2632- Seq (file)
2633- }.taskValue,
2631+ Compile / resourceGenerators += generateCompilerProperties.taskValue,
26342632 // Configure to use the non-bootstrapped compiler
26352633 managedScalaInstance := false ,
26362634 scalaInstance := {
0 commit comments