From f6653ae0c70c86636712667811cd45bc3d8c0500 Mon Sep 17 00:00:00 2001 From: Barry O'Neill Date: Tue, 26 Nov 2024 16:13:41 -0500 Subject: [PATCH 1/2] move to sbt defaults --- .gitignore | 39 +++++++- .scalafmt.conf | 17 +++- LICENSE | 21 +++++ .../mysql/binlog/models/BinaryLogs.scala | 6 +- .../binlog/models/DeleteRowsEventData.scala | 4 +- .../mysql/binlog/models/EventHeaderV4.scala | 2 +- .../mysql/binlog/models/QueryEventData.scala | 2 +- .../mysql/binlog/models/RotateEventData.scala | 2 +- .../mysql/binlog/models/SchemaMetadata.scala | 4 +- .../binlog/models/TableMapEventData.scala | 2 +- .../binlog/models/UpdateRowsEventData.scala | 4 +- .../binlog/models/WriteRowsEventData.scala | 4 +- .../mysql/binlog/models/XidEventData.scala | 2 +- .../mysql/binlog/client/package.scala | 2 +- .../mysql/binlog/compaction/package.scala | 2 +- .../mysql/binlog/database/database.scala | 4 +- .../binlog/stream/MysqlBinlogStream.scala | 2 +- .../binlog/stream/TransactionState.scala | 6 +- .../mysql/binlog/stream/package.scala | 6 +- .../mysql/binlog/stream/MultiSchemaTest.scala | 2 +- .../binlog/stream/MysqlBinlogStreamTest.scala | 2 +- .../mysql/binlog/stream/PipesTest.scala | 4 +- .../laserdisc/mysql/binlog/stream/Sku.scala | 2 +- .../binlog/stream/TransactionStateTest.scala | 6 +- build.sbt | 32 ++----- .../src/main/scala/main/BinLogListener.scala | 8 +- .../io/laserdisc/mysql/json/package.scala | 4 +- .../test/scala/db/MySqlContainerTest.scala | 4 +- .../mysql/binlog/event/EventMessageTest.scala | 2 +- .../mysql/binlog/event/OffsetTest.scala | 2 +- project/BuildOptions.scala | 71 -------------- project/Dependencies.scala | 94 ++++++++----------- project/build.properties | 14 ++- project/plugins.sbt | 9 +- 34 files changed, 183 insertions(+), 204 deletions(-) create mode 100644 LICENSE delete mode 100644 project/BuildOptions.scala diff --git a/.gitignore b/.gitignore index 1e1b0b5..373499d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,42 @@ +# ------------------ autogenerated file - do not edit ------------------- +# This file was generated by sbt-laserdisc-defaults +# +# Please check in any changes generated in this file (for IDE support) +# +# To make changes, please publish a new version of the plugin at: +# https://github.com/laserdisc-io/sbt-laserdisc-defaults +# +# To temporarily disable generation, set this at the top of build.sbt: +# ThisBuild / laserdiscGitIgnoreGenOn := false +# ----------------------------------------------------------------------- + +# tip: use a "global" gitignore (core.excludesfile) for your own, local, personal preferences +# See: https://gist.github.com/subfuzion/db7f57fff2fb6998a16c + +# scala / sbt / java +project/project/ +project/target/ target/ +.sbtopts +.tasty + +# intellij .idea/ +*.iml + +# metals / bsp +.metals/ +.bloop/ .bsp/ -.DS_Store +project/metals.sbt + +# vscode +.vscode/ + +# terraform +.terraform/ +*.tfplan +*.terraform.lock.hcl +# mac +.DS_Store \ No newline at end of file diff --git a/.scalafmt.conf b/.scalafmt.conf index 8d8e3c6..34ae598 100644 --- a/.scalafmt.conf +++ b/.scalafmt.conf @@ -1,12 +1,25 @@ +# ------------------ autogenerated file - do not edit ------------------- +# This file was generated by sbt-laserdisc-defaults +# +# Please check in any changes generated in this file (for IDE support) +# +# To make changes, please publish a new version of the plugin at: +# https://github.com/laserdisc-io/sbt-laserdisc-defaults +# +# To temporarily disable generation, set this at the top of build.sbt: +# ThisBuild / laserdiscScalaFmtGenOn := false +# ----------------------------------------------------------------------- + version=3.8.3 maxColumn = 140 style = default align.preset = more -runner.dialect = scala213source3 +project.layout = StandardConvention +runner.dialect = scala3 fileOverride { - "glob:**/scala-3/**" { runner.dialect = scala3 } + "lang:scala-2" = scala213source3 } danglingParentheses.preset = true diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..ad3d630 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2020 Dmytro Semenov & Barry O'Neill + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/binlog-stream-models/src/main/scala/io/laserdisc/mysql/binlog/models/BinaryLogs.scala b/binlog-stream-models/src/main/scala/io/laserdisc/mysql/binlog/models/BinaryLogs.scala index 73db3b1..6235b14 100644 --- a/binlog-stream-models/src/main/scala/io/laserdisc/mysql/binlog/models/BinaryLogs.scala +++ b/binlog-stream-models/src/main/scala/io/laserdisc/mysql/binlog/models/BinaryLogs.scala @@ -1,8 +1,8 @@ package io.laserdisc.mysql.binlog.models -import cats.implicits.* -import doobie.* -import doobie.implicits.* +import cats.implicits._ +import doobie._ +import doobie.implicits._ import cats.effect.MonadCancel case class BinaryLogs(fileName: String, size: Long) diff --git a/binlog-stream-models/src/main/scala/io/laserdisc/mysql/binlog/models/DeleteRowsEventData.scala b/binlog-stream-models/src/main/scala/io/laserdisc/mysql/binlog/models/DeleteRowsEventData.scala index 32db38f..8f2b4e3 100644 --- a/binlog-stream-models/src/main/scala/io/laserdisc/mysql/binlog/models/DeleteRowsEventData.scala +++ b/binlog-stream-models/src/main/scala/io/laserdisc/mysql/binlog/models/DeleteRowsEventData.scala @@ -1,8 +1,8 @@ package io.laserdisc.mysql.binlog.models -import com.github.shyiko.mysql.binlog.event.DeleteRowsEventData as JDeleteRowsEventData +import com.github.shyiko.mysql.binlog.event.{DeleteRowsEventData => JDeleteRowsEventData} -import scala.jdk.CollectionConverters.* +import scala.jdk.CollectionConverters._ object DeleteRowsEventData { def unapply(arg: JDeleteRowsEventData): Option[(Long, List[Array[Serializable]], Array[Int])] = Some((arg.getTableId, arg.getRows.asScala.toList, arg.getIncludedColumns.stream().toArray)) diff --git a/binlog-stream-models/src/main/scala/io/laserdisc/mysql/binlog/models/EventHeaderV4.scala b/binlog-stream-models/src/main/scala/io/laserdisc/mysql/binlog/models/EventHeaderV4.scala index b10b02f..f7b3ae2 100644 --- a/binlog-stream-models/src/main/scala/io/laserdisc/mysql/binlog/models/EventHeaderV4.scala +++ b/binlog-stream-models/src/main/scala/io/laserdisc/mysql/binlog/models/EventHeaderV4.scala @@ -1,6 +1,6 @@ package io.laserdisc.mysql.binlog.models -import com.github.shyiko.mysql.binlog.event.{EventHeaderV4 as JEventHeaderV4, EventType} +import com.github.shyiko.mysql.binlog.event.{EventHeaderV4 => JEventHeaderV4, EventType} object EventHeaderV4 { def unapply(arg: JEventHeaderV4): Option[(EventType, Long, Long)] = diff --git a/binlog-stream-models/src/main/scala/io/laserdisc/mysql/binlog/models/QueryEventData.scala b/binlog-stream-models/src/main/scala/io/laserdisc/mysql/binlog/models/QueryEventData.scala index d66a20a..e21f54a 100644 --- a/binlog-stream-models/src/main/scala/io/laserdisc/mysql/binlog/models/QueryEventData.scala +++ b/binlog-stream-models/src/main/scala/io/laserdisc/mysql/binlog/models/QueryEventData.scala @@ -1,6 +1,6 @@ package io.laserdisc.mysql.binlog.models -import com.github.shyiko.mysql.binlog.event.QueryEventData as JQueryEventData +import com.github.shyiko.mysql.binlog.event.{QueryEventData => JQueryEventData} object QueryEventData { def truncateTable(sql: String) = { diff --git a/binlog-stream-models/src/main/scala/io/laserdisc/mysql/binlog/models/RotateEventData.scala b/binlog-stream-models/src/main/scala/io/laserdisc/mysql/binlog/models/RotateEventData.scala index 824a95f..ed9e8dc 100644 --- a/binlog-stream-models/src/main/scala/io/laserdisc/mysql/binlog/models/RotateEventData.scala +++ b/binlog-stream-models/src/main/scala/io/laserdisc/mysql/binlog/models/RotateEventData.scala @@ -1,6 +1,6 @@ package io.laserdisc.mysql.binlog.models -import com.github.shyiko.mysql.binlog.event.RotateEventData as JRotateEventData +import com.github.shyiko.mysql.binlog.event.{RotateEventData => JRotateEventData} object RotateEventData { def unapply(arg: JRotateEventData): Option[(String, Long)] = diff --git a/binlog-stream-models/src/main/scala/io/laserdisc/mysql/binlog/models/SchemaMetadata.scala b/binlog-stream-models/src/main/scala/io/laserdisc/mysql/binlog/models/SchemaMetadata.scala index c40ce8a..6a11135 100644 --- a/binlog-stream-models/src/main/scala/io/laserdisc/mysql/binlog/models/SchemaMetadata.scala +++ b/binlog-stream-models/src/main/scala/io/laserdisc/mysql/binlog/models/SchemaMetadata.scala @@ -1,7 +1,7 @@ package io.laserdisc.mysql.binlog.models -import doobie.* -import doobie.implicits.* +import doobie._ +import doobie.implicits._ import scala.collection.mutable import cats.effect.MonadCancel diff --git a/binlog-stream-models/src/main/scala/io/laserdisc/mysql/binlog/models/TableMapEventData.scala b/binlog-stream-models/src/main/scala/io/laserdisc/mysql/binlog/models/TableMapEventData.scala index 9bf22c8..998848e 100644 --- a/binlog-stream-models/src/main/scala/io/laserdisc/mysql/binlog/models/TableMapEventData.scala +++ b/binlog-stream-models/src/main/scala/io/laserdisc/mysql/binlog/models/TableMapEventData.scala @@ -1,6 +1,6 @@ package io.laserdisc.mysql.binlog.models -import com.github.shyiko.mysql.binlog.event.TableMapEventData as JTableMapEventData +import com.github.shyiko.mysql.binlog.event.{TableMapEventData => JTableMapEventData} object TableMapEventData { def unapply(arg: JTableMapEventData): Option[(Long, String, String)] = diff --git a/binlog-stream-models/src/main/scala/io/laserdisc/mysql/binlog/models/UpdateRowsEventData.scala b/binlog-stream-models/src/main/scala/io/laserdisc/mysql/binlog/models/UpdateRowsEventData.scala index 5346085..c6977a5 100644 --- a/binlog-stream-models/src/main/scala/io/laserdisc/mysql/binlog/models/UpdateRowsEventData.scala +++ b/binlog-stream-models/src/main/scala/io/laserdisc/mysql/binlog/models/UpdateRowsEventData.scala @@ -1,8 +1,8 @@ package io.laserdisc.mysql.binlog.models -import com.github.shyiko.mysql.binlog.event.UpdateRowsEventData as JUpdateRowsEventData +import com.github.shyiko.mysql.binlog.event.{UpdateRowsEventData => JUpdateRowsEventData} -import scala.jdk.CollectionConverters.* +import scala.jdk.CollectionConverters._ object UpdateRowsEventData { def unapply( diff --git a/binlog-stream-models/src/main/scala/io/laserdisc/mysql/binlog/models/WriteRowsEventData.scala b/binlog-stream-models/src/main/scala/io/laserdisc/mysql/binlog/models/WriteRowsEventData.scala index 2102331..34a5fed 100644 --- a/binlog-stream-models/src/main/scala/io/laserdisc/mysql/binlog/models/WriteRowsEventData.scala +++ b/binlog-stream-models/src/main/scala/io/laserdisc/mysql/binlog/models/WriteRowsEventData.scala @@ -1,8 +1,8 @@ package io.laserdisc.mysql.binlog.models -import com.github.shyiko.mysql.binlog.event.WriteRowsEventData as JWriteRowsEventData +import com.github.shyiko.mysql.binlog.event.{WriteRowsEventData => JWriteRowsEventData} -import scala.jdk.CollectionConverters.* +import scala.jdk.CollectionConverters._ object WriteRowsEventData { def unapply(arg: JWriteRowsEventData): Option[(Long, List[Array[Serializable]], Array[Int])] = diff --git a/binlog-stream-models/src/main/scala/io/laserdisc/mysql/binlog/models/XidEventData.scala b/binlog-stream-models/src/main/scala/io/laserdisc/mysql/binlog/models/XidEventData.scala index 4e84e1f..181cd22 100644 --- a/binlog-stream-models/src/main/scala/io/laserdisc/mysql/binlog/models/XidEventData.scala +++ b/binlog-stream-models/src/main/scala/io/laserdisc/mysql/binlog/models/XidEventData.scala @@ -1,6 +1,6 @@ package io.laserdisc.mysql.binlog.models -import com.github.shyiko.mysql.binlog.event.XidEventData as JXidEventData +import com.github.shyiko.mysql.binlog.event.{XidEventData => JXidEventData} object XidEventData { def unapply(arg: JXidEventData): Option[Long] = Some(arg.getXid) diff --git a/binlog-stream/src/main/scala/io/laserdisc/mysql/binlog/client/package.scala b/binlog-stream/src/main/scala/io/laserdisc/mysql/binlog/client/package.scala index e6825ba..7960f63 100644 --- a/binlog-stream/src/main/scala/io/laserdisc/mysql/binlog/client/package.scala +++ b/binlog-stream/src/main/scala/io/laserdisc/mysql/binlog/client/package.scala @@ -1,7 +1,7 @@ package io.laserdisc.mysql.binlog import cats.effect.Sync -import cats.implicits.* +import cats.implicits._ import com.github.shyiko.mysql.binlog.BinaryLogClient import io.laserdisc.mysql.binlog.checkpoint.BinlogOffset import io.laserdisc.mysql.binlog.config.{BinLogConfig, BinLogConfigOps} diff --git a/binlog-stream/src/main/scala/io/laserdisc/mysql/binlog/compaction/package.scala b/binlog-stream/src/main/scala/io/laserdisc/mysql/binlog/compaction/package.scala index 2234a27..a769fee 100644 --- a/binlog-stream/src/main/scala/io/laserdisc/mysql/binlog/compaction/package.scala +++ b/binlog-stream/src/main/scala/io/laserdisc/mysql/binlog/compaction/package.scala @@ -1,7 +1,7 @@ package io.laserdisc.mysql.binlog import cats.data.Kleisli -import cats.implicits.* +import cats.implicits._ import io.circe.Json import io.laserdisc.mysql.binlog.event.EventMessage import io.laserdisc.mysql.json diff --git a/binlog-stream/src/main/scala/io/laserdisc/mysql/binlog/database/database.scala b/binlog-stream/src/main/scala/io/laserdisc/mysql/binlog/database/database.scala index 05d3148..449c1f3 100644 --- a/binlog-stream/src/main/scala/io/laserdisc/mysql/binlog/database/database.scala +++ b/binlog-stream/src/main/scala/io/laserdisc/mysql/binlog/database/database.scala @@ -1,7 +1,7 @@ package io.laserdisc.mysql.binlog -import cats.effect.* -import doobie.* +import cats.effect._ +import doobie._ import doobie.hikari.HikariTransactor import io.laserdisc.mysql.binlog.config.BinLogConfig diff --git a/binlog-stream/src/main/scala/io/laserdisc/mysql/binlog/stream/MysqlBinlogStream.scala b/binlog-stream/src/main/scala/io/laserdisc/mysql/binlog/stream/MysqlBinlogStream.scala index 523f7f7..2e3f17e 100644 --- a/binlog-stream/src/main/scala/io/laserdisc/mysql/binlog/stream/MysqlBinlogStream.scala +++ b/binlog-stream/src/main/scala/io/laserdisc/mysql/binlog/stream/MysqlBinlogStream.scala @@ -2,7 +2,7 @@ package io.laserdisc.mysql.binlog.stream import cats.effect.std.{Dispatcher, Queue} import cats.effect.{Async, IO, LiftIO} -import cats.implicits.* +import cats.implicits._ import com.github.shyiko.mysql.binlog.BinaryLogClient import com.github.shyiko.mysql.binlog.event.Event import fs2.Stream diff --git a/binlog-stream/src/main/scala/io/laserdisc/mysql/binlog/stream/TransactionState.scala b/binlog-stream/src/main/scala/io/laserdisc/mysql/binlog/stream/TransactionState.scala index 2f6bde0..589c5ce 100644 --- a/binlog-stream/src/main/scala/io/laserdisc/mysql/binlog/stream/TransactionState.scala +++ b/binlog-stream/src/main/scala/io/laserdisc/mysql/binlog/stream/TransactionState.scala @@ -2,14 +2,14 @@ package io.laserdisc.mysql.binlog.stream import cats.data.State import cats.effect.{Ref, Sync} -import cats.implicits.* +import cats.implicits._ import com.github.shyiko.mysql.binlog.BinaryLogClient import com.github.shyiko.mysql.binlog.event.EventType.{EXT_UPDATE_ROWS, UPDATE_ROWS} import com.github.shyiko.mysql.binlog.event.deserialization.json.JsonBinary -import com.github.shyiko.mysql.binlog.event.{Event, EventData, EventHeaderV4 as JEventHeaderV4, EventType} +import com.github.shyiko.mysql.binlog.event.{Event, EventData, EventHeaderV4 => JEventHeaderV4, EventType} import io.circe.Json import io.laserdisc.mysql.binlog.event.EventMessage -import io.laserdisc.mysql.binlog.models.* +import io.laserdisc.mysql.binlog.models._ import org.typelevel.log4cats.Logger import java.math.BigDecimal diff --git a/binlog-stream/src/main/scala/io/laserdisc/mysql/binlog/stream/package.scala b/binlog-stream/src/main/scala/io/laserdisc/mysql/binlog/stream/package.scala index 468c09a..635cfda 100644 --- a/binlog-stream/src/main/scala/io/laserdisc/mysql/binlog/stream/package.scala +++ b/binlog-stream/src/main/scala/io/laserdisc/mysql/binlog/stream/package.scala @@ -2,7 +2,7 @@ package io.laserdisc.mysql.binlog import cats.effect.kernel.Ref import cats.effect.{Concurrent, Sync} -import cats.implicits.* +import cats.implicits._ import com.github.shyiko.mysql.binlog.event.Event import org.typelevel.log4cats.Logger import io.laserdisc.mysql.binlog.event.EventMessage @@ -13,14 +13,14 @@ package object stream { schema: String ): fs2.Pipe[F, Event, EventMessage] = _.through(streamTransactionPackages[F](transactionState, schema)).flatMap(pkg => - fs2.Stream.eval(warnBigTransactionPackage(pkg)) >> fs2.Stream(pkg.events*) + fs2.Stream.eval(warnBigTransactionPackage(pkg)) >> fs2.Stream(pkg.events: _*) ) def streamCompactedEvents[F[_]: Concurrent: Logger]( transactionState: Ref[F, TransactionState], schema: String ): fs2.Pipe[F, Event, EventMessage] = - _.through(streamTransactionPackages[F](transactionState, schema)).flatMap(pkg => fs2.Stream(compaction.compact(pkg.events)*)) + _.through(streamTransactionPackages[F](transactionState, schema)).flatMap(pkg => fs2.Stream(compaction.compact(pkg.events): _*)) def streamTransactionPackages[F[_]: Concurrent: Logger]( transactionState: Ref[F, TransactionState], diff --git a/binlog-stream/src/test/scala/io/laserdisc/mysql/binlog/stream/MultiSchemaTest.scala b/binlog-stream/src/test/scala/io/laserdisc/mysql/binlog/stream/MultiSchemaTest.scala index 94747cb..6c75884 100644 --- a/binlog-stream/src/test/scala/io/laserdisc/mysql/binlog/stream/MultiSchemaTest.scala +++ b/binlog-stream/src/test/scala/io/laserdisc/mysql/binlog/stream/MultiSchemaTest.scala @@ -5,7 +5,7 @@ import cats.effect.unsafe.implicits.global import com.dimafeng.testcontainers.ForAllTestContainer import com.github.shyiko.mysql.binlog.BinaryLogClient import db.MySqlContainerTest -import doobie.implicits.* +import doobie.implicits._ import io.circe.optics.JsonPath.root import io.laserdisc.mysql.binlog.database import io.laserdisc.mysql.binlog.config.BinLogConfigOps diff --git a/binlog-stream/src/test/scala/io/laserdisc/mysql/binlog/stream/MysqlBinlogStreamTest.scala b/binlog-stream/src/test/scala/io/laserdisc/mysql/binlog/stream/MysqlBinlogStreamTest.scala index fba2c49..cde5b4c 100644 --- a/binlog-stream/src/test/scala/io/laserdisc/mysql/binlog/stream/MysqlBinlogStreamTest.scala +++ b/binlog-stream/src/test/scala/io/laserdisc/mysql/binlog/stream/MysqlBinlogStreamTest.scala @@ -7,7 +7,7 @@ import com.github.shyiko.mysql.binlog.BinaryLogClient import com.github.shyiko.mysql.binlog.event.{EventHeaderV4, EventType} import db.MySqlContainerTest import doobie.hikari.HikariTransactor -import doobie.implicits.* +import doobie.implicits._ import io.laserdisc.mysql.binlog.config.BinLogConfigOps import io.laserdisc.mysql.binlog.database import org.scalatest.matchers.should.Matchers diff --git a/binlog-stream/src/test/scala/io/laserdisc/mysql/binlog/stream/PipesTest.scala b/binlog-stream/src/test/scala/io/laserdisc/mysql/binlog/stream/PipesTest.scala index 1021775..8b32d75 100644 --- a/binlog-stream/src/test/scala/io/laserdisc/mysql/binlog/stream/PipesTest.scala +++ b/binlog-stream/src/test/scala/io/laserdisc/mysql/binlog/stream/PipesTest.scala @@ -2,12 +2,12 @@ package io.laserdisc.mysql.binlog.stream import cats.effect.unsafe.implicits.global import cats.effect.{IO, Resource} -import cats.implicits.* +import cats.implicits._ import com.dimafeng.testcontainers.ForAllTestContainer import com.github.shyiko.mysql.binlog.BinaryLogClient import db.MySqlContainerTest import doobie.hikari.HikariTransactor -import doobie.implicits.* +import doobie.implicits._ import org.typelevel.log4cats.Logger import org.typelevel.log4cats.slf4j.Slf4jLogger import io.laserdisc.mysql.binlog.database diff --git a/binlog-stream/src/test/scala/io/laserdisc/mysql/binlog/stream/Sku.scala b/binlog-stream/src/test/scala/io/laserdisc/mysql/binlog/stream/Sku.scala index ac4a205..26a0b7c 100644 --- a/binlog-stream/src/test/scala/io/laserdisc/mysql/binlog/stream/Sku.scala +++ b/binlog-stream/src/test/scala/io/laserdisc/mysql/binlog/stream/Sku.scala @@ -1,7 +1,7 @@ package io.laserdisc.mysql.binlog.stream import doobie.ConnectionIO -import doobie.implicits.* +import doobie.implicits._ import doobie.util.update.Update case class Sku(id: Int, sku: String) diff --git a/binlog-stream/src/test/scala/io/laserdisc/mysql/binlog/stream/TransactionStateTest.scala b/binlog-stream/src/test/scala/io/laserdisc/mysql/binlog/stream/TransactionStateTest.scala index 3814a31..47e66be 100644 --- a/binlog-stream/src/test/scala/io/laserdisc/mysql/binlog/stream/TransactionStateTest.scala +++ b/binlog-stream/src/test/scala/io/laserdisc/mysql/binlog/stream/TransactionStateTest.scala @@ -1,9 +1,9 @@ package io.laserdisc.mysql.binlog.stream -import _root_.io.circe.optics.JsonPath.* +import _root_.io.circe.optics.JsonPath._ import _root_.io.circe.Json -import _root_.io.laserdisc.mysql.binlog.* -import com.github.shyiko.mysql.binlog.event.* +import _root_.io.laserdisc.mysql.binlog._ +import com.github.shyiko.mysql.binlog.event._ import org.scalatest.OptionValues import org.scalatest.matchers.should.Matchers import org.scalatest.wordspec.AnyWordSpec diff --git a/build.sbt b/build.sbt index 7e3f5e3..318190f 100644 --- a/build.sbt +++ b/build.sbt @@ -1,26 +1,15 @@ -organization := "io.laserdisc" -name := "mysql-binlog-stream" +import laserdisc.sbt.CompileTarget.Scala2And3 +import laserdisc.sbt.LaserDiscDevelopers._ -lazy val scala213 = "2.13.14" -lazy val scala3 = "3.3.3" -lazy val supportedScalaVersions = List(scala213, scala3) +name := "mysql-binlog-stream" -ThisBuild / crossScalaVersions := supportedScalaVersions -ThisBuild / scalaVersion := scala3 +ThisBuild / laserdiscRepoName := "mysql-binlog-stream" +ThisBuild / laserdiscCompileTarget := Scala2And3 lazy val commonSettings = Seq( - organization := "io.laserdisc", - developers := List( - Developer("semenodm", "Dmytro Semenov", "sdo.semenov@gmail.com", url("https://github.com/semenodm")), - Developer("barryoneill", "Barry O'Neill", "", url("https://github.com/barryoneill")) - ), - licenses ++= Seq(("MIT", url("http://opensource.org/licenses/MIT"))), - homepage := Some(url("https://github.com/laserdisc-io/fs2-aws")), Test / parallelExecution := false, Test / fork := true, - Test / scalacOptions ++= BuildOptions.scalacTestOptions, - scalacOptions ++= BuildOptions.scalacOptions(scalaVersion.value), - libraryDependencies ++= BuildOptions.compilerPlugins(scalaVersion.value) + developers := List(Dmytro, Barry) ) lazy val noPublishSettings = Seq( @@ -43,7 +32,6 @@ lazy val dockerPublishSettings = Seq( lazy val root = project .in(file(".")) .settings(commonSettings) - .settings(crossScalaVersions := Nil) .settings(noPublishSettings) .aggregate( `mysql-binlog-stream-shared`, @@ -51,6 +39,7 @@ lazy val root = project `binlog-stream`, `mysql-binlog-stream-examples` ) + .enablePlugins(LaserDiscDefaultsPlugin) lazy val `mysql-binlog-stream-examples` = (project in file("mysql-binlog-stream-examples")) @@ -68,14 +57,9 @@ lazy val `mysql-binlog-stream-shared` = (project in file("mysql-binlog-stream-sh .settings( commonSettings, Dependencies.TestLib, - Dependencies.Circe, - Dependencies.Cats + Dependencies.Circe ) -addCommandAlias("build", ";checkFormat;clean;test;coverage") -addCommandAlias("format", ";scalafmtAll;scalafmtSbt") -addCommandAlias("checkFormat", ";scalafmtCheckAll;scalafmtSbtCheck") - lazy val `binlog-stream` = (project in file("binlog-stream")) .settings( commonSettings, diff --git a/mysql-binlog-stream-examples/src/main/scala/main/BinLogListener.scala b/mysql-binlog-stream-examples/src/main/scala/main/BinLogListener.scala index 8112f25..c8ca290 100644 --- a/mysql-binlog-stream-examples/src/main/scala/main/BinLogListener.scala +++ b/mysql-binlog-stream-examples/src/main/scala/main/BinLogListener.scala @@ -1,10 +1,10 @@ package main import cats.effect.{ExitCode, IO, IOApp} -import cats.implicits.* -import ciris.* -import ciris.refined.* -import eu.timepit.refined.auto.* +import cats.implicits._ +import ciris._ +import ciris.refined._ +import eu.timepit.refined.auto._ import eu.timepit.refined.types.string.TrimmedString import io.laserdisc.mysql.binlog.config.BinLogConfig import io.laserdisc.mysql.binlog.models.SchemaMetadata diff --git a/mysql-binlog-stream-shared/src/main/scala/io/laserdisc/mysql/json/package.scala b/mysql-binlog-stream-shared/src/main/scala/io/laserdisc/mysql/json/package.scala index bb0878d..86a538c 100644 --- a/mysql-binlog-stream-shared/src/main/scala/io/laserdisc/mysql/json/package.scala +++ b/mysql-binlog-stream-shared/src/main/scala/io/laserdisc/mysql/json/package.scala @@ -1,7 +1,7 @@ package io.laserdisc.mysql -import io.circe.* -import io.circe.parser.* +import io.circe._ +import io.circe.parser._ package object json { def flatHash(doc: String, removeKey: String = ""): Either[Exception, String] = diff --git a/mysql-binlog-stream-shared/src/test/scala/db/MySqlContainerTest.scala b/mysql-binlog-stream-shared/src/test/scala/db/MySqlContainerTest.scala index 6730937..ebc560b 100644 --- a/mysql-binlog-stream-shared/src/test/scala/db/MySqlContainerTest.scala +++ b/mysql-binlog-stream-shared/src/test/scala/db/MySqlContainerTest.scala @@ -1,6 +1,6 @@ package db -import com.dimafeng.testcontainers.* +import com.dimafeng.testcontainers._ import com.dimafeng.testcontainers.scalatest.TestContainersForAll import io.laserdisc.mysql.binlog.config.BinLogConfig import org.scalatest.{BeforeAndAfterEach, Suite} @@ -10,7 +10,7 @@ import org.testcontainers.utility.DockerImageName import java.net.URI import scala.concurrent.ExecutionContext import scala.concurrent.ExecutionContext.Implicits -import scala.jdk.CollectionConverters.* +import scala.jdk.CollectionConverters._ trait MySqlContainerTest extends TestContainersForAll with BeforeAndAfterEach { self: Suite => diff --git a/mysql-binlog-stream-shared/src/test/scala/io/laserdisc/mysql/binlog/event/EventMessageTest.scala b/mysql-binlog-stream-shared/src/test/scala/io/laserdisc/mysql/binlog/event/EventMessageTest.scala index f775fa4..e7d21af 100644 --- a/mysql-binlog-stream-shared/src/test/scala/io/laserdisc/mysql/binlog/event/EventMessageTest.scala +++ b/mysql-binlog-stream-shared/src/test/scala/io/laserdisc/mysql/binlog/event/EventMessageTest.scala @@ -9,7 +9,7 @@ class EventMessageTest extends AnyWordSpec with Matchers { "EventMessage" should { "be orderable by Offset" in { - import OffsetTest.* + import OffsetTest._ import OffsetOrdering.ordering evtMsg(FILE_A, offset = 123) should be < evtMsg(FILE_B, offset = 999) diff --git a/mysql-binlog-stream-shared/src/test/scala/io/laserdisc/mysql/binlog/event/OffsetTest.scala b/mysql-binlog-stream-shared/src/test/scala/io/laserdisc/mysql/binlog/event/OffsetTest.scala index 183b121..dc88f43 100644 --- a/mysql-binlog-stream-shared/src/test/scala/io/laserdisc/mysql/binlog/event/OffsetTest.scala +++ b/mysql-binlog-stream-shared/src/test/scala/io/laserdisc/mysql/binlog/event/OffsetTest.scala @@ -2,7 +2,7 @@ package io.laserdisc.mysql.binlog.event import org.scalatest.matchers.should.Matchers import org.scalatest.wordspec.AnyWordSpec -import OffsetTest.* +import OffsetTest._ object OffsetTest { val FILE_A = "mysql-bin-changelog.001450" diff --git a/project/BuildOptions.scala b/project/BuildOptions.scala deleted file mode 100644 index 56934fb..0000000 --- a/project/BuildOptions.scala +++ /dev/null @@ -1,71 +0,0 @@ -import sbt.* - -object BuildOptions { - - def scalacOptions(scalaVersion: String): Seq[String] = - Scalac.Common ++ (CrossVersion.partialVersion(scalaVersion) match { - case Some((3, _)) => Scalac.Version3x - case Some((2, _)) => Scalac.Version2x - case _ => Seq.empty - }) - - def scalacTestOptions: Seq[String] = Scalac.Test - - def compilerPlugins(scalaVersion: String): Seq[sbt.ModuleID] = - Compiler.Common ++ (CrossVersion.partialVersion(scalaVersion) match { - case Some((2, _)) => Compiler.Scala2x - case _ => Seq.empty - }) - - object Scalac { - - lazy val Common: Seq[String] = Seq( - "-encoding", - "UTF-8", - "-deprecation", - "-unchecked", - "-feature", - "-language:existentials,experimental.macros,higherKinds,implicitConversions,postfixOps", - "-Wconf:src=src_managed/.*:silent", - "-Xfatal-warnings" - ) - - lazy val Version3x: Seq[String] = Seq( - "-Yretain-trees", - "-Ykind-projector:underscores", - "-source:future", - "-language:adhocExtensions", - "-Wconf:msg=`= _` has been deprecated; use `= uninitialized` instead.:s" - ) - - lazy val Test: Seq[String] = Seq( - "-Wconf:msg=is not declared infix:s,msg=is declared 'open':s" - ) - - lazy val Version2x: Seq[String] = Seq( - "-Xlint:-unused,_", - "-Ywarn-numeric-widen", - "-Ywarn-value-discard", - "-Ywarn-unused:implicits", - "-Ywarn-unused:imports", - "-Xsource:3", - "-Xlint:_,-byname-implicit", // enable handy linter warnings except byname-implicit (see https://github.com/scala/bug/issues/12072) - "-P:kind-projector:underscore-placeholders", - "-Xlint", - "-Ywarn-macros:after" - ) - - } - - object Compiler { - - lazy val Common: Seq[ModuleID] = Seq("org.scala-lang.modules" %% "scala-collection-compat" % "2.12.0") - - lazy val Scala2x: Seq[ModuleID] = Seq( - compilerPlugin(("org.typelevel" %% "kind-projector" % "0.13.3").cross(CrossVersion.full)), - compilerPlugin("com.olegpy" %% "better-monadic-for" % "0.3.1") - ) - - } - -} diff --git a/project/Dependencies.scala b/project/Dependencies.scala index 331ce2c..11ee540 100644 --- a/project/Dependencies.scala +++ b/project/Dependencies.scala @@ -1,71 +1,55 @@ -import sbt.* +import sbt._ import sbt.Keys.libraryDependencies object Dependencies { - val cirisVersion = "3.6.0" - val doobieVersion = "1.0.0-RC6" - val circeVersion = "0.14.10" - val catsEffectVersion = "3.5.4" - - val TestLib = Seq( - libraryDependencies ++= Seq( - "org.scalamock" %% "scalamock" % "6.0.0" % Test, - "org.scalatest" %% "scalatest" % "3.2.19" % Test, - "com.dimafeng" %% "testcontainers-scala" % "0.41.4" % Test, - "org.testcontainers" % "mysql" % "1.20.2" % Test, - "org.testcontainers" % "testcontainers" % "1.20.2" % Test - ) + val cirisVersion = "3.6.0" + val doobieVersion = "1.0.0-RC6" + val circeVersion = "0.14.10" + + val TestLib = libraryDependencies ++= Seq( + "org.scalamock" %% "scalamock" % "6.0.0" % Test, + "org.scalatest" %% "scalatest" % "3.2.19" % Test, + "com.dimafeng" %% "testcontainers-scala" % "0.41.4" % Test, + "org.testcontainers" % "mysql" % "1.20.4" % Test, + "org.testcontainers" % "testcontainers" % "1.20.4" % Test ) - val Config = Seq( - libraryDependencies ++= Seq( - "is.cir" %% "ciris-enumeratum" % cirisVersion, - "is.cir" %% "ciris-refined" % cirisVersion, - "eu.timepit" %% "refined" % "0.11.2" - ) + val Config = libraryDependencies ++= Seq( + "is.cir" %% "ciris-enumeratum" % cirisVersion, + "is.cir" %% "ciris-refined" % cirisVersion, + "eu.timepit" %% "refined" % "0.11.2" ) - val Logging = Seq( - libraryDependencies ++= Seq( - "ch.qos.logback" % "logback-classic" % "1.5.9", - "ch.qos.logback" % "logback-core" % "1.5.9", - "org.slf4j" % "jcl-over-slf4j" % "2.0.16", - "org.slf4j" % "jul-to-slf4j" % "2.0.16", - "org.typelevel" %% "log4cats-slf4j" % "2.7.0" - ) + val Logging = libraryDependencies ++= Seq( + "ch.qos.logback" % "logback-classic" % "1.5.12", + "ch.qos.logback" % "logback-core" % "1.5.12", + "org.slf4j" % "jcl-over-slf4j" % "2.0.16", + "org.slf4j" % "jul-to-slf4j" % "2.0.16", + "org.typelevel" %% "log4cats-slf4j" % "2.7.0" ) - val Persistence = Seq( - libraryDependencies ++= Seq( - "org.tpolecat" %% "doobie-core" % doobieVersion, - "org.tpolecat" %% "doobie-hikari" % doobieVersion, - "org.tpolecat" %% "doobie-refined" % doobieVersion, - "org.tpolecat" %% "doobie-scalatest" % doobieVersion % Test, - "mysql" % "mysql-connector-java" % "8.0.33", - "com.zendesk" % "mysql-binlog-connector-java" % "0.29.2" - ) + val Persistence = libraryDependencies ++= Seq( + "org.tpolecat" %% "doobie-core" % doobieVersion, + "org.tpolecat" %% "doobie-hikari" % doobieVersion, + "org.tpolecat" %% "doobie-refined" % doobieVersion, + "org.tpolecat" %% "doobie-scalatest" % doobieVersion % Test, + "mysql" % "mysql-connector-java" % "8.0.33", + "com.zendesk" % "mysql-binlog-connector-java" % "0.30.1" ) - val Circe = Seq( - libraryDependencies ++= Seq( - "io.circe" %% "circe-core" % circeVersion, - "io.circe" %% "circe-parser" % circeVersion, - "io.circe" %% "circe-optics" % "0.15.0" % Test - ) + val Circe = libraryDependencies ++= Seq( + "io.circe" %% "circe-core" % circeVersion, + "io.circe" %% "circe-parser" % circeVersion, + "io.circe" %% "circe-optics" % "0.15.0" % Test ) - val Cats = Seq( - libraryDependencies ++= Seq( - "org.typelevel" %% "cats-effect" % catsEffectVersion - ) - ) +// val Cats = libraryDependencies ++= Seq("org.typelevel" %% "cats-effect" % "3.5.6") - val XML = Seq( - libraryDependencies ++= Seq( - "javax.xml.bind" % "jaxb-api" % "2.3.1", - "com.sun.xml.bind" % "jaxb-impl" % "4.0.5", - "com.sun.xml.bind" % "jaxb-core" % "4.0.5", - "javax.activation" % "activation" % "1.1.1" - ) + val XML = libraryDependencies ++= Seq( + "javax.xml.bind" % "jaxb-api" % "2.3.1", + "com.sun.xml.bind" % "jaxb-impl" % "4.0.5", + "com.sun.xml.bind" % "jaxb-core" % "4.0.5", + "javax.activation" % "activation" % "1.1.1" ) + } diff --git a/project/build.properties b/project/build.properties index 0b699c3..8bfed43 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1 +1,13 @@ -sbt.version=1.10.2 +# ------------------ autogenerated file - do not edit ------------------- +# This file was generated by sbt-laserdisc-defaults +# +# Please check in any changes generated in this file (for IDE support) +# +# To make changes, please publish a new version of the plugin at: +# https://github.com/laserdisc-io/sbt-laserdisc-defaults +# +# To temporarily disable generation, set this at the top of build.sbt: +# ThisBuild / laserdiscSBTVersionGenOn := false +# ----------------------------------------------------------------------- + +sbt.version = 1.10.5 \ No newline at end of file diff --git a/project/plugins.sbt b/project/plugins.sbt index 6308245..0cf5732 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,5 +1,4 @@ -addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.5.2") -addSbtPlugin("org.scoverage" % "sbt-coveralls" % "1.3.11") -addSbtPlugin("org.scoverage" % "sbt-scoverage" % "2.0.12") -addSbtPlugin("com.github.sbt" % "sbt-native-packager" % "1.10.0") -addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.5.12") +addSbtPlugin("org.scoverage" % "sbt-coveralls" % "1.3.11") +addSbtPlugin("org.scoverage" % "sbt-scoverage" % "2.2.2") +addSbtPlugin("io.laserdisc" % "sbt-laserdisc-defaults" % "0.2.0") +addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.9.0") From 12b3bcc9b0d4c19fb1c4b04554d6f7afa65bcf81 Mon Sep 17 00:00:00 2001 From: Barry O'Neill Date: Tue, 26 Nov 2024 16:20:42 -0500 Subject: [PATCH 2/2] adjust ci --- .github/workflows/build.yml | 2 +- .github/workflows/release.yml | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 2f152ca..3a078d8 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -24,5 +24,5 @@ jobs: ~/.sbt key: sbt-${{ hashFiles('**/build.sbt') }} - name: Run tests - run: sbt +clean +test +doc + run: sbt build diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index f2e7fdf..da38987 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -11,6 +11,8 @@ jobs: with: fetch-depth: 0 - uses: olafurpg/setup-scala@v14 + with: + java-version: corretto@1.17 - run: sbt ci-release env: PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }}