Skip to content

Commit 99dd9e1

Browse files
authored
cross build scala 3.5.2 and 3.6.4 (#203)
1 parent d918f8e commit 99dd9e1

File tree

18 files changed

+718
-71
lines changed

18 files changed

+718
-71
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
target/
1+
target
22

33
/.bsp
44
/gnupg-*

README.md

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,10 @@ markdown-toc --maxdepth 3 README.md|tail -n +4
6262
- [Contribution guidelines](#contribution-guidelines)
6363
* [How can I build/stage a local version?](#how-can-i-buildstage-a-local-version)
6464
* [How can I get a new binary (bootstrapped) release?](#how-can-i-get-a-new-binary-bootstrapped-release)
65-
* [Updating the Scala version](#updating-the-scala-version)
65+
* [Adding support for a new Scala version](#adding-support-for-a-new-scala-version)
6666
* [Updating the shaded libraries](#updating-the-shaded-libraries)
6767
- [Fineprint](#fineprint)
6868

69-
7069
## Benefits over / comparison with
7170

7271
### Regular Scala REPL
@@ -617,9 +616,8 @@ sbt stage
617616
### How can I get a new binary (bootstrapped) release?
618617
While maven central jar releases are created for each commit on master (a new version tag is assigned automatically), the binary (bootstrapped) releases that end up in https://github.com/mpollmeier/scala-repl-pp/releases/latest are being triggered manually. Contributors can run the [bootstrap action](https://github.com/mpollmeier/scala-repl-pp/actions/workflows/bootstrap.yml).
619618

620-
### Updating the Scala version
621-
* bump version in [build.sbt](build.sbt)
622-
* get relevant diff from dotty repo
619+
### Adding support for a new Scala version
620+
First, get relevant diff from dotty repo:
623621
```bash
624622
cd /path/to/dotty
625623
git fetch
@@ -628,12 +626,12 @@ OLD=3.5.2-RC2 # set to version that was used before you bumped it
628626
NEW=3.6.4 # set to version that you bumped it to
629627
git diff $OLD..$NEW compiler/src/dotty/tools/repl
630628
```
631-
* check if any of those changes need to be reapplied to this repo
629+
Check if any of those changes need to be reapplied to this repo - some files have been copied and slightly adjusted, the majority of functionality is reused.
630+
If there's any binary incompatible changes (which is typically the case between minor versions), you need to add new projects for `core` and `server` in [build.sbt](build.sbt), add new `core/src/main/scala-3.x.y` directories etc.
632631

633632
### Updating the shaded libraries
634633
See [import-instructions.md](shaded-libs/import-instructions.md).
635634

636-
637635
## Fineprint
638636
(*) To keep our codebase concise we do use libraries, most importantly the [com.lihaoyi](https://github.com/com-lihaoyi/) stack. We want to ensure that users can freely use their own dependencies without clashing with the srp classpath though, so we [copied them into our build](shaded-libs/src/main/scala/replpp/shaded) and [changed the namespace](shaded-libs/import-instructions) to `replpp.shaded`. Many thanks to the original authors, also for choosing permissive licenses.
639637

build.sbt

Lines changed: 61 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,83 +1,91 @@
11
name := "scala-repl-pp-root"
2+
ThisBuild/organization := "com.michaelpollmeier"
23
publish/skip := true
34

4-
ThisBuild / organization := "com.michaelpollmeier"
5-
ThisBuild / scalaVersion := "3.6.4"
6-
lazy val ScalaTestVersion = "3.2.18"
5+
lazy val scalaVersions = Seq("3.5.2", "3.6.4")
6+
ThisBuild/scalaVersion := scalaVersions.max
77
lazy val Slf4jVersion = "2.0.16"
88

9-
lazy val core = project.in(file("core"))
9+
lazy val core_364 = Build
10+
.newProject("core", "3.6.4", "scala-repl-pp")
1011
.dependsOn(shadedLibs)
1112
.enablePlugins(JavaAppPackaging)
12-
.settings(
13-
name := "scala-repl-pp",
14-
Compile/mainClass := Some("replpp.Main"),
15-
executableScriptName := "srp",
16-
libraryDependencies ++= Seq(
17-
"org.scala-lang" %% "scala3-compiler" % scalaVersion.value,
18-
"org.slf4j" % "slf4j-simple" % Slf4jVersion % Optional,
19-
),
20-
commonSettings,
21-
)
13+
.settings(coreSettings)
2214

23-
lazy val shadedLibs = project.in(file("shaded-libs"))
24-
.settings(
25-
name := "scala-repl-pp-shaded-libs",
26-
Compile/compile/scalacOptions ++= Seq(
27-
"-language:implicitConversions",
28-
"-Wconf:any:silent", // silence warnings from shaded libraries
29-
"-explain"
30-
),
31-
Compile/doc/scalacOptions += "-nowarn",
32-
commonSettings,
33-
)
15+
lazy val core_352 = Build
16+
.newProject("core", "3.5.2", "scala-repl-pp")
17+
.dependsOn(shadedLibs)
18+
.enablePlugins(JavaAppPackaging)
19+
.settings(coreSettings)
20+
21+
lazy val coreSettings = commonSettings ++ Seq(
22+
Compile/mainClass := Some("replpp.Main"),
23+
executableScriptName := "srp",
24+
libraryDependencies ++= Seq(
25+
"org.scala-lang" %% "scala3-compiler" % scalaVersion.value,
26+
"org.slf4j" % "slf4j-simple" % Slf4jVersion % Optional,
27+
),
28+
)
29+
30+
lazy val shadedLibs = project.in(file("shaded-libs")).settings(
31+
name := "scala-repl-pp-shaded-libs",
32+
scalaVersion := scalaVersions.min,
33+
Compile/compile/scalacOptions ++= Seq(
34+
"-language:implicitConversions",
35+
"-Wconf:any:silent", // silence warnings from shaded libraries
36+
"-explain"
37+
),
38+
Compile/doc/scalacOptions += "-nowarn",
39+
commonSettings,
40+
)
3441

35-
lazy val server = project.in(file("server"))
36-
.dependsOn(core)
42+
lazy val server_364 = Build
43+
.newProject("server", "3.6.4", "scala-repl-pp-server")
44+
.dependsOn(core_364)
3745
.enablePlugins(JavaAppPackaging)
38-
.settings(
39-
name := "scala-repl-pp-server",
40-
executableScriptName := "srp-server",
41-
Compile/mainClass := Some("replpp.server.Main"),
42-
fork := true, // important: otherwise we run into classloader issues
43-
libraryDependencies ++= Seq(
44-
"com.lihaoyi" %% "cask" % "0.9.5",
45-
"org.slf4j" % "slf4j-simple" % Slf4jVersion % Optional,
46-
"com.lihaoyi" %% "requests" % "0.8.2" % Test,
47-
),
48-
commonSettings,
49-
)
46+
.settings(serverSettings)
47+
48+
lazy val server_352 = Build
49+
.newProject("server", "3.5.2", "scala-repl-pp-server")
50+
.dependsOn(core_352)
51+
.enablePlugins(JavaAppPackaging)
52+
.settings(serverSettings)
53+
54+
lazy val serverSettings = commonSettings ++ Seq(
55+
Compile/mainClass := Some("replpp.server.Main"),
56+
libraryDependencies ++= Seq(
57+
"com.lihaoyi" %% "cask" % "0.9.5",
58+
"org.slf4j" % "slf4j-simple" % Slf4jVersion % Optional,
59+
"com.lihaoyi" %% "requests" % "0.8.2" % Test,
60+
),
61+
executableScriptName := "srp-server",
62+
fork := true, // important: otherwise we run into classloader issues
63+
)
5064

5165
lazy val integrationTests = project.in(file("integration-tests"))
52-
.dependsOn(server)
66+
.dependsOn(server_364)
5367
.settings(
5468
name := "integration-tests",
5569
fork := true, // important: otherwise we run into classloader issues
56-
libraryDependencies ++= Seq(
57-
"org.slf4j" % "slf4j-simple" % Slf4jVersion % Optional,
58-
"org.scalatest" %% "scalatest" % ScalaTestVersion % Test,
59-
),
70+
libraryDependencies += "org.slf4j" % "slf4j-simple" % Slf4jVersion % Optional,
6071
publish/skip := true
6172
)
6273

63-
val commonSettings = Seq(
64-
crossVersion := CrossVersion.full,
65-
maintainer.withRank(KeyRanks.Invisible) := "[email protected]",
66-
)
74+
lazy val commonSettings = Seq(maintainer.withRank(KeyRanks.Invisible) := "[email protected]")
6775

68-
ThisBuild / libraryDependencies ++= Seq(
69-
"org.scalatest" %% "scalatest" % ScalaTestVersion % Test,
76+
ThisBuild/libraryDependencies ++= Seq(
77+
"org.scalatest" %% "scalatest" % "3.2.19" % Test,
7078
"com.lihaoyi" %% "os-lib" % "0.9.1" % Test,
7179
)
7280

73-
ThisBuild / versionScheme := Some("strict")
81+
ThisBuild/versionScheme := Some("strict")
7482

75-
ThisBuild / javacOptions ++= Seq(
83+
ThisBuild/javacOptions ++= Seq(
7684
"-g", //debug symbols
7785
"--release", "11"
7886
)
7987

80-
ThisBuild / scalacOptions ++= Seq(
88+
ThisBuild/scalacOptions ++= Seq(
8189
"-release", "11",
8290
"-deprecation",
8391
"-feature",
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package replpp
2+
3+
import dotty.tools.dotc.reporting.{HideNonSensicalMessages, StoreReporter, UniqueMessagePositions}
4+
import dotty.tools.repl.*
5+
6+
/** random code that I needed to copy over from dotty to make things work, usually because it was `private[repl]`
7+
*/
8+
private[replpp] object DottyRandomStuff {
9+
10+
/** Create empty outer store reporter
11+
* copied from https://github.com/lampepfl/dotty/blob/3.3.0-RC5/compiler/src/dotty/tools/repl/package.scala#L6 */
12+
def newStoreReporter: StoreReporter = {
13+
new StoreReporter(null) with UniqueMessagePositions with HideNonSensicalMessages
14+
}
15+
16+
/** Based on https://github.com/scala/scala3/blob/3.5.2/compiler/src/dotty/tools/repl/ParseResult.scala#L130
17+
* change: removed [private] classifier so we can access it...
18+
* alternatively we could use reflection...
19+
*/
20+
object ParseResult {
21+
val commands: List[(String, String => ParseResult)] = List(
22+
Quit.command -> (_ => Quit),
23+
Quit.alias -> (_ => Quit),
24+
Help.command -> (_ => Help),
25+
Reset.command -> (arg => Reset(arg)),
26+
Imports.command -> (_ => Imports),
27+
Load.command -> (arg => Load(arg)),
28+
TypeOf.command -> (arg => TypeOf(arg)),
29+
DocOf.command -> (arg => DocOf(arg)),
30+
Settings.command -> (arg => Settings(arg)),
31+
)
32+
}
33+
}

0 commit comments

Comments
 (0)