Skip to content

Commit 46be6ba

Browse files
authored
Merge pull request #4517 from sjrd/version-scheme
Fix #4513: Set up versionScheme for all the "library" artifacts.
2 parents 91e2a68 + 8c60492 commit 46be6ba

File tree

1 file changed

+41
-12
lines changed

1 file changed

+41
-12
lines changed

project/Build.scala

Lines changed: 41 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -493,7 +493,7 @@ object Build {
493493
}
494494
)
495495

496-
val publishSettings = Seq(
496+
private val basePublishSettings = Seq(
497497
publishMavenStyle := true,
498498
publishTo := {
499499
val nexus = "https://oss.sonatype.org/"
@@ -524,6 +524,35 @@ object Build {
524524
pomIncludeRepository := { _ => false }
525525
)
526526

527+
/** Constants for the `verScheme` parameter of `publishSettings`.
528+
*
529+
* sbt does not define constants in its API for `versionScheme`. It
530+
* specifies some strings instead. We use the following version schemes,
531+
* depending on the artifacts and the versioning policy in `VERSIONING.md`:
532+
*
533+
* - `"strict"` for artifacts whose public API can break in patch releases (e.g., `test-bridge`)
534+
* - `"pvp"` for artifacts whose public API can break in minor releases
535+
* - `"semver-spec"` for artifacts whose public API can only break in major releases (e.g., `library`)
536+
*
537+
* At the moment, we only set the version scheme for artifacts in the
538+
* "library ecosystem", i.e., scalajs-library, scalajs-test-interface,
539+
* scalajs-junit-runtime and scalajs-test-bridge. Artifacts of the "tools
540+
* ecosystem" do not have a version scheme set, as the jury is still out on
541+
* what is the best way to specify them.
542+
*
543+
* See also https://www.scala-sbt.org/1.x/docs/Publishing.html#Version+scheme
544+
*/
545+
object VersionScheme {
546+
final val BreakOnPatch = "strict"
547+
final val BreakOnMinor = "pvp"
548+
final val BreakOnMajor = "semver-spec"
549+
}
550+
551+
def publishSettings(verScheme: Option[String]): Seq[Setting[_]] = Def.settings(
552+
basePublishSettings,
553+
versionScheme := verScheme,
554+
)
555+
527556
val fatalWarningsSettings = Def.settings(
528557
scalacOptions += "-Xfatal-warnings",
529558

@@ -712,7 +741,7 @@ object Build {
712741

713742
val commonIrProjectSettings = Def.settings(
714743
commonSettings,
715-
publishSettings,
744+
publishSettings(None),
716745
fatalWarningsSettings,
717746
name := "Scala.js IR",
718747
previousArtifactSetting,
@@ -748,7 +777,7 @@ object Build {
748777
id = "compiler", base = file("compiler")
749778
).settings(
750779
commonSettings,
751-
publishSettings,
780+
publishSettings(None),
752781
fatalWarningsSettings,
753782
name := "Scala.js compiler",
754783
crossVersion := CrossVersion.full, // because compiler api is not binary compatible
@@ -801,7 +830,7 @@ object Build {
801830

802831
val commonLinkerInterfaceSettings = Def.settings(
803832
commonSettings,
804-
publishSettings,
833+
publishSettings(None),
805834
fatalWarningsSettings,
806835
name := "Scala.js linker interface",
807836

@@ -889,7 +918,7 @@ object Build {
889918

890919
def commonLinkerSettings(library: LocalProject) = Def.settings(
891920
commonSettings,
892-
publishSettings,
921+
publishSettings(None),
893922
fatalWarningsSettings,
894923
name := "Scala.js linker",
895924
ensureSAMSupportSetting,
@@ -1052,7 +1081,7 @@ object Build {
10521081
id = "testAdapter", base = file("test-adapter")
10531082
).settings(
10541083
commonSettings,
1055-
publishSettings,
1084+
publishSettings(None),
10561085
fatalWarningsSettings,
10571086
name := "Scala.js sbt test adapter",
10581087
libraryDependencies ++= Seq(
@@ -1072,7 +1101,7 @@ object Build {
10721101
lazy val plugin: Project = Project(id = "sbtPlugin", base = file("sbt-plugin"))
10731102
.enablePlugins(ScriptedPlugin).settings(
10741103
commonSettings,
1075-
publishSettings,
1104+
publishSettings(None),
10761105
fatalWarningsSettings,
10771106
name := "Scala.js sbt plugin",
10781107
normalizedName := "sbt-scalajs",
@@ -1429,7 +1458,7 @@ object Build {
14291458
MyScalaJSPlugin
14301459
).settings(
14311460
commonSettings,
1432-
publishSettings,
1461+
publishSettings(Some(VersionScheme.BreakOnMajor)),
14331462
crossVersion := CrossVersion.binary, // no _sjs suffix
14341463
fatalWarningsSettings,
14351464
name := "Scala.js library",
@@ -1549,7 +1578,7 @@ object Build {
15491578
MyScalaJSPlugin
15501579
).settings(
15511580
commonSettings,
1552-
publishSettings,
1581+
publishSettings(Some(VersionScheme.BreakOnMajor)),
15531582
crossVersion := CrossVersion.binary, // no _sjs suffix
15541583
fatalWarningsSettings,
15551584
name := "Scala.js test interface",
@@ -1564,7 +1593,7 @@ object Build {
15641593
MyScalaJSPlugin
15651594
).settings(
15661595
commonSettings,
1567-
publishSettings,
1596+
publishSettings(Some(VersionScheme.BreakOnPatch)),
15681597
crossVersion := CrossVersion.binary, // no _sjs suffix
15691598
fatalWarningsSettings,
15701599
name := "Scala.js test bridge",
@@ -1588,7 +1617,7 @@ object Build {
15881617
MyScalaJSPlugin
15891618
).settings(
15901619
commonSettings,
1591-
publishSettings,
1620+
publishSettings(Some(VersionScheme.BreakOnMajor)),
15921621
crossVersion := CrossVersion.binary, // no _sjs suffix
15931622
fatalWarningsSettings,
15941623
name := "Scala.js JUnit test runtime",
@@ -1642,7 +1671,7 @@ object Build {
16421671
id = "jUnitPlugin", base = file("junit-plugin")
16431672
).settings(
16441673
commonSettings,
1645-
publishSettings,
1674+
publishSettings(None),
16461675
fatalWarningsSettings,
16471676
name := "Scala.js JUnit test plugin",
16481677
crossVersion := CrossVersion.full,

0 commit comments

Comments
 (0)