Skip to content

Commit 45c2e63

Browse files
committed
[build] Improve, document and group versioning code in Build.scala (scala#21837)
* Introduce `developedVersion` describing the target for the current release cycle * Adapt `baseVersion` to the effectively revert scala#21011 changes * Adapt .msi packager to use `developedVersion` as a workaround to MSI ProductInfo limitations (version without RC suffix required) * Group and document versioning related code
1 parent daca114 commit 45c2e63

File tree

1 file changed

+35
-21
lines changed

1 file changed

+35
-21
lines changed

project/Build.scala

Lines changed: 35 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,39 @@ object Build {
8383

8484
val referenceVersion = "3.3.5"
8585

86-
val baseVersion = "3.3.6-RC1"
86+
/** Version of the Scala compiler targeted in the current release cycle
87+
* Contains a version without RC/SNAPSHOT/NIGHTLY specific suffixes
88+
* Should be updated ONLY after release or cutoff for previous release cycle.
89+
*
90+
* Should only be referred from `dottyVersion` or settings/tasks requiring simplified version string,
91+
* eg. `compatMode` or Windows native distribution version.
92+
*/
93+
val developedVersion = "3.3.6"
94+
95+
/** The version of the compiler including the RC prefix.
96+
* Defined as common base before calculating environment specific suffixes in `dottyVersion`
97+
*
98+
* By default, during development cycle defined as `${developedVersion}-RC1`;
99+
* During release candidate cycle incremented by the release officer before publishing a subsequent RC version;
100+
* During final, stable release is set exactly to `developedVersion`.
101+
*/
102+
val baseVersion = s"$developedVersion-RC1"
103+
104+
/** Final version of Scala compiler, controlled by environment variables. */
105+
val dottyVersion = {
106+
if (isRelease) baseVersion
107+
else if (isNightly) s"${baseVersion}-bin-${VersionUtil.commitDate}-${VersionUtil.gitHash}-NIGHTLY"
108+
else s"${baseVersion}-bin-SNAPSHOT"
109+
}
110+
def isRelease = sys.env.get("RELEASEBUILD").contains("yes")
111+
def isNightly = sys.env.get("NIGHTLYBUILD").contains("yes")
112+
113+
/** Version calculate for `nonbootstrapped` projects */
114+
val dottyNonBootstrappedVersion = {
115+
// Make sure sbt always computes the scalaBinaryVersion correctly
116+
val bin = if (!dottyVersion.contains("-bin")) "-bin" else ""
117+
dottyVersion + bin + "-nonbootstrapped"
118+
}
87119

88120
// LTS or Next
89121
val versionLine = "LTS"
@@ -110,8 +142,8 @@ object Build {
110142
}
111143

112144
val compatMode = {
113-
val VersionRE = """^\d+\.(\d+).(\d+).*""".r
114-
baseVersion match {
145+
val VersionRE = """^\d+\.(\d+)\.(\d+)""".r
146+
developedVersion match {
115147
case VersionRE(_, "0") => CompatMode.BinaryCompatible
116148
case _ => CompatMode.SourceAndBinaryCompatible
117149
}
@@ -132,24 +164,6 @@ object Build {
132164
val dottyGithubUrl = "https://github.com/scala/scala3"
133165
val dottyGithubRawUserContentUrl = "https://raw.githubusercontent.com/scala/scala3"
134166

135-
136-
val isRelease = sys.env.get("RELEASEBUILD") == Some("yes")
137-
138-
val dottyVersion = {
139-
def isNightly = sys.env.get("NIGHTLYBUILD") == Some("yes")
140-
if (isRelease)
141-
baseVersion
142-
else if (isNightly)
143-
baseVersion + "-bin-" + VersionUtil.commitDate + "-" + VersionUtil.gitHash + "-NIGHTLY"
144-
else
145-
baseVersion + "-bin-SNAPSHOT"
146-
}
147-
val dottyNonBootstrappedVersion = {
148-
// Make sure sbt always computes the scalaBinaryVersion correctly
149-
val bin = if (!dottyVersion.contains("-bin")) "-bin" else ""
150-
dottyVersion + bin + "-nonbootstrapped"
151-
}
152-
153167
val sbtCommunityBuildVersion = "0.1.0-SNAPSHOT"
154168

155169
val agentOptions = List(

0 commit comments

Comments
 (0)