@@ -433,6 +433,48 @@ 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 = (contents : String , file : File ) => Def .task {
445+ if (! (file.exists && IO .read(file) == contents)) {
446+ IO .write(file, contents)
447+ }
448+ Seq (file)
449+ }
450+
451+ // Generate compiler.properties consumed by sbt
452+ lazy val generateCompilerProperties : Def .Initialize [Task [Seq [File ]]] = {
453+ import java .util ._
454+ import java .text ._
455+ val file = (Compile / resourceManaged).value / " compiler.properties"
456+ val dateFormat = new SimpleDateFormat (" yyyyMMdd-HHmmss" )
457+ dateFormat.setTimeZone(TimeZone .getTimeZone(" GMT" ))
458+ val contents = // 2.11.11.v20170413-090219-8a413ba7cc
459+ s """ version.number= ${version.value}
460+ |maven.version.number= ${version.value}
461+ |git.hash= ${VersionUtil .gitHash}
462+ |copyright.string=Copyright 2002- $currentYear, LAMP/EPFL
463+ """ .stripMargin
464+ generatePropertiesFile(contents, file)
465+ }
466+
467+ // Generate library3.properties consumed by scala.util.Properties
468+ lazy val generateLibrary3Properties : Def .Initialize [Task [Seq [File ]]] = {
469+ val file = (Compile / resourceManaged).value / " library3.properties"
470+ val contents = s """ version.number= ${version.value}
471+ |maven.version.number= ${version.value}
472+ |copyright.string=Copyright 2002- $currentYear, LAMP/EPFL
473+ |shell.banner= ${shellBanner}
474+ | """ .stripMargin
475+ generatePropertiesFile(contents, file)
476+ }
477+
436478 def scalacOptionsDocSettings (includeExternalMappings : Boolean = true ) = {
437479 val extMap = Seq (" -external-mappings:" +
438480 (if (includeExternalMappings) " .*scala/.*::scaladoc3::https://dotty.epfl.ch/api/," else " " ) +
@@ -700,25 +742,7 @@ object Build {
700742 scalacOptions += " -Wconf:cat=deprecation&origin=scala\\ .collection\\ .mutable\\ .AnyRefMap.*:s" ,
701743
702744 // 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,
745+ (Compile / resourceGenerators) += generateCompilerProperties.taskValue,
722746
723747 // get libraries onboard
724748 libraryDependencies ++= Seq (
@@ -1916,19 +1940,8 @@ object Build {
19161940 customMimaReportBinaryIssues(" MiMaFilters.Scala3Library" ),
19171941 // Should we also patch .sjsir files
19181942 keepSJSIR := false ,
1919- Compile / resourceGenerators += Def .task {
1920- val file = (Compile / resourceManaged).value / " library3.properties"
1921- val contents =
1922- s """ version.number= ${version.value}
1923- |maven.version.number= ${version.value}
1924- | """ .stripMargin
1925-
1926- if (! (file.exists && IO .read(file) == contents)) {
1927- IO .write(file, contents)
1928- }
1929-
1930- Seq (file)
1931- }.taskValue,
1943+ // Generate Scala 3 runtime properties overlay
1944+ Compile / resourceGenerators += generateLibrary3Properties.taskValue
19321945 )
19331946
19341947 /* Configuration of the org.scala-lang:scala3-library_3:*.**.**-nonbootstrapped project */
@@ -2054,19 +2067,8 @@ object Build {
20542067 customMimaReportBinaryIssues(" MiMaFilters.Scala3Library" ),
20552068 // Should we also patch .sjsir files
20562069 keepSJSIR := false ,
2057- Compile / resourceGenerators += Def .task {
2058- val file = (Compile / resourceManaged).value / " library3.properties"
2059- val contents =
2060- s """ version.number= ${version.value}
2061- |maven.version.number= ${version.value}
2062- | """ .stripMargin
2063-
2064- if (! (file.exists && IO .read(file) == contents)) {
2065- IO .write(file, contents)
2066- }
2067-
2068- Seq (file)
2069- }.taskValue,
2070+ // Generate Scala 3 runtime properties overlay
2071+ Compile / resourceGenerators += generateLibrary3Properties.taskValue,
20702072 )
20712073
20722074 /* Configuration of the org.scala-lang:scala3-library_3:*.**.**-bootstrapped project */
@@ -2470,25 +2472,7 @@ object Build {
24702472 // Project specific target folder. sbt doesn't like having two projects using the same target folder
24712473 target := target.value / " scala3-compiler-nonbootstrapped" ,
24722474 // Generate compiler.properties, used by sbt
2473- Compile / resourceGenerators += Def .task {
2474- import java .util ._
2475- import java .text ._
2476- val file = (Compile / resourceManaged).value / " compiler.properties"
2477- val dateFormat = new SimpleDateFormat (" yyyyMMdd-HHmmss" )
2478- dateFormat.setTimeZone(TimeZone .getTimeZone(" GMT" ))
2479- val contents = // 2.11.11.v20170413-090219-8a413ba7cc
2480- s """ version.number= ${version.value}
2481- |maven.version.number= ${version.value}
2482- |git.hash= ${VersionUtil .gitHash}
2483- |copyright.string=Copyright 2002- $currentYear, LAMP/EPFL
2484- """ .stripMargin
2485-
2486- if (! (file.exists && IO .read(file) == contents)) {
2487- IO .write(file, contents)
2488- }
2489-
2490- Seq (file)
2491- }.taskValue,
2475+ Compile / resourceGenerators += generateCompilerProperties.taskValue,
24922476 // sbt adds all the projects to scala-tool config which breaks building the scalaInstance
24932477 // as a workaround, I build it manually by only adding the compiler
24942478 managedScalaInstance := false ,
@@ -2638,25 +2622,7 @@ object Build {
26382622 // Project specific target folder. sbt doesn't like having two projects using the same target folder
26392623 target := target.value / " scala3-compiler-bootstrapped" ,
26402624 // Generate compiler.properties, used by sbt
2641- Compile / resourceGenerators += Def .task {
2642- import java .util ._
2643- import java .text ._
2644- val file = (Compile / resourceManaged).value / " compiler.properties"
2645- val dateFormat = new SimpleDateFormat (" yyyyMMdd-HHmmss" )
2646- dateFormat.setTimeZone(TimeZone .getTimeZone(" GMT" ))
2647- val contents = // 2.11.11.v20170413-090219-8a413ba7cc
2648- s """ version.number= ${version.value}
2649- |maven.version.number= ${version.value}
2650- |git.hash= ${VersionUtil .gitHash}
2651- |copyright.string=Copyright 2002- $currentYear, LAMP/EPFL
2652- """ .stripMargin
2653-
2654- if (! (file.exists && IO .read(file) == contents)) {
2655- IO .write(file, contents)
2656- }
2657-
2658- Seq (file)
2659- }.taskValue,
2625+ Compile / resourceGenerators += generateCompilerProperties.taskValue,
26602626 // Configure to use the non-bootstrapped compiler
26612627 managedScalaInstance := false ,
26622628 scalaInstance := {
0 commit comments