Skip to content

Commit

Permalink
Merge pull request #396 from scalacenter/jdk21
Browse files Browse the repository at this point in the history
fix JDK21 CI
  • Loading branch information
bjaglin committed Feb 25, 2024
2 parents e7a5851 + 555d1f3 commit 59e8727
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 14 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: olafurpg/setup-scala@v14
- uses: coursier/setup-action@v1
with:
jvm: temurin:17
- run: sbt "test; scripted sbt-*/* skip-windows/*"
jvm: temurin:21
- run: sbt "test; scripted sbt-scalafix/* skip-windows/*"
windows:
name: Windows tests
runs-on: windows-latest
Expand Down
9 changes: 9 additions & 0 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,15 @@ scalaVersion := "2.12.19"
// keep this as low as possible to avoid running into binary incompatibility such as https://github.com/sbt/sbt/issues/5049
pluginCrossBuild / sbtVersion := "1.3.1"

scriptedSbt := {
val jdk = System.getProperty("java.specification.version").toDouble

if (jdk >= 21)
"1.9.0" // first release that supports JDK21
else
(pluginCrossBuild / sbtVersion).value
}

libraryDependencies += compilerPlugin(scalafixSemanticdb)

scalacOptions ++= List("-Ywarn-unused", "-Yrangepos")
Expand Down
2 changes: 1 addition & 1 deletion src/sbt-test/sbt-scalafix/dependency/build.sbt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
scalaVersion := "2.12.7"
scalaVersion := "2.12.18"

TaskKey[Unit]("check") := {
val a = IO.read((Compile / sourceDirectory).value / "scala" / "A.scala")
Expand Down
4 changes: 2 additions & 2 deletions src/sbt-test/sbt-scalafix/local-rules/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ inThisBuild(
"ch.epfl.scala" %% "example-scalafix-rule" % "1.4.0"
),
resolvers += Resolver.sonatypeRepo("snapshots"),
scalaVersion := "2.13.0", // out of sync with scalafix.sbt.BuildInfo.scala213 on purpose
scalaVersion := "2.13.11", // out of sync with scalafix.sbt.BuildInfo.scala213 on purpose
scalafixScalaBinaryVersion :=
// this should be the default in sbt-scalafix 1.0
CrossVersion.binaryScalaVersion(scalaVersion.value)
Expand All @@ -24,7 +24,7 @@ val rules = project
val service = project
.dependsOn(rules % ScalafixConfig)
.settings(
libraryDependencies += "com.nequissimus" %% "sort-imports" % "0.5.2" % ScalafixConfig
libraryDependencies += "ch.epfl.scala" %% "example-scalafix-rule" % "3.0.0" % ScalafixConfig
)

val sameproject = project
Expand Down
2 changes: 1 addition & 1 deletion src/sbt-test/sbt-scalafix/local-rules/test
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ $ delete rules/src/main/scala/local/NoOp.scala
> service/scalafix SyntacticRule

# run a rule included from a remote JAR referenced via the Scalafix ivy config
> service/scalafix SortImports
> service/scalafix SyntacticRule

> sameproject/scalafix SameProjectSyntacticRule
6 changes: 5 additions & 1 deletion src/sbt-test/skip-windows/caching/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@ inThisBuild(
scalafixDependencies += "com.geirsson" %% "example-scalafix-rule" % "1.2.0",
resolvers +=
// for retrieving SNAPSHOTS of `scalafix-interfaces`
Resolver.sonatypeRepo("snapshots")
Resolver.sonatypeRepo("snapshots"),
// On recent sbt versions, make sure unmanagedSources do not silently
// exclude 000-chmoded files (because input files are stamped with
// Hash by default), as it causes false positives in the test suite
unmanagedSources / inputFileStamper := sbt.nio.FileStamper.LastModified
)
)

Expand Down
8 changes: 2 additions & 6 deletions src/sbt-test/skip-windows/caching/test
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
# make sure unmanagedSources does not silently exclude 000-chmoded files on recent
# sbt versions (where input files are stamped with Hash by default)
> set unmanagedSources / inputFileStamper := sbt.nio.FileStamper.LastModified

# a re-run after a no-op, successful run should be cached
> set scalafixConfig := Some(file("files/DisableSyntaxNull.scalafix.conf"))
$ mkdir src/main/scala
Expand Down Expand Up @@ -339,7 +335,7 @@ $ mkdir src/main/scala
$ copy-file files/Valid.scala src/main/scala/Valid.scala
> scalafix --check ProcedureSyntax
> reload plugins
> 'set dependencyOverrides += "ch.epfl.scala" % "scalafix-interfaces" % "0.9.17+5-86d5550d-SNAPSHOT"' // different than current, requires bumping when using new APIs
> 'set dependencyOverrides += "ch.epfl.scala" % "scalafix-interfaces" % "0.11.0"' // different than current, requires bumping when using new APIs
> session save
> reload return
$ exec chmod 000 src/main/scala/Valid.scala
Expand All @@ -353,7 +349,7 @@ $ copy-file files/Valid.scala src/main/scala/Valid.scala
> set scalafixDependencies in ThisBuild := Nil
> scalafix --check ProcedureSyntax
> reload plugins
> 'set dependencyOverrides += "ch.epfl.scala" % "scalafix-interfaces" % "0.9.17+7-a1b6d972-SNAPSHOT"' // different than above, requires bumping when using new APIs
> 'set dependencyOverrides += "ch.epfl.scala" % "scalafix-interfaces" % "0.11.0+134-f4dcc6fa-SNAPSHOT"' // different than above, requires bumping when using new APIs
> session save
> reload return
> set scalafixDependencies in ThisBuild := Nil
Expand Down

0 comments on commit 59e8727

Please sign in to comment.