Skip to content
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

Support scala3 #301

Merged
merged 5 commits into from
Jan 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
12 changes: 11 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
scala: [2.12.18, 2.13.12]
scala: [2.12.18, 3.3.1, 2.13.12]
java: [temurin@11]
runs-on: ${{ matrix.os }}
steps:
Expand Down Expand Up @@ -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.12)
uses: actions/download-artifact@v2
with:
Expand Down
1 change: 1 addition & 0 deletions .mergify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ pull_request_rules:
- author=scala-steward
- author=nafg-scala-steward[bot]
- check-success=Build and Test (ubuntu-latest, 2.12.18, temurin@11)
- check-success=Build and Test (ubuntu-latest, 3.3.1, temurin@11)
- check-success=Build and Test (ubuntu-latest, 2.13.12, temurin@11)
actions:
queue:
Expand Down
6 changes: 3 additions & 3 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
inThisBuild(List(
crossScalaVersions := Seq("2.12.18", "2.13.12"),
crossScalaVersions := Seq("2.12.18", "3.3.1", "2.13.12"),
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.10.0-M1"

libraryDependencies += "org.flywaydb" % "flyway-core" % "9.22.3"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
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

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()
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,22 @@ 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


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: 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)) {
override def createSession() = new UnmanagedSession(this)
extends JdbcBackend.JdbcDatabaseDef(new UnmanagedJdbcDataSource(conn), AsyncExecutor("UnmanagedDatabase-AsyncExecutor", 1, -1)) {
override def createSession(): UnmanagedSession = new UnmanagedSession(this)
}
Loading