From 55ef24219e6c35a6c692ed690b13043acd034167 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Sowi=C5=84ski?= Date: Tue, 17 Sep 2024 11:33:17 +0200 Subject: [PATCH] Remove support for Scala 2 (#150) * Remove support for Scala 2 * Update nav config --- build.sbt | 71 +++++-------------------------- docs/docs/getting-started-devs.md | 7 ++- docs/docs/index.md | 3 +- docs/docs/user/compatibility.md | 3 +- docs/docs/user/scala2.md | 33 -------------- docs/mkdocs.yml | 1 - 6 files changed, 15 insertions(+), 103 deletions(-) delete mode 100644 docs/docs/user/scala2.md diff --git a/build.sbt b/build.sbt index d2a8ac5f..30452dea 100644 --- a/build.sbt +++ b/build.sbt @@ -1,16 +1,8 @@ -// We have two builds of Jelly – both compiled using the Scala 3 compiler, but one with -// Scala 2.13 dependencies and the other with Scala 3 dependencies. This is because we -// want to at least somewhat support both Scala 2.13 and Scala 3 projects that use Jelly. -// The "fake" Scala 2.13 build is published with the _2.13 suffix. -lazy val scala2Version = "3.3.2" // This is the fake Scala 2 version -lazy val scala3Version = "3.3.3" // This is the real Scala 3 version - // Scala 2 version used for meta-programming – transforming the generated proto classes. // Not used to compile any of the Jelly projects. lazy val scala2MetaVersion = "2.13.14" -ThisBuild / scalaVersion := scala3Version -ThisBuild / crossScalaVersions := Seq(scala2Version, scala3Version) +ThisBuild / scalaVersion := "3.3.3" ThisBuild / organization := "eu.ostrzyciel.jelly" ThisBuild / homepage := Some(url("https://w3id.org/jelly/jelly-jvm")) ThisBuild / licenses := List("Apache-2.0" -> url("https://www.apache.org/licenses/LICENSE-2.0")) @@ -38,31 +30,8 @@ lazy val rdf4jV = "5.0.2" // When updating also change the version in plugins.sbt lazy val scalapbV = "0.11.13" -// Helper function to transform Scala 3 dependencies into Scala 2 ones -def crossDependencies(binVersion: String, modules: ModuleID*): Seq[ModuleID] = { - if (binVersion == scala2Version) { - modules.map(_.cross(CrossVersion.for3Use2_13)) - } - else modules -} - -// List of exclusions for the grpc module and its dependencies (when building for Scala 2) -lazy val grpcExclusions2 = Seq( - ExclusionRule(organization = "org.parboiled", name = "parboiled_3"), - ExclusionRule(organization = "org.apache.pekko", name = "pekko-protobuf-v3_3"), - ExclusionRule(organization = "org.apache.pekko", name = "pekko-actor_3"), - ExclusionRule(organization = "org.apache.pekko", name = "pekko-stream_3"), - ExclusionRule(organization = "org.apache.pekko", name = "pekko-http_3"), - ExclusionRule(organization = "org.apache.pekko", name = "pekko-discovery_3"), - ExclusionRule(organization = "org.apache.pekko", name = "pekko-parsing_3"), - ExclusionRule(organization = "org.apache.pekko", name = "pekko-http-cors_3"), - ExclusionRule(organization = "org.apache.pekko", name = "pekko-http-core_3"), - ExclusionRule(organization = "org.apache.pekko", name = "pekko-grpc-runtime_3"), - ExclusionRule(organization = "com.typesafe", name = "ssl-config-core_3"), -) - -// List of exclusions for the grpc module and its dependencies (when building for Scala 3) -lazy val grpcExclusions3 = Seq( +// List of exclusions for the grpc module and its dependencies +lazy val grpcExclusions = Seq( ExclusionRule(organization = "org.scala-lang.modules", name = "scala-collection-compat_2.13"), ExclusionRule(organization = "com.thesamet.scalapb", name = "lenses_2.13"), ExclusionRule(organization = "com.thesamet.scalapb", name = "scalapb-runtime_2.13"), @@ -84,31 +53,17 @@ lazy val commonSettings = Seq( case x if x.endsWith("io.netty.versions.properties") => MergeStrategy.first case x => assemblyMergeStrategy.value(x) }, - excludeDependencies ++= { - if (scalaVersion.value == scala2Version) Seq( - ExclusionRule(organization = "org.scala-lang.modules", name = "scala-collection-compat_3"), - ExclusionRule(organization = "com.thesamet.scalapb", name = "lenses_3"), - ExclusionRule(organization = "com.thesamet.scalapb", name = "scalapb-runtime_3"), - ) - else Seq() - }, - crossVersion := { - // Publish our fake Scala 2 project with _2.13 suffix - if (scalaVersion.value == scala2Version) CrossVersion.Constant("2.13") - else CrossVersion.binary - }, + crossVersion := CrossVersion.binary, ) // Intermediate project that generates the Scala code from the protobuf files lazy val rdfProtos = (project in file("rdf-protos")) .settings( name := "jelly-scalameta-test", - libraryDependencies ++= crossDependencies(scalaVersion.value, + libraryDependencies ++= Seq( "com.thesamet.scalapb" %% "compilerplugin" % scalapbV, "com.thesamet.scalapb" %% "scalapb-runtime" % scalapbV % "protobuf", "com.thesamet.scalapb" %% "scalapb-runtime-grpc" % scalapbV, - ), - libraryDependencies ++= Seq( "io.grpc" % "grpc-netty" % scalapb.compiler.Version.grpcJavaVersion, ), Compile / PB.targets := Seq( @@ -125,7 +80,7 @@ lazy val core = (project in file("core")) .settings( name := "jelly-core", description := "Core code for serializing and deserializing RDF data in the Jelly format.", - libraryDependencies ++= crossDependencies(scalaVersion.value, + libraryDependencies ++= Seq( "com.thesamet.scalapb" %% "scalapb-runtime" % scalapbV, ), // Add the generated proto classes after transforming them with Scalameta @@ -198,7 +153,7 @@ lazy val stream = (project in file("stream")) .settings( name := "jelly-stream", description := "Utilities for using the Jelly RDF serialization format with Reactive Streams (via Apache Pekko).", - libraryDependencies ++= crossDependencies(scalaVersion.value, + libraryDependencies ++= Seq( "org.apache.pekko" %% "pekko-actor-typed" % pekkoV, "org.apache.pekko" %% "pekko-stream-typed" % pekkoV, ), @@ -211,7 +166,7 @@ lazy val grpc = (project in file("grpc")) .settings( name := "jelly-grpc", description := "Implementation of a gRPC client and server for the Jelly gRPC streaming protocol.", - libraryDependencies ++= crossDependencies(scalaVersion.value, + libraryDependencies ++= Seq( "com.typesafe.scala-logging" %% "scala-logging" % "3.9.5", "org.apache.pekko" %% "pekko-actor-typed" % pekkoV, "org.apache.pekko" %% "pekko-discovery" % pekkoV, @@ -225,10 +180,7 @@ lazy val grpc = (project in file("grpc")) (rdfProtos / baseDirectory).value / "src" / "main" / "protobuf", ), Compile / PB.generate / excludeFilter := "rdf.proto", - excludeDependencies ++= { - if (scalaVersion.value == scala2Version) grpcExclusions2 - else grpcExclusions3 - }, + excludeDependencies ++= grpcExclusions, commonSettings, ) .dependsOn(stream % "test->compile") @@ -255,10 +207,7 @@ lazy val examples = (project in file("examples")) "org.eclipse.rdf4j" % "rdf4j-rio-turtle" % rdf4jV, "org.eclipse.rdf4j" % "rdf4j-rio-nquads" % rdf4jV, ), - excludeDependencies ++= { - if (scalaVersion.value == scala2Version) grpcExclusions2 - else grpcExclusions3 - }, + excludeDependencies ++= grpcExclusions, commonSettings, ) .dependsOn(grpc, stream, jena, rdf4j) diff --git a/docs/docs/getting-started-devs.md b/docs/docs/getting-started-devs.md index dcd33e08..1d87233c 100644 --- a/docs/docs/getting-started-devs.md +++ b/docs/docs/getting-started-devs.md @@ -2,11 +2,11 @@ *If you don't want to code anything and only use Jelly with your Apache Jena/RDF4J application, see [the dedicated guide](getting-started-plugins.md) about using Jelly-JVM as a plugin.* -This guide explains a few of the basic functionalities of Jelly-JVM and how to use them in your code. Jelly-JVM is written in Scala, but it can be used from Java as well. However, in this guide, we will focus on **Scala 3**[^1]. +This guide explains a few of the basic functionalities of Jelly-JVM and how to use them in your code. Jelly-JVM is written in Scala, but it can be used from Java as well. However, in this guide, we will focus on **Scala 3**. ## Quick start – plain old files -Depending on your RDF library of choice (Apache Jena or RDF4J), you should import one of two dependencies: `jelly-jena` or `jelly-rdf4j`[^2]. In our examples we will use Jena, so let's add this to your `build.sbt` file (this would be the same for other build tools like Maven or Gradle): +Depending on your RDF library of choice (Apache Jena or RDF4J), you should import one of two dependencies: `jelly-jena` or `jelly-rdf4j`[^1]. In our examples we will use Jena, so let's add this to your `build.sbt` file (this would be the same for other build tools like Maven or Gradle): ```scala title="build.sbt" lazy val jellyVersion = "{{ jvm_package_version() }}" @@ -140,8 +140,7 @@ Jelly is a bit more than just a serialization format – it also defines a [gRPC - [RiverBench ci-worker](https://github.com/RiverBench/ci-worker) – a real-world application that is used for processing large RDF datasets in a CI/CD pipeline. It uses Jelly-JVM for serialization and deserialization with Apache Jena. It also uses extensively Apache Pekko Streams. -[^1]: Jelly-JVM is written in Scala 3, but we do have Scala 2.13-compatible builds available on Maven Central. [Read more about the details and caveats](user/scala2.md). -[^2]: There is nothing stopping you from using both at the same time. You can also pretty easily add support for any other Java-based RDF library by implementing a few interfaces. [More details here](dev/implementing.md). +[^1]: There is nothing stopping you from using both at the same time. You can also pretty easily add support for any other Java-based RDF library by implementing a few interfaces. [More details here](dev/implementing.md). ## Questions? diff --git a/docs/docs/index.md b/docs/docs/index.md index e22b48d3..0de7bf5a 100644 --- a/docs/docs/index.md +++ b/docs/docs/index.md @@ -67,7 +67,6 @@ Below is a list of all documentation pages about Jelly-JVM. You can also browse - [gRPC](user/grpc.md) - [Useful utilities](user/utilities.md) - [Compatibility policy](user/compatibility.md) - - [Scala 2.13 builds](user/scala2.md) - Developer guide - [Releases](dev/releases.md) - [Implementing Jelly for other libraries](dev/implementing.md) @@ -78,4 +77,4 @@ Below is a list of all documentation pages about Jelly-JVM. You can also browse -[^1]: Scala 2.13-compatible builds of Jelly-JVM are available as well. [See more details](user/scala2.md). +[^1]: Scala 2.13-compatible builds of Jelly-JVM are available for Jelly-JVM 1.0.x. Scala 2 support was removed in subsequent versions. [See more details](https://w3id.org/jelly/jelly-jvm/1.0.x/user/scala2). diff --git a/docs/docs/user/compatibility.md b/docs/docs/user/compatibility.md index 3c077ea9..11a53878 100644 --- a/docs/docs/user/compatibility.md +++ b/docs/docs/user/compatibility.md @@ -6,7 +6,7 @@ Jelly-JVM follows [Semantic Versioning 2.0.0](https://semver.org/), with MAJOR.M The current version of Jelly-JVM is compatible with Java 17 and newer. Java 17, 21, and 22 are tested in CI and are guaranteed to work. We recommend using a recent release of [GraalVM](https://www.graalvm.org/) to get the best performance. If you need Java 11 support, you should use [Jelly-JVM 1.0.x](https://w3id.org/jelly/jelly-jvm/1.0.x). -Jelly is built with [Scala 3 LTS releases](https://www.scala-lang.org/blog/2022/08/17/long-term-compatibility-plans.html), however, [Scala 2.13-compatible builds are available as well](scala2.md). +Jelly is built with [Scala 3 LTS releases](https://www.scala-lang.org/blog/2022/08/17/long-term-compatibility-plans.html) and supports only Scala 3. If you need Scala 2 support, you should use [Jelly-JVM 1.0.x](https://w3id.org/jelly/jelly-jvm/1.0.x). ## RDF libraries @@ -22,7 +22,6 @@ Auto-generated classes in the `jelly-core` module, `eu.ostrzyciel.jelly.core.pro ## See also -- [Scala 2.13 builds](scala2.md) - [Release notes on GitHub](https://github.com/Jelly-RDF/jelly-jvm/releases) - [Making Jelly-JVM releases](../dev/releases.md) - [Contributing to Jelly-JVM](../contributing.md) diff --git a/docs/docs/user/scala2.md b/docs/docs/user/scala2.md deleted file mode 100644 index 5cce33fa..00000000 --- a/docs/docs/user/scala2.md +++ /dev/null @@ -1,33 +0,0 @@ -# Scala 2 builds - -Jelly-JVM is written in Scala 3, but we also provide packages that _mostly_ work with Scala 2.13. They include only Scala 2 dependencies and are published to Maven Central. - -## How to use this? - -- In your project enable the Scala 2.13 TASTy reader – [read more in Scala docs](https://docs.scala-lang.org/scala3/guides/migration/compatibility-classpath.html#the-scala-213-tasty-reader). -- Add Jelly-JVM dependencies with the `_2.13` suffix, e.g., `eu.ostrzyciel.jelly %% jelly-core % 0.14.0` in sbt (assuming you are building a Scala 2.13 project). -- If you get conflicting Scala version suffix errors from sbt, you may need to add exclusion rules like this: - ```scala - libraryDependencies ++= List( - "eu.ostrzyciel.jelly" %% "jelly-stream" % jellyVersion, - "eu.ostrzyciel.jelly" %% "jelly-grpc" % jellyVersion, - "eu.ostrzyciel.jelly" %% "jelly-rdf4j" % jellyVersion, - ).map(_ excludeAll ( - // These are two leftover Scala 3 dependencies that are improperly handled in the pseudo-Scala 2 - // version of Jelly due to a quirk with how the scalapb plugin works. We must exclude them here. - ExclusionRule(organization = "org.apache.pekko", name = "pekko-grpc-runtime_3"), - ExclusionRule(organization = "com.thesamet.scalapb", name = "scalapb-runtime_3"), - )) - ``` - -That's it! - -## Is this supported? - -Kind of. It does work (we tested it), but it's not a perfect solution, as Jelly-JVM was from the start designed only for Scala 3. **Support for Scala 2 will be dropped in Jelly-JVM 2.0.0**. - -## Technical notes – maintainer guide - -The thing is a rather ugly hack in sbt. On the one hand, we need sbt to think we need Scala 2 dependencies for one build, and that we want to publish these artifacts with the `_2.13` suffix in Maven. On the other, this is still Scala 3 code and it _must_ be compiled with the Scala 3 compiler. - -The solution looks like [this](https://github.com/Jelly-RDF/jelly-jvm/blob/b9f4083671d6a1d4ee4861061e9bea4b1460adea/build.sbt#L1) – we trick sbt, by having two Scala 3 builds (one with a slightly different version), and then [treating one of them differently](https://github.com/Jelly-RDF/jelly-jvm/blob/b9f4083671d6a1d4ee4861061e9bea4b1460adea/build.sbt#L97) using conditionals. Don't judge me. diff --git a/docs/mkdocs.yml b/docs/mkdocs.yml index c9a838c5..28b29b3a 100644 --- a/docs/mkdocs.yml +++ b/docs/mkdocs.yml @@ -96,7 +96,6 @@ nav: - Useful utilities: 'user/utilities.md' - Low-level usage: 'user/low-level.md' - Compatibility policy: 'user/compatibility.md' - - Scala 2 builds: 'user/scala2.md' - Developer guide: - Releases: 'dev/releases.md' - Implementing Jelly for other libraries: 'dev/implementing.md'