Skip to content

Commit 7454d90

Browse files
committed
Document and group together versioning related code
1 parent ecc332f commit 7454d90

File tree

1 file changed

+35
-24
lines changed

1 file changed

+35
-24
lines changed

Diff for: project/Build.scala

+35-24
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,39 @@ object Build {
9999
*/
100100
val referenceVersion = "3.6.0"
101101

102-
val baseVersion = "3.6.2"
103-
// Will be required by some automation later
104-
// TODO: Introduce automation and handling for RC versions before 3.6.2-RC1
105-
// val prereleaseVersion = s"$baseVersion-RC1"
102+
/** Version of the Scala compiler targeted in the current release cycle
103+
* Contains a version without RC/SNAPSHOT/NIGHTLY specific suffixes
104+
* Should be updated ONLY after release or cutoff for previous release cycle.
105+
*
106+
* Should only be referred from `dottyVersion` or settings/tasks requiring simplified version string,
107+
* eg. `compatMode` or Windows native distribution version.
108+
*/
109+
val developedVersion = "3.6.2"
110+
111+
/** The version of the compiler including the RC prefix.
112+
* Defined as common base before calculating environment specific suffixes in `dottyVersion`
113+
*
114+
* By default, during development cycle defined as `${developedVersion}-RC1`;
115+
* During release candidate cycle incremented by the release officer before publishing a subsequent RC version;
116+
* During final, stable release is set exactly to `developedVersion`.
117+
*/
118+
val baseVersion = s"$developedVersion-RC1"
119+
120+
/** Final version of Scala compiler, controlled by environment variables. */
121+
val dottyVersion = {
122+
if (isRelease) baseVersion
123+
else if (isNightly) s"${baseVersion}-bin-${VersionUtil.commitDate}-${VersionUtil.gitHash}-NIGHTLY"
124+
else s"${baseVersion}-bin-SNAPSHOT"
125+
}
126+
def isRelease = sys.env.get("RELEASEBUILD").contains("yes")
127+
def isNightly = sys.env.get("NIGHTLYBUILD").contains("yes")
128+
129+
/** Version calculate for `nonbootstrapped` projects */
130+
val dottyNonBootstrappedVersion = {
131+
// Make sure sbt always computes the scalaBinaryVersion correctly
132+
val bin = if (!dottyVersion.contains("-bin")) "-bin" else ""
133+
dottyVersion + bin + "-nonbootstrapped"
134+
}
106135

107136
// LTS or Next
108137
val versionLine = "Next"
@@ -117,7 +146,7 @@ object Build {
117146
/** Minor version against which we check binary compatibility.
118147
*
119148
* This must be the earliest published release in the same versioning line.
120-
* For a baseVersion `3.M.P` the mimaPreviousDottyVersion should be set to:
149+
* For a developedVersion `3.M.P` the mimaPreviousDottyVersion should be set to:
121150
* - `3.M.0` if `P > 0`
122151
* - `3.(M-1).0` if `P = 0`
123152
* 3.6.1 is an exception from this rule - 3.6.0 was a broken release
@@ -144,7 +173,7 @@ object Build {
144173

145174
val compatMode = {
146175
val VersionRE = """^\d+\.(\d+)\.(\d+)""".r
147-
baseVersion match {
176+
developedVersion match {
148177
case VersionRE(_, "0") => CompatMode.BinaryCompatible
149178
case _ => CompatMode.SourceAndBinaryCompatible
150179
}
@@ -174,24 +203,6 @@ object Build {
174203
val dottyGithubUrl = "https://github.com/scala/scala3"
175204
val dottyGithubRawUserContentUrl = "https://raw.githubusercontent.com/scala/scala3"
176205

177-
178-
val isRelease = sys.env.get("RELEASEBUILD") == Some("yes")
179-
180-
val dottyVersion = {
181-
def isNightly = sys.env.get("NIGHTLYBUILD") == Some("yes")
182-
if (isRelease)
183-
baseVersion
184-
else if (isNightly)
185-
baseVersion + "-RC1-bin-" + VersionUtil.commitDate + "-" + VersionUtil.gitHash + "-NIGHTLY"
186-
else
187-
baseVersion + "-RC1-bin-SNAPSHOT"
188-
}
189-
val dottyNonBootstrappedVersion = {
190-
// Make sure sbt always computes the scalaBinaryVersion correctly
191-
val bin = if (!dottyVersion.contains("-bin")) "-bin" else ""
192-
dottyVersion + bin + "-nonbootstrapped"
193-
}
194-
195206
val sbtCommunityBuildVersion = "0.1.0-SNAPSHOT"
196207

197208
val agentOptions = List(

0 commit comments

Comments
 (0)