From e8fbd5dc24f5b4c06876f52bf7c2c7f5e6eab17a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Ferreira?= Date: Fri, 13 Oct 2023 22:50:45 +0100 Subject: [PATCH 1/4] scala3 support --- build.sbt | 6 +++--- .../slick/migration/api/flyway/UnmanagedDatabase.scala | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/build.sbt b/build.sbt index bc785a6..72b5ade 100644 --- a/build.sbt +++ b/build.sbt @@ -1,14 +1,14 @@ inThisBuild(List( - crossScalaVersions := Seq("2.12.17", "2.13.10"), + crossScalaVersions := Seq("2.12.17", "3.3.1", "2.13.10"), scalaVersion := crossScalaVersions.value.last, organization := "io.github.nafg.slick-migration-api" )) name := "slick-migration-api-flyway" -scalacOptions += "-deprecation" +scalacOptions ++= Seq("-feature", "-deprecation", "-Xsource:3") -libraryDependencies += "io.github.nafg.slick-migration-api" %% "slick-migration-api" % "0.9.0" +libraryDependencies += "io.github.nafg.slick-migration-api" %% "slick-migration-api" % "0.9.0+171-ccfb34ee-SNAPSHOT" libraryDependencies += "org.flywaydb" % "flyway-core" % "9.22.3" diff --git a/src/main/scala/slick/migration/api/flyway/UnmanagedDatabase.scala b/src/main/scala/slick/migration/api/flyway/UnmanagedDatabase.scala index a5ba41f..2141b8e 100644 --- a/src/main/scala/slick/migration/api/flyway/UnmanagedDatabase.scala +++ b/src/main/scala/slick/migration/api/flyway/UnmanagedDatabase.scala @@ -2,7 +2,7 @@ package slick.migration.api.flyway import java.sql.Connection -import slick.jdbc.JdbcBackend.{BaseSession, DatabaseDef} +import slick.jdbc.JdbcBackend.BaseSession import slick.jdbc.{JdbcBackend, JdbcDataSource} import slick.util.AsyncExecutor @@ -13,11 +13,11 @@ class UnmanagedJdbcDataSource(conn: Connection) extends JdbcDataSource { override val maxConnections = None } -class UnmanagedSession(database: DatabaseDef) extends BaseSession(database) { +class UnmanagedSession(database: JdbcBackend.Database) extends BaseSession(database) { override def close(): Unit = () } class UnmanagedDatabase(conn: Connection) - extends JdbcBackend.DatabaseDef(new UnmanagedJdbcDataSource(conn), AsyncExecutor("UnmanagedDatabase-AsyncExecutor", 1, -1)) { + extends JdbcBackend.JdbcDatabaseDef(new UnmanagedJdbcDataSource(conn), AsyncExecutor("UnmanagedDatabase-AsyncExecutor", 1, -1)) { override def createSession() = new UnmanagedSession(this) } From e98fd1b1fa72e933124410f8ccf5073d1079334a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Ferreira?= Date: Fri, 22 Dec 2023 14:42:32 +0000 Subject: [PATCH 2/4] use released version --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index 72b5ade..0c4c213 100644 --- a/build.sbt +++ b/build.sbt @@ -8,7 +8,7 @@ name := "slick-migration-api-flyway" scalacOptions ++= Seq("-feature", "-deprecation", "-Xsource:3") -libraryDependencies += "io.github.nafg.slick-migration-api" %% "slick-migration-api" % "0.9.0+171-ccfb34ee-SNAPSHOT" +libraryDependencies += "io.github.nafg.slick-migration-api" %% "slick-migration-api" % "0.10.0-M1" libraryDependencies += "org.flywaydb" % "flyway-core" % "9.22.3" From 8aa8433aa527405c45eb27ae502efd72edbfddfc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Ferreira?= Date: Fri, 22 Dec 2023 14:44:36 +0000 Subject: [PATCH 3/4] githubWorkflowGenerate --- .github/workflows/ci.yml | 12 +++++++++++- .mergify.yml | 1 + 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a28d0be..c9c99f4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -23,7 +23,7 @@ jobs: strategy: matrix: os: [ubuntu-latest] - scala: [2.12.17, 2.13.10] + scala: [2.12.17, 3.3.1, 2.13.10] java: [temurin@11] runs-on: ${{ matrix.os }} steps: @@ -111,6 +111,16 @@ jobs: tar xf targets.tar rm targets.tar + - name: Download target directories (3.3.1) + uses: actions/download-artifact@v2 + with: + name: target-${{ matrix.os }}-3.3.1-${{ matrix.java }} + + - name: Inflate target directories (3.3.1) + run: | + tar xf targets.tar + rm targets.tar + - name: Download target directories (2.13.10) uses: actions/download-artifact@v2 with: diff --git a/.mergify.yml b/.mergify.yml index ecfc75f..4c90de3 100644 --- a/.mergify.yml +++ b/.mergify.yml @@ -9,6 +9,7 @@ pull_request_rules: - author=scala-steward - author=nafg-scala-steward[bot] - check-success=Build and Test (ubuntu-latest, 2.12.17, temurin@11) + - check-success=Build and Test (ubuntu-latest, 3.3.1, temurin@11) - check-success=Build and Test (ubuntu-latest, 2.13.10, temurin@11) actions: queue: From ba103fc475f2933ee4932fba7d7efed1040f6fd3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Ferreira?= Date: Tue, 26 Dec 2023 14:23:42 +0000 Subject: [PATCH 4/4] fix inferred types in scala2 vs scala3 --- .../api/flyway/DatabaseDatasource.scala | 17 +++++++++-------- .../api/flyway/ExplicitMigrationResolver.scala | 4 +--- .../api/flyway/UnmanagedDatabase.scala | 6 +++--- 3 files changed, 13 insertions(+), 14 deletions(-) diff --git a/src/main/scala/slick/migration/api/flyway/DatabaseDatasource.scala b/src/main/scala/slick/migration/api/flyway/DatabaseDatasource.scala index 5d0bb78..e3c5621 100644 --- a/src/main/scala/slick/migration/api/flyway/DatabaseDatasource.scala +++ b/src/main/scala/slick/migration/api/flyway/DatabaseDatasource.scala @@ -1,7 +1,8 @@ package slick.migration.api.flyway import java.io.PrintWriter -import java.sql.{DriverManager, SQLException, SQLFeatureNotSupportedException} +import java.sql.{Connection, DriverManager, SQLException, SQLFeatureNotSupportedException} +import java.util.logging.Logger import slick.jdbc.JdbcBackend @@ -9,15 +10,15 @@ import javax.sql.DataSource class DatabaseDatasource(database: JdbcBackend#Database) extends DataSource { - override def getConnection = database.createSession().conn - override def getConnection(username: String, password: String) = throw new SQLFeatureNotSupportedException() - override def unwrap[T](iface: Class[T]) = + override def getConnection(): Connection = database.createSession().conn + override def getConnection(username: String, password: String): Connection = throw new SQLFeatureNotSupportedException() + override def unwrap[T](iface: Class[T]): T = if (iface.isInstance(this)) this.asInstanceOf[T] else throw new SQLException(getClass.getName + " is not a wrapper for " + iface) - override def isWrapperFor(iface: Class[_]) = iface.isInstance(this) - override def getLogWriter = throw new SQLFeatureNotSupportedException() + override def isWrapperFor(iface: Class[_]): Boolean = iface.isInstance(this) + override def getLogWriter: PrintWriter = throw new SQLFeatureNotSupportedException() override def setLogWriter(out: PrintWriter): Unit = throw new SQLFeatureNotSupportedException() override def setLoginTimeout(seconds: Int): Unit = DriverManager.setLoginTimeout(seconds) - override def getLoginTimeout = DriverManager.getLoginTimeout - override def getParentLogger = throw new SQLFeatureNotSupportedException() + override def getLoginTimeout: Int = DriverManager.getLoginTimeout + override def getParentLogger: Logger = throw new SQLFeatureNotSupportedException() } diff --git a/src/main/scala/slick/migration/api/flyway/ExplicitMigrationResolver.scala b/src/main/scala/slick/migration/api/flyway/ExplicitMigrationResolver.scala index bf25008..3636d37 100644 --- a/src/main/scala/slick/migration/api/flyway/ExplicitMigrationResolver.scala +++ b/src/main/scala/slick/migration/api/flyway/ExplicitMigrationResolver.scala @@ -2,10 +2,8 @@ package slick.migration.api.flyway import scala.collection.JavaConverters._ import org.flywaydb.core.api.resolver.MigrationResolver.Context - import org.flywaydb.core.api.resolver.{MigrationResolver, ResolvedMigration} - case class ExplicitMigrationResolver(migrations: ResolvedMigration*) extends MigrationResolver { - override def resolveMigrations(context: Context) = migrations.asJava + override def resolveMigrations(context: Context): java.util.Collection[ResolvedMigration] = migrations.asJava } diff --git a/src/main/scala/slick/migration/api/flyway/UnmanagedDatabase.scala b/src/main/scala/slick/migration/api/flyway/UnmanagedDatabase.scala index 2141b8e..a0aef2a 100644 --- a/src/main/scala/slick/migration/api/flyway/UnmanagedDatabase.scala +++ b/src/main/scala/slick/migration/api/flyway/UnmanagedDatabase.scala @@ -8,9 +8,9 @@ import slick.util.AsyncExecutor class UnmanagedJdbcDataSource(conn: Connection) extends JdbcDataSource { - override def createConnection() = conn + override def createConnection(): Connection = conn override def close(): Unit = () - override val maxConnections = None + override val maxConnections: Option[Int] = None } class UnmanagedSession(database: JdbcBackend.Database) extends BaseSession(database) { @@ -19,5 +19,5 @@ class UnmanagedSession(database: JdbcBackend.Database) extends BaseSession(datab class UnmanagedDatabase(conn: Connection) extends JdbcBackend.JdbcDatabaseDef(new UnmanagedJdbcDataSource(conn), AsyncExecutor("UnmanagedDatabase-AsyncExecutor", 1, -1)) { - override def createSession() = new UnmanagedSession(this) + override def createSession(): UnmanagedSession = new UnmanagedSession(this) }