From c308fd4d420c864dd0de3be54c22131edf3058b3 Mon Sep 17 00:00:00 2001 From: xuwei-k <6b656e6a69@gmail.com> Date: Wed, 9 Sep 2026 07:49:40 +0900 Subject: [PATCH] sbt 2 --- .github/workflows/build-test.yml | 4 ++-- build.sbt | 34 +++++++++++++++++++------------- docs/build.sbt | 14 +++++++------ docs/project/build.properties | 2 +- project/Common.scala | 14 ++++++------- project/build.properties | 2 +- 6 files changed, 39 insertions(+), 31 deletions(-) diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index fc9bcbe5..126a038a 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -29,7 +29,7 @@ jobs: with: java: 21, 17 scala: 2.13.x, 3.x - cmd: cd docs && sbt ++$MATRIX_SCALA validateCode + cmd: cd docs && sbt "++$MATRIX_SCALA ; validateCode" tests: name: Tests @@ -42,7 +42,7 @@ jobs: java: 21, 17 scala: 2.13.x, 3.x cmd: >- - sbt ++$MATRIX_SCALA test + sbt --server ++$MATRIX_SCALA test scripted-tests: name: Scripted tests diff --git a/build.sbt b/build.sbt index 225c6803..26014110 100644 --- a/build.sbt +++ b/build.sbt @@ -41,13 +41,14 @@ lazy val root = project publish / skip := true, ) .settings( - (Compile / headerSources) ++= + (Compile / headerSources) ++= Def.uncached( ((baseDirectory.value ** ("*.properties" || "*.md" || "*.sbt")) --- (baseDirectory.value ** "target" ** "*") --- (baseDirectory.value / ".github" ** "*") --- (baseDirectory.value / "docs" ** "*") - --- (baseDirectory.value / "sbt-play-ebean" ** "*")).get ++ - (baseDirectory.value / "project" ** "*.scala" --- (baseDirectory.value ** "target" ** "*")).get + --- (baseDirectory.value / "sbt-play-ebean" ** "*")).get() ++ + (baseDirectory.value / "project" ** "*.scala" --- (baseDirectory.value ** "target" ** "*")).get() + ), ) lazy val core = project @@ -58,11 +59,14 @@ lazy val core = project crossScalaVersions := Seq(scala213, scala3App), Dependencies.ebean, mimaSettings, - Compile / compile := enhanceEbeanClasses( - (Compile / dependencyClasspath).value, - (Compile / compile).value, - (Compile / classDirectory).value, - "play/db/ebean/**" + Compile / compile := Def.uncached( + enhanceEbeanClasses( + (Compile / dependencyClasspath).value, + (Compile / compile).value, + (Compile / classDirectory).value, + "play/db/ebean/**", + fileConverter.value, + ) ), ) @@ -74,12 +78,12 @@ lazy val plugin = project organization := "org.playframework", Dependencies.plugin, addSbtPlugin("org.playframework" % "sbt-plugin" % Versions.play), - scalaVersion := scala212, + scalaVersion := scala3Plugin, crossScalaVersions := Seq(scala212, scala3Plugin), pluginCrossBuild / sbtVersion := { scalaBinaryVersion.value match { case "2.12" => "1.12.9" - case _ => "2.0.0-RC11" + case _ => "2.0.8" } }, scalacOptions ++= { @@ -104,8 +108,9 @@ lazy val plugin = project scriptedDependencies := publishLocal.value, ) .settings( - (Compile / headerSources) ++= - (sourceDirectory.value / "sbt-test" ** ("*.java" || "*.sbt")).get + (Compile / headerSources) ++= Def.uncached( + (sourceDirectory.value / "sbt-test" ** ("*.java" || "*.sbt")).get() + ), ) def resolveScriptedScala(version: String): String = @@ -129,10 +134,11 @@ def enhanceEbeanClasses( classpath: Classpath, analysis: CompileAnalysis, classDirectory: File, - pkg: String + pkg: String, + converter: FileConverter, ): CompileAnalysis = { // Ebean (really hacky sorry) - val cp = classpath.map(_.data.toURI.toURL).toArray :+ classDirectory.toURI.toURL + val cp = classpath.map(_.data).map(converter.toPath).map(_.toFile.toURI.toURL).toArray :+ classDirectory.toURI.toURL val cl = new java.net.URLClassLoader(cp) val t = cl .loadClass("io.ebean.enhance.Transformer") diff --git a/docs/build.sbt b/docs/build.sbt index 0600e338..08592db2 100644 --- a/docs/build.sbt +++ b/docs/build.sbt @@ -19,7 +19,8 @@ lazy val docs = project libraryDependencies += component("play-java-forms"), libraryDependencies += component("play-test") % Test, libraryDependencies += "com.h2database" % "h2" % "2.5.250" % Test, - PlayDocsKeys.javaManualSourceDirectories := (baseDirectory.value / "manual" / "working" / "javaGuide" ** "code").get, + PlayDocsKeys.javaManualSourceDirectories := (baseDirectory.value / "manual" / "working" / "javaGuide" ** "code") + .get(), // No resource directories shuts the ebean agent up about java sources in the classes directory Test / unmanagedResourceDirectories := Nil, Test / parallelExecution := false, @@ -40,23 +41,24 @@ lazy val docs = project FileType("properties") -> HeaderCommentStyle.hashLineComment, FileType("md") -> CommentStyle(new LineCommentCreator(""), commentBetween("")) ), - Compile / headerSources ++= + Compile / headerSources ++= Def.uncached( ((baseDirectory.value ** ("*.properties" || "*.md" || "*.sbt")) - --- (baseDirectory.value ** "target" ** "*")).get, + --- (baseDirectory.value ** "target" ** "*")).get() + ), ) - .settings(PlayEbean.unscopedSettings: _*) + .settings(PlayEbean.unscopedSettings) .settings( inConfig(Test)( Seq( playEbeanModels := Seq("javaguide.ebean.*") ) - ): _* + ) ) .dependsOn(playEbean) lazy val playEbean = ProjectRef(Path.fileProperty("user.dir").getParentFile, "core") -val _ = sys.props += ("sbt_validateCode" -> List( +val ignore = sys.props += ("sbt_validateCode" -> List( "evaluateSbtFiles", "validateDocs", ).mkString(";")) diff --git a/docs/project/build.properties b/docs/project/build.properties index 24f46a50..d75cc0e5 100644 --- a/docs/project/build.properties +++ b/docs/project/build.properties @@ -1,3 +1,3 @@ # Copyright (C) from 2022 The Play Framework Contributors , 2011-2021 Lightbend Inc. -sbt.version=1.13.0 +sbt.version=2.0.8 diff --git a/project/Common.scala b/project/Common.scala index 539e6755..f09018f1 100644 --- a/project/Common.scala +++ b/project/Common.scala @@ -21,21 +21,21 @@ object Common extends AutoPlugin { val repoName = "play-ebean" - override def globalSettings: Seq[Setting[_]] = + override def globalSettings: Seq[Setting[?]] = Seq( // organization organization := "org.playframework", organizationName := "The Play Framework Project", - organizationHomepage := Some(url("https://playframework.com/")), + organizationHomepage := Some(uri("https://playframework.com/")), scalacOptions ++= Seq("-deprecation", "-feature", "-unchecked", "-encoding", "utf8"), javacOptions ++= Seq("-encoding", "UTF-8"), // legal - licenses := Seq("Apache-2.0" -> url("https://www.apache.org/licenses/LICENSE-2.0.html")), + licenses := Seq(License("Apache-2.0", uri("https://www.apache.org/licenses/LICENSE-2.0.html"))), // on the web - homepage := Some(url(s"https://github.com/playframework/$repoName")), + homepage := Some(uri(s"https://github.com/playframework/$repoName")), scmInfo := Some( ScmInfo( - url(s"https://github.com/playframework/$repoName"), + uri(s"https://github.com/playframework/$repoName"), s"scm:git:git@github.com:playframework/$repoName.git" ) ), @@ -43,11 +43,11 @@ object Common extends AutoPlugin { "playframework", "The Play Framework Contributors", "contact@playframework.com", - url("https://github.com/playframework") + uri("https://github.com/playframework") ) ) - override def projectSettings: Seq[Def.Setting[_]] = + override def projectSettings: Seq[Def.Setting[?]] = Seq( headerLicense := Some( HeaderLicense.Custom( diff --git a/project/build.properties b/project/build.properties index 24f46a50..d75cc0e5 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1,3 +1,3 @@ # Copyright (C) from 2022 The Play Framework Contributors , 2011-2021 Lightbend Inc. -sbt.version=1.13.0 +sbt.version=2.0.8