Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions library/src/scala/util/Properties.scala
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ private[scala] trait PropertiesTrait {

/** The name of the properties file */
protected val propFilename = "/" + propCategory + ".properties"
protected val lib3Filename = "/library3.properties"

/** The loaded properties */
protected lazy val scalaProps: java.util.Properties = {
Expand All @@ -42,6 +43,12 @@ private[scala] trait PropertiesTrait {
if (stream ne null)
quietlyDispose(props.load(stream), stream.close)

// If available in the same jar as the stdlib classes, overlay Scala 3
// runtime properties contained in `library3.properties` (e.g., version.number).
val lib3Stream = pickJarBasedOn.getResourceAsStream(lib3Filename)
if (lib3Stream ne null)
quietlyDispose(props.load(lib3Stream), lib3Stream.close)

props
}

Expand Down
26 changes: 26 additions & 0 deletions project/Build.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1916,6 +1916,19 @@ object Build {
customMimaReportBinaryIssues("MiMaFilters.Scala3Library"),
// Should we also patch .sjsir files
keepSJSIR := false,
Compile / resourceGenerators += Def.task {
val file = (Compile / resourceManaged).value / "library3.properties"
val contents =
s"""version.number=${version.value}
|maven.version.number=${version.value}
|""".stripMargin

if (!(file.exists && IO.read(file) == contents)) {
IO.write(file, contents)
}

Seq(file)
}.taskValue,
)

/* Configuration of the org.scala-lang:scala3-library_3:*.**.**-nonbootstrapped project */
Expand Down Expand Up @@ -2041,6 +2054,19 @@ object Build {
customMimaReportBinaryIssues("MiMaFilters.Scala3Library"),
// Should we also patch .sjsir files
keepSJSIR := false,
Compile / resourceGenerators += Def.task {
val file = (Compile / resourceManaged).value / "library3.properties"
val contents =
s"""version.number=${version.value}
|maven.version.number=${version.value}
|""".stripMargin

if (!(file.exists && IO.read(file) == contents)) {
IO.write(file, contents)
}

Seq(file)
}.taskValue,
)

/* Configuration of the org.scala-lang:scala3-library_3:*.**.**-bootstrapped project */
Expand Down
1 change: 1 addition & 0 deletions tests/run/properties-version-string.check
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
OK
7 changes: 7 additions & 0 deletions tests/run/properties-version-string.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
object Test {
def main(args: Array[String]): Unit = {
val v = scala.util.Properties.versionNumberString
if (v.nonEmpty && !v.startsWith("2.")) println("OK")
else println("FAIL " + v)
}
}
Loading