-
Notifications
You must be signed in to change notification settings - Fork 17
Cross-build twinagle-scalapb-plugin for sbt 1.x and sbt 2.x #529
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
rbscgh
wants to merge
3
commits into
master
Choose a base branch
from
sbt_2
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,32 +2,30 @@ import sbt.CrossVersion | |
|
|
||
| lazy val scala212 = "2.12.20" | ||
| lazy val scala213 = "2.13.17" | ||
| lazy val scala3LTS = "3.3.7" | ||
| lazy val scala3LTS = "3.3.7" // runtime stays on LTS — it is the end-user library | ||
| lazy val scala3 = "3.8.4" // codegen + plugin Scala-3 axis (matches sbt 2.0.0 DSL) | ||
| lazy val sbt2 = "2.0.0" | ||
| lazy val sbt1 = "1.9.9" // pluginCrossBuild sbt version for the 2.12 axis (oldest sbt 1.x we support) | ||
|
|
||
| lazy val commonSettings = List( | ||
| scalaVersion := scala212, | ||
| scalacOptions ++= { | ||
| val common = Seq("-encoding", "utf8", "-deprecation", "-unchecked") | ||
| CrossVersion.partialVersion(scalaVersion.value) match { | ||
| case Some((2, _)) => scalacOptions ++= Seq("-Xlint") | ||
| case _ => () | ||
| // Scala 3 renamed -Xfatal-warnings to -Werror (the old alias is itself deprecated). | ||
| case Some((2, _)) => common ++ Seq("-Xlint", "-Xfatal-warnings") | ||
| case _ => common ++ Seq("-Werror") | ||
| } | ||
| Seq( | ||
| "-encoding", | ||
| "utf8", | ||
| "-deprecation", | ||
| "-unchecked", | ||
| "-Xfatal-warnings" | ||
| ) | ||
| }, | ||
| Compile / console / scalacOptions --= Seq("-deprecation", "-Xfatal-warnings", "-Xlint"), | ||
| Compile / console / scalacOptions --= Seq("-deprecation", "-Xfatal-warnings", "-Werror", "-Xlint"), | ||
| scalafmtOnCompile := true | ||
| ) | ||
|
|
||
| lazy val codegen = (project in file("codegen")) | ||
| .settings( | ||
| commonSettings, | ||
| name := "twinagle-codegen", | ||
| crossScalaVersions := Seq(scala212, scala213, scala3LTS), | ||
| crossScalaVersions := Seq(scala212, scala213, scala3), | ||
| libraryDependencies += "com.thesamet.scalapb" %% "compilerplugin" % scalapb.compiler.Version.scalapbVersion, | ||
| publishLocal := publishLocal.dependsOn(runtime / publishLocal).value | ||
| ) | ||
|
|
@@ -37,8 +35,23 @@ lazy val plugin = (project in file("plugin")) | |
| .dependsOn(codegen) | ||
| .settings( | ||
| commonSettings, | ||
| name := "twinagle-scalapb-plugin", | ||
| addSbtPlugin("com.thesamet" % "sbt-protoc" % "1.0.7"), | ||
| name := "twinagle-scalapb-plugin", | ||
| crossScalaVersions := Seq(scala212, scala3), | ||
| scalaVersion := scala212, | ||
| pluginCrossBuild / sbtVersion := { | ||
| scalaBinaryVersion.value match { | ||
| case "2.12" => sbt1 | ||
| case _ => sbt2 | ||
| } | ||
| }, | ||
| scriptedSbt := { | ||
| scalaBinaryVersion.value match { | ||
| case "2.12" => sbtVersion.value | ||
| case _ => sbt2 | ||
| } | ||
| }, | ||
| addSbtPlugin("com.thesamet" % "sbt-protoc" % "1.1.0-RC1"), | ||
| addSbtPlugin("com.github.sbt" % "sbt2-compat" % "0.1.0"), | ||
| buildInfoKeys := Seq[BuildInfoKey](version, scalaBinaryVersion), | ||
| buildInfoPackage := "com.soundcloud.twinagle.plugin", | ||
| buildInfoUsePackageAsPath := true, | ||
|
|
@@ -57,8 +70,21 @@ lazy val runtime = (project in file("runtime")).settings( | |
| libraryDependencies ++= { | ||
| Seq( | ||
| "com.twitter" %% "finagle-http" % "24.2.0" cross CrossVersion.for3Use2_13, | ||
| "com.thesamet.scalapb" %% "scalapb-runtime" % "0.11.20", | ||
| "com.thesamet.scalapb" %% "scalapb-json4s" % "0.12.1", | ||
| "com.thesamet.scalapb" %% "scalapb-runtime" % "1.0.0-alpha.5", | ||
| // scalapb-json4s has only published 1.0.0-alpha.1, which pulls scalapb-runtime alpha.1. | ||
| // Exclude its transitive scalapb-runtime so only our alpha.5 above remains: sbt's | ||
| // early-semver check otherwise flags the alpha.1 -> alpha.5 eviction as a hard conflict, | ||
| // and a per-dependency exclude (unlike dependencyOverrides) serializes into the published | ||
| // POM/ivy so downstream consumers inherit the coherent single version. | ||
| // | ||
| // The Scala-binary suffixes (_2.12/_2.13/_3) are spelled out explicitly rather than via | ||
| // CrossVersion.binary: exclusions match on the literal published artifactId, and a | ||
| // CrossVersion.binary rule serializes to the suffix-less "scalapb-runtime", which does | ||
| // NOT match "scalapb-runtime_2.13" in a downstream consumer's POM resolution. | ||
| ("com.thesamet.scalapb" %% "scalapb-json4s" % "1.0.0-alpha.1") | ||
| .exclude("com.thesamet.scalapb", "scalapb-runtime_2.12") | ||
| .exclude("com.thesamet.scalapb", "scalapb-runtime_2.13") | ||
| .exclude("com.thesamet.scalapb", "scalapb-runtime_3"), | ||
|
Comment on lines
+73
to
+87
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is probably unacceptable but hopefully will be fixed once 1.0 scalapb is released
rbscgh marked this conversation as resolved.
|
||
| "org.json4s" %% "json4s-native" % "4.0.7", | ||
| "org.specs2" %% "specs2-core" % "4.20.9" % Test cross CrossVersion.for3Use2_13 | ||
| ) | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,22 +1,34 @@ | ||
| # Twinagle ScalaPB Plugin | ||
|
|
||
| To test the generator, within SBT: | ||
| This plugin is cross-built for **sbt 1.x and sbt 2.x**. The end-to-end test under | ||
| `plugin/src/sbt-test/generator/e2e` runs against both: on the Scala 2.12 axis it | ||
| launches sbt 1.x, and on the Scala 3 axis it launches sbt 2.0.0. | ||
|
|
||
| ## Running the generator tests | ||
|
|
||
| To test the generator across both sbt axes, within sbt (requires JDK 17): | ||
|
|
||
| ``` | ||
| > scripted | ||
| > +publishLocal | ||
| > +plugin/scripted | ||
| ``` | ||
|
|
||
| This would publish your generator locally and run it over a test project | ||
| located under `codegen/src/sbt-test/generator/e2e`. | ||
| `+publishLocal` cross-publishes `twinagle-runtime`, `twinagle-codegen`, and both | ||
| plugin artifacts (`_2.12_1.0` and `_sbt2_3`) to your local ivy repo. `+plugin/scripted` | ||
| then publishes nothing further and runs the test project once per sbt axis. | ||
|
|
||
| > Note: a bare `scripted` only runs the sbt 1.x axis. Use `+plugin/scripted` to | ||
| > cover sbt 2.x as well. | ||
|
|
||
| ## Iterating on the test project without republishing | ||
|
|
||
| Assuming that the plugin If you would like to test the test project without republishing the plugin | ||
| each time (assuming it does not change), then publish it locally using | ||
| `publishLocal`, then in `codegen/src/sbt-test` run SBT and pass it the version number, | ||
| for example: | ||
| If the plugin itself hasn't changed, publish it once and run the test project | ||
| directly, passing the version number: | ||
|
|
||
| ``` | ||
| cd codegen/src/sbt-test/generator/e2e` | ||
| sbt -Dplugin.version=0.1.1-SNAPSHOT | ||
| sbt +publishLocal # note the version it prints, e.g. 1.4.6-SNAPSHOT | ||
|
|
||
| cd plugin/src/sbt-test/generator/e2e | ||
| sbt -Dplugin.version=1.4.6-SNAPSHOT | ||
| > test | ||
| ``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,7 @@ | ||
| enablePlugins(Twinagle) | ||
|
|
||
| scalaVersion := "2.13.17" | ||
|
|
||
| scalacOptions ++= Seq( | ||
| "-encoding", | ||
| "utf8", | ||
|
|
||
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.