Skip to content

Jdk17 scala 2.12.20 and 2.13.16 #5

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

Merged
merged 27 commits into from
Jun 26, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
8e20814
* flink bump to 1.20.1
raphaelsolarski Jun 18, 2025
e3b88e0
* flink bump to 1.20.1
raphaelsolarski Jun 18, 2025
cc9d57e
provoked change
raphaelsolarski Jun 18, 2025
8e0cd74
publish on push to test publish action (should be reverted before merge)
raphaelsolarski Jun 23, 2025
e3d10f1
additional logging
raphaelsolarski Jun 23, 2025
65132f7
additional logging
raphaelsolarski Jun 23, 2025
135bea5
additional logging
raphaelsolarski Jun 23, 2025
be170a9
additional logging
raphaelsolarski Jun 23, 2025
db2182b
build/publish jdk downgraded
raphaelsolarski Jun 23, 2025
ee906f4
build/publish jdk downgraded
raphaelsolarski Jun 23, 2025
7f37273
--no-colors to sbt added
raphaelsolarski Jun 23, 2025
7708f4b
setup buildx builder
raphaelsolarski Jun 23, 2025
0117741
maven artifacts publication + little fixes
raphaelsolarski Jun 23, 2025
8afd676
sonatype credentials setup
raphaelsolarski Jun 23, 2025
e04033a
secrets fixup
raphaelsolarski Jun 23, 2025
72d1773
provoked change
raphaelsolarski Jun 23, 2025
45f4cfa
provoked change
raphaelsolarski Jun 23, 2025
7c92152
oss.sonatype.org changed to centra.sonatype.com
raphaelsolarski Jun 23, 2025
cbf6f64
credential host fixup (maybe hack)
raphaelsolarski Jun 23, 2025
e652754
logging
raphaelsolarski Jun 24, 2025
7b15583
Logging removed
raphaelsolarski Jun 24, 2025
a25f844
GH repo renamed + readme update
raphaelsolarski Jun 24, 2025
1a2585f
scala test bump
raphaelsolarski Jun 24, 2025
7c0e8a4
scala upgrade 2.12.15 -> 2.12.20 2.13.15 -> 2.13.16
raphaelsolarski Jun 24, 2025
0e6e365
review fix
raphaelsolarski Jun 26, 2025
f237c07
publishSigned configuration
raphaelsolarski Jun 26, 2025
d8bcd2b
publish as manual ci action
raphaelsolarski Jun 26, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: olafurpg/setup-scala@v11
- uses: actions/setup-java@v4
with:
java-version: [email protected]
distribution: temurin
java-version: 17
cache: sbt
- uses: sbt/setup-sbt@v1
- name: Test
run: sbt test
run: sbt "++test"
39 changes: 39 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Publish
on:
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
env:
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
steps:
- uses: actions/checkout@v1
- uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 11
cache: sbt
- uses: sbt/setup-sbt@v1
- name: Import GPG key
id: import_gpg
uses: crazy-max/ghaction-import-gpg@v5
with:
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.GPG_PRIVATE_KEY_PASSWORD }}
- name: Build and publish maven artifacts
run: sbt "+clean; +publishSigned"
- name: Setup buildx builder
uses: docker/setup-buildx-action@v3
with:
platforms: linux/amd64,linux/arm64
config-inline: |
[worker.oci]
max-parallelism = 1
- name: Login to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USER }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push images
run: ./build-images.sh --push
1 change: 1 addition & 0 deletions .sbtopts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-J--add-opens=java.base/java.util=ALL-UNNAMED
8 changes: 8 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
ARG FLINK_VERSION="invalid"

FROM flink:${FLINK_VERSION}-scala_2.12-java17

RUN rm $FLINK_HOME/lib/flink-scala*.jar

ARG FLINK_SCALA_VERSION="invalid"
COPY --chown=flink:flink flink-scala-assembly-${FLINK_SCALA_VERSION}.jar $FLINK_HOME/lib/
17 changes: 12 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,25 @@
# flink-scala-2.13
# flink-scala

For now Flink does not support Scala 2.13. For more refer to <https://issues.apache.org/jira/browse/FLINK-13414>.
This module is a replacement for the `org.apache.flink:flink-scala` lib shipped with flink distribution,
and allows using flink with higher scala versions than 2.12.8.

Our solution to deploy Scala 2.13 code to Flink, until it's officially supported (or Flink becomes really scala-free):
For more refer to <https://issues.apache.org/jira/browse/FLINK-13414>.

