diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4e7db4d5..08ddca46 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -23,8 +23,8 @@ jobs: strategy: matrix: os: [ubuntu-latest] - scala: [3.6.4, 2.12.21] - java: [temurin@11] + scala: [3.8.4, 2.12.21] + java: [temurin@17] runs-on: ${{ matrix.os }} steps: - name: Checkout current branch (full) @@ -32,12 +32,12 @@ jobs: with: fetch-depth: 0 - - name: Setup Java (temurin@11) - if: matrix.java == 'temurin@11' + - name: Setup Java (temurin@17) + if: matrix.java == 'temurin@17' uses: actions/setup-java@v5 with: distribution: temurin - java-version: 11 + java-version: 17 cache: sbt - name: Setup sbt @@ -68,8 +68,8 @@ jobs: strategy: matrix: os: [ubuntu-latest] - scala: [3.6.4] - java: [temurin@11] + scala: [3.8.4] + java: [temurin@17] runs-on: ${{ matrix.os }} steps: - name: Checkout current branch (full) @@ -77,23 +77,23 @@ jobs: with: fetch-depth: 0 - - name: Setup Java (temurin@11) - if: matrix.java == 'temurin@11' + - name: Setup Java (temurin@17) + if: matrix.java == 'temurin@17' uses: actions/setup-java@v5 with: distribution: temurin - java-version: 11 + java-version: 17 cache: sbt - name: Setup sbt uses: sbt/setup-sbt@v1 - - name: Download target directories (3.6.4) + - name: Download target directories (3.8.4) uses: actions/download-artifact@v8 with: - name: target-${{ matrix.os }}-3.6.4-${{ matrix.java }} + name: target-${{ matrix.os }}-3.8.4-${{ matrix.java }} - - name: Inflate target directories (3.6.4) + - name: Inflate target directories (3.8.4) run: | tar xf targets.tar rm targets.tar diff --git a/build.sbt b/build.sbt index 35df52ac..44e5d680 100644 --- a/build.sbt +++ b/build.sbt @@ -30,7 +30,7 @@ ThisBuild / developers := List( ) // sbt-github-actions -lazy val scala3 = "3.6.4" +lazy val scala3 = "3.8.4" lazy val scala212 = "2.12.21" ThisBuild / scalaVersion := scala3 ThisBuild / crossScalaVersions := Seq(scala3, scala212) @@ -38,7 +38,7 @@ ThisBuild / githubWorkflowBuild := Seq( WorkflowStep.Sbt(name = Some("Build project"), commands = List("compile", "test", "scripted")) ) ThisBuild / githubWorkflowTargetBranches := Seq("main") -ThisBuild / githubWorkflowJavaVersions := Seq(JavaSpec.temurin("11")) +ThisBuild / githubWorkflowJavaVersions := Seq(JavaSpec.temurin("17")) ThisBuild / githubWorkflowTargetTags := Seq("v*") ThisBuild / githubWorkflowBuildPreamble := Seq( WorkflowStep.Sbt( @@ -61,13 +61,18 @@ ThisBuild / githubWorkflowPublish := Seq( ) // compilers -ThisBuild / javacOptions ++= Seq("--release", "8") -ThisBuild / scalacOptions ++= Seq("-release", "8") +ThisBuild / javacOptions ++= Seq("--release", "17") +ThisBuild / scalacOptions ++= Seq("-release", "17") lazy val javaOnlySettings: Seq[Setting[?]] = Seq( crossPaths := false, autoScalaLibrary := false, - crossScalaVersions := Seq(scala3) + crossScalaVersions := Seq(scala3), + dependencyOverrides ++= Seq( + // tests are written in scala. pin the library to the compiler version so the transitive + // (older) one from the test framework does not end up alone on the classpath + "org.scala-lang" %% "scala3-library" % scalaVersion.value + ) ) lazy val `sbt-avro-parent`: Project = project @@ -106,16 +111,17 @@ lazy val `sbt-avro`: Project = project .enablePlugins(BuildInfoPlugin, SbtPlugin) .settings( description := "Sbt plugin for compiling Avro sources", + addSbtPlugin(Dependencies.SbtPlugin.Sbt2Compat), (pluginCrossBuild / sbtVersion) := { scalaBinaryVersion.value match { - case "2.12" => "1.5.0" - case _ => "2.0.0-M3" + case "2.12" => "1.9.0" + case _ => "2.0.0" } }, scriptedSbt := { scalaBinaryVersion.value match { - case "2.12" => "1.10.7" - case _ => "2.0.0-M3" + case "2.12" => "1.13.0" + case _ => "2.0.0" } }, buildInfoKeys := Seq[BuildInfoKey](name, version), diff --git a/plugin/src/main/scala-2.12/com/github/sbt/avro/PluginCompat.scala b/plugin/src/main/scala-2.12/com/github/sbt/avro/PluginCompat.scala deleted file mode 100644 index 94bff10b..00000000 --- a/plugin/src/main/scala-2.12/com/github/sbt/avro/PluginCompat.scala +++ /dev/null @@ -1,14 +0,0 @@ -package com.github.sbt.avro -import sbt.* -import xsbti.FileConverter - -import java.nio.file.{Path => NioPath} - -private[avro] object PluginCompat { - type FileRef = java.io.File - type Out = java.io.File - - def toNioPath(a: Attributed[File])(implicit conv: FileConverter): NioPath = - a.data.toPath() - def toFileRef(f: File): FileRef = f -} diff --git a/plugin/src/main/scala-3/com/github/sbt/avro/PluginCompat.scala b/plugin/src/main/scala-3/com/github/sbt/avro/PluginCompat.scala deleted file mode 100644 index b6127130..00000000 --- a/plugin/src/main/scala-3/com/github/sbt/avro/PluginCompat.scala +++ /dev/null @@ -1,14 +0,0 @@ -package com.github.sbt.avro - -import java.nio.file.{Path => NioPath} -import sbt.* -import xsbti.{FileConverter, HashedVirtualFileRef, VirtualFile} - -private[avro] object PluginCompat: - type FileRef = HashedVirtualFileRef - type Out = VirtualFile - - def toNioPath(a: Attributed[HashedVirtualFileRef])(using conv: FileConverter): NioPath = - conv.toPath(a.data) - - def toFileRef(f: File)(using conv: FileConverter): FileRef = conv.toVirtualFile(f.toPath) diff --git a/plugin/src/main/scala/com/github/sbt/avro/SbtAvro.scala b/plugin/src/main/scala/com/github/sbt/avro/SbtAvro.scala index 23c6e751..f785fa74 100644 --- a/plugin/src/main/scala/com/github/sbt/avro/SbtAvro.scala +++ b/plugin/src/main/scala/com/github/sbt/avro/SbtAvro.scala @@ -3,9 +3,9 @@ package com.github.sbt.avro import sbt.Keys.* import sbt.{*, given} import Path.relativeTo -import PluginCompat.* import sbt.ScopeFilter.ProjectFilter import sbt.librarymanagement.DependencyFilter +import sbtcompat.PluginCompat.* import java.io.File @@ -63,7 +63,7 @@ object SbtAvro extends AutoPlugin { // addArtifact doesn't take publishArtifact setting in account artifacts ++= Classpaths.artifactDefs(avroArtifactTasks).value, - packagedArtifacts ++= Classpaths.packaged(avroArtifactTasks).value, + packagedArtifacts ++= Def.uncached(Classpaths.packaged(avroArtifactTasks).value), // use a custom folders to avoid potential conflict with other generators avroProjectIncludeFilter := inDependencies(ThisProject), avroUnpackDependencies / target := sourceManaged.value / "avro", @@ -96,16 +96,18 @@ object SbtAvro extends AutoPlugin { avroUnpackDependencies / includeFilter := AllPassFilter, avroUnpackDependencies / excludeFilter := HiddenFileFilter, avroUnpackDependencies / target := configSrcSub(avroUnpackDependencies / target).value, - avroUnpackDependencies := unpackDependenciesTask(avroUnpackDependencies).value, + avroUnpackDependencies := Def.uncached(unpackDependenciesTask(avroUnpackDependencies).value), // source generation avroGenerate / target := configSrcSub(avroGenerate / target).value, managedSourceDirectories += (avroGenerate / target).value, - avroGenerate := sourceGeneratorTask(avroGenerate) - .dependsOn(avroUnpackDependencies) - .dependsOn(avroUnpackDependencies.?.all(filterDependsOn)) - .value, + avroGenerate := Def.uncached( + sourceGeneratorTask(avroGenerate) + .dependsOn(avroUnpackDependencies) + .dependsOn(avroUnpackDependencies.?.all(filterDependsOn)) + .value + ), sourceGenerators += avroGenerate.taskValue, - compile := compile.dependsOn(avroGenerate).value, + compile := compile.dependsOn(Def.uncached(avroGenerate)).value, // packaging packageAvro / artifactClassifier := Some(AvroClassifier), packageAvro / publishArtifact := false @@ -148,7 +150,7 @@ object SbtAvro extends AutoPlugin { ): Seq[File] = { def cachedExtractDep(jar: File): Seq[File] = { val cached = FileFunction.cached( - cacheBaseDirectory / jar.name, + cacheBaseDirectory / jar.getName, inStyle = FilesInfo.lastModified, outStyle = FilesInfo.exists ) { deps => diff --git a/project/Dependencies.scala b/project/Dependencies.scala index 2029979a..a13c17f9 100644 --- a/project/Dependencies.scala +++ b/project/Dependencies.scala @@ -5,6 +5,7 @@ object Dependencies { object Versions { val Avro = "1.12.2" val Specs2 = "4.23.0" + val Sbt2Compat = "0.2.0" } object Provided { @@ -15,4 +16,8 @@ object Dependencies { val Specs2Core = "org.specs2" %% "specs2-core" % Versions.Specs2 % "test" val AvroCompiler = "org.apache.avro" % "avro-compiler" % Versions.Avro % "test" } + + object SbtPlugin { + val Sbt2Compat = "com.github.sbt" % "sbt2-compat" % Versions.Sbt2Compat + } }