@@ -433,6 +433,47 @@ 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 ]]] = generatePropertiesFile(
469+ contents = s """ version.number= ${version.value}
470+ |maven.version.number= ${version.value}
471+ |copyright.string=Copyright 2002- $currentYear, LAMP/EPFL and Lightbend, Inc. dba Akka
472+ |shell.banner= ${shellBanner}
473+ | """ .stripMargin,
474+ file = (Compile / resourceManaged).value / " library3.properties"
475+ )
476+
436477 def scalacOptionsDocSettings (includeExternalMappings : Boolean = true ) = {
437478 val extMap = Seq (" -external-mappings:" +
438479 (if (includeExternalMappings) " .*scala/.*::scaladoc3::https://dotty.epfl.ch/api/," else " " ) +
@@ -700,25 +741,7 @@ object Build {
700741 scalacOptions += " -Wconf:cat=deprecation&origin=scala\\ .collection\\ .mutable\\ .AnyRefMap.*:s" ,
701742
702743 // 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,
744+ (Compile / resourceGenerators) += generateCompilerProperties.taskValue,
722745
723746 // get libraries onboard
724747 libraryDependencies ++= Seq (
@@ -1916,19 +1939,8 @@ object Build {
19161939 customMimaReportBinaryIssues(" MiMaFilters.Scala3Library" ),
19171940 // Should we also patch .sjsir files
19181941 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,
1942+ // Generate Scala 3 runtime properties overlay
1943+ Compile / resourceGenerators += generateLibrary3Properties.taskValue
19321944 )
19331945
19341946 /* Configuration of the org.scala-lang:scala3-library_3:*.**.**-nonbootstrapped project */
@@ -2054,19 +2066,8 @@ object Build {
20542066 customMimaReportBinaryIssues(" MiMaFilters.Scala3Library" ),
20552067 // Should we also patch .sjsir files
20562068 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,
2069+ // Generate Scala 3 runtime properties overlay
2070+ Compile / resourceGenerators += generateLibrary3Properties.taskValue,
20702071 )
20712072
20722073 /* Configuration of the org.scala-lang:scala3-library_3:*.**.**-bootstrapped project */
@@ -2470,25 +2471,7 @@ object Build {
24702471 // Project specific target folder. sbt doesn't like having two projects using the same target folder
24712472 target := target.value / " scala3-compiler-nonbootstrapped" ,
24722473 // 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,
2474+ Compile / resourceGenerators += generateCompilerProperties.taskValue,
24922475 // sbt adds all the projects to scala-tool config which breaks building the scalaInstance
24932476 // as a workaround, I build it manually by only adding the compiler
24942477 managedScalaInstance := false ,
@@ -2638,25 +2621,7 @@ object Build {
26382621 // Project specific target folder. sbt doesn't like having two projects using the same target folder
26392622 target := target.value / " scala3-compiler-bootstrapped" ,
26402623 // 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,
2624+ Compile / resourceGenerators += generateCompilerProperties.taskValue,
26602625 // Configure to use the non-bootstrapped compiler
26612626 managedScalaInstance := false ,
26622627 scalaInstance := {
0 commit comments