## Replacing flink-scala in flink distribution
```bash
rm $FLINK_HOME/lib/flink-scala*.jar
wget https://repo1.maven.org/maven2/pl/touk/flink-scala-2-13_2.13/1.1.2/flink-scala-2-13_2.13-1.1.2-assembly.jar -O $FLINK_HOME/lib/flink-scala-2-13_2.13-1.1.1-assembly.jar

wget https://central.sonatype.com/repository/maven-snapshots/pl/touk/flink-scala_2.13/1.1.3-SNAPSHOT/flink-scala_2.13-1.1.3-SNAPSHOT-assembly.jar -O $FLINK_HOME/lib/flink-scala_2.13-1.1.3-SNAPSHOT-assembly.jar
```

## Using as a lib (probably only sufficient when child-first classloading is enabled on flink)
```scala
libraryDependencies += "pl.touk" %% "flink-scala-2-13" % "1.1.2"
libraryDependencies += "pl.touk" %% "flink-scala" % "1.1.3-SNAPSHOT"
```

## Prebuild flink images
* we provide prebuild flink docker images for scala 2.12 and 2.13 on [Docker Hub](https://hub.docker.com/r/touk/flink)

## Publishing
```
sbt publishSigned sonatypeBundleRelease
Expand Down
39 changes: 39 additions & 0 deletions build-images.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/bin/bash
set -e

VERSION=$(sbt --no-colors -Dsbt.supershell=false "show version" | grep "info" | tail -1 | awk '{print $2}')
FLINK_VERSION=$(sbt --no-colors -Dsbt.supershell=false "show flinkV" | grep "info" | tail -1 | awk '{print $2}')
echo "FLINK_SCALA_VERSION: ${VERSION}"
echo "FLINK_VERSION: ${FLINK_VERSION}"

if [[ "$1" == "--push" ]]; then
OUTPUT_TYPE="registry"
else
OUTPUT_TYPE="docker"
fi

sbt "+clean; +assembly"

IMAGE_TAG="${VERSION}-flink${FLINK_VERSION}-scala_2.12"
echo "Building Docker image with version: $IMAGE_TAG"

cp target/scala-2.12/flink-scala-assembly-${VERSION}.jar .

docker buildx build \
--build-arg FLINK_VERSION=$FLINK_VERSION \
--build-arg FLINK_SCALA_VERSION=$VERSION \
--platform linux/amd64,linux/arm64 \
--tag touk/flink:$IMAGE_TAG \
--output=type=$OUTPUT_TYPE .

IMAGE_TAG="${VERSION}-flink${FLINK_VERSION}-scala_2.13"
echo "Building Docker image with version: $IMAGE_TAG"

cp target/scala-2.13/flink-scala-assembly-${VERSION}.jar .

docker buildx build \
--build-arg FLINK_VERSION=$FLINK_VERSION \
--build-arg FLINK_SCALA_VERSION=$VERSION \
--platform linux/amd64,linux/arm64 \
--tag touk/flink:$IMAGE_TAG \
--output=type=$OUTPUT_TYPE .
116 changes: 76 additions & 40 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,67 +1,103 @@
version := "1.1.2"
import sbtassembly.MergeStrategy

scalaVersion := "2.13.15"
name := "flink-scala"
version := "1.1.3-SNAPSHOT"

name := "flink-scala-2.13"
val scala212 = "2.12.20"
val scala213 = "2.13.16"

lazy val flinkV = "1.16.2"
lazy val scalaTestV = "3.2.17"
scalaVersion := scala212
crossScalaVersions := List(scala212, scala213)

val flinkV = settingKey[String]("Flink version") // to extract using `show flinkV`
flinkV := "1.20.1"

assembly / artifact := {
val art = (assembly / artifact).value
art.withClassifier(Some("assembly"))
}
lazy val scalaTestV = "3.2.19"

addArtifact(assembly / artifact, assembly)
lazy val assemblySettings = Seq(
assembly / artifact := {
val art = (assembly / artifact).value
art.withClassifier(Some("assembly"))
},
assembly / assemblyMergeStrategy := {
case PathList(ps@_*) if ps.last == "module-info.class" => MergeStrategy.discard
case x => MergeStrategy.defaultMergeStrategy(x)
},
addArtifact(assembly / artifact, assembly)
)

lazy val publishSettings = Seq(
publishMavenStyle := true,
sonatypeCredentialHost := "central.sonatype.com",
publishTo := {
val defaultNexusUrl = "https://oss.sonatype.org/"
if (isSnapshot.value)
Some("snapshots" at defaultNexusUrl + "content/repositories/snapshots")
else {
sonatypePublishToBundle.value
}
if (isSnapshot.value)
Some("snapshots" at "https://central.sonatype.com/repository/maven-snapshots/")
else {
sonatypePublishToBundle.value //todo: full release not tested yet
}
},
Test / publishArtifact := false,
//We don't put scm information here, it will be added by release plugin and if scm provided here is different than the one from scm
//we'll end up with two scm sections and invalid pom...
pomExtra in Global := {
<scm>
<connection>scm:git:github.com/TouK/flink-scala-2.13.git</connection>
<developerConnection>scm:git:[email protected]:TouK/flink-scala-2.13.git</developerConnection>
<url>github.com/TouK/flink-scala-2.13</url>
<connection>scm:git:github.com/TouK/flink-scala.git</connection>
<developerConnection>scm:git:[email protected]:TouK/flink-scala.git</developerConnection>
<url>github.com/TouK/flink-scala</url>
</scm>
<developers>
<developer>
<id>TouK</id>
<name>TouK</name>
<url>https://touk.pl</url>
</developer>
</developers>
<developers>
<developer>
<id>TouK</id>
<name>TouK</name>
<url>https://touk.pl</url>
</developer>
</developers>
},
organization := "pl.touk",
)

lazy val root = (project in file("."))
.settings(
name := "flink-scala-2.13",
name := "flink-scala",
organization := "pl.touk",
licenses := Seq("Apache 2" -> url("http://www.apache.org/licenses/LICENSE-2.0.txt")),
homepage := Some(url("https://github.com/TouK/flink-scala-2.13")),
libraryDependencies ++= {
Seq(
"org.scala-lang" % "scala-compiler" % scalaVersion.value,
"org.scala-lang" % "scala-reflect" % scalaVersion.value,

"org.apache.flink" % "flink-streaming-java" % flinkV % "provided",
"com.twitter" %% "chill" % "0.9.5" exclude("com.esotericsoftware", "kryo-shaded"),
"com.esotericsoftware.kryo" % "kryo" % "2.24.0" % "provided",

"org.scalatest" %% "scalatest" % scalaTestV % "test",
)
}
homepage := Some(url("https://github.com/TouK/flink-scala")),
libraryDependencies ++= (forScalaVersion(scalaVersion.value) {
case (2, 12) =>
Seq(
"org.apache.flink" %% "flink-scala" % flinkV.value excludeAll(
ExclusionRule(organization = "org.apache.flink", name = "flink-core"),
ExclusionRule(organization = "org.apache.flink", name = "flink-java"),
ExclusionRule(organization = "org.apache.flink", name = "flink-shaded-asm-9"),
ExclusionRule(organization = "org.slf4j", name = "slf4j-api"),
ExclusionRule(organization = "com.google.code.findbugs", name = "jsr305"),
),
"com.esotericsoftware.kryo" % "kryo" % "2.24.0" % Test,
"org.apache.flink" % "flink-java" % flinkV.value % Test,
)
case (2, 13) =>
Seq(
"org.apache.flink" % "flink-streaming-java" % flinkV.value % "provided",
"com.twitter" %% "chill" % "0.9.5" exclude("com.esotericsoftware", "kryo-shaded"),
"com.esotericsoftware.kryo" % "kryo" % "2.24.0" % "provided",
)
} ++ Seq(
"org.scala-lang" % "scala-library" % scalaVersion.value,
"org.scala-lang" % "scala-compiler" % scalaVersion.value,
"org.scala-lang" % "scala-reflect" % scalaVersion.value,
"org.scalatest" %% "scalatest" % scalaTestV % Test,
))
)
.settings(assemblySettings *)
.settings(publishSettings)

def forScalaVersion[T](version: String)(provide: PartialFunction[(Int, Int), T]): T = {
CrossVersion.partialVersion(version) match {
case Some((major, minor)) if provide.isDefinedAt((major.toInt, minor.toInt)) =>
provide((major.toInt, minor.toInt))
case Some(_) =>
throw new IllegalArgumentException(s"Scala version $version is not handled")
case None =>
throw new IllegalArgumentException(s"Invalid Scala version $version")
}
}
2 changes: 1 addition & 1 deletion project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "2.1.4")
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "2.3.1")
addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "3.10.0")
addSbtPlugin("com.github.sbt" % "sbt-pgp" % "2.2.1")
Original file line number Diff line number Diff line change
Expand Up @@ -233,4 +233,4 @@ class ScalaCollectionsRegistrarCompat extends IKryoRegistrar {
)
)
}
}
}