Skip to content

Commit

Permalink
Remove support for Scala 2 (#150)
Browse files Browse the repository at this point in the history
* Remove support for Scala 2

* Update nav config
  • Loading branch information
Ostrzyciel authored Sep 17, 2024
1 parent 92fbd31 commit 55ef242
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 103 deletions.
71 changes: 10 additions & 61 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -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"))
Expand Down Expand Up @@ -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"),
Expand All @@ -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(
Expand All @@ -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
Expand Down Expand Up @@ -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,
),
Expand All @@ -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,
Expand All @@ -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")
Expand All @@ -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)
7 changes: 3 additions & 4 deletions docs/docs/getting-started-devs.md
Original file line number Diff line number Diff line change
Expand Up @@ -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() }}"
Expand Down Expand Up @@ -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?

Expand Down
3 changes: 1 addition & 2 deletions docs/docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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).
3 changes: 1 addition & 2 deletions docs/docs/user/compatibility.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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)
33 changes: 0 additions & 33 deletions docs/docs/user/scala2.md

This file was deleted.

1 change: 0 additions & 1 deletion docs/mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down

0 comments on commit 55ef242

Please sign in to comment.