diff --git a/.gitignore b/.gitignore index 028a9661..01de63f3 100644 --- a/.gitignore +++ b/.gitignore @@ -4,8 +4,13 @@ target/ # IDE .idea/ +.vscode/ *.iml .metals/ +.bsp/ +project/metals.sbt +project/project/ +.history/ # Scala *.class diff --git a/.scala-steward.conf b/.scala-steward.conf new file mode 100644 index 00000000..b1d7697b --- /dev/null +++ b/.scala-steward.conf @@ -0,0 +1,17 @@ +# Reference conf file -> https://github.com/scala-steward-org/scala-steward/blob/master/docs/repo-specific-configuration.md + +updates.pin = [ + {groupId = "com.sky:akka-streams", version = "4.0.1"}, + {groupId = "com.sky:akka-streams-kafka", version = "4.0.1"}, +] + +# If set, Scala Steward will only create or update `n` PRs each time it runs (see `pullRequests.frequency` above). +# Useful if running frequently and/or CI build are costly +updates.limit = 2 + +# If "always", Scala Steward will always update the PR it created as long as +# you don't change it yourself. +updatePullRequests = "always" + +# If set, Scala Steward will use this message template for the commit messages and PR titles. +commits.message = "Update ${artifactName} from ${currentVersion} to ${nextVersion}" diff --git a/.scalafmt.conf b/.scalafmt.conf index 3857c45b..dd29f3c3 100644 --- a/.scalafmt.conf +++ b/.scalafmt.conf @@ -11,5 +11,6 @@ newlines.sometimesBeforeColonInMethodReturnType = false rewrite.rules = [SortImports, RedundantBraces, RedundantParens, PreferCurlyFors] project.git = true +lineEndings = preserve spaces.beforeContextBoundColon = true diff --git a/build.sbt b/build.sbt index f8c7c793..6a781701 100644 --- a/build.sbt +++ b/build.sbt @@ -1,22 +1,20 @@ organization := "com.sky" -scalaVersion := "2.13.2" +scalaVersion := "2.13.7" name := "kafka-topic-loader" -crossScalaVersions := Seq("2.12.11", "2.13.2") +crossScalaVersions := Seq("2.12.15", "2.13.7") -scalacOptions ++= Seq( +// format: off +ThisBuild / scalacOptions ++= Seq( "-deprecation", - "-encoding", - "utf-8", + "-encoding", "utf8", "-explaintypes", "-feature", "-language:existentials", "-language:higherKinds", - "-language:implicitConversions", "-unchecked", "-Xcheckinit", "-Xfatal-warnings", - "-Xlint", "-Ywarn-dead-code", "-Ywarn-extra-implicit", "-Ywarn-numeric-widen", @@ -31,40 +29,38 @@ scalacOptions ++= Seq( if (scalaBinaryVersion.value == "2.13") Seq("-Wconf:msg=annotation:silent") else Seq("-Xfuture", "-Ypartial-unification", "-Yno-adapted-args") } +// format: on scalafmtVersion := "1.5.1" scalafmtOnCompile := true -parallelExecution in Test := false -fork in Test := true +Test / parallelExecution := false +Test / fork := true releaseCrossBuild := true -bintrayOrganization := Some("sky-uk") -bintrayReleaseOnPublish in ThisBuild := false -bintrayRepository := "oss-maven" -bintrayVcsUrl := Some("https://github.com/sky-uk/kafka-topic-loader") licenses += ("BSD New", url("https://opensource.org/licenses/BSD-3-Clause")) -val AkkaVersion = "2.6.5" -val CatsVersion = "2.1.1" +val AkkaVersion = "2.6.16" +val CatsVersion = "2.6.1" +val KafkaVersion = "2.8.0" val RefinedVersion = "0.9.27" // @formatter:off libraryDependencies ++= Seq( "com.typesafe.akka" %% "akka-stream" % AkkaVersion, - "com.typesafe.akka" %% "akka-stream-kafka" % "2.0.3", - "org.apache.kafka" % "kafka-clients" % "2.5.0", - "com.typesafe.scala-logging" %% "scala-logging" % "3.9.2", + "com.typesafe.akka" %% "akka-stream-kafka" % "2.1.1", + "org.apache.kafka" % "kafka-clients" % KafkaVersion, + "com.typesafe.scala-logging" %% "scala-logging" % "3.9.4", "org.typelevel" %% "cats-core" % CatsVersion, "org.typelevel" %% "cats-kernel" % CatsVersion, "eu.timepit" %% "refined" % RefinedVersion, "eu.timepit" %% "refined-pureconfig" % RefinedVersion, "com.github.pureconfig" %% "pureconfig" % "0.17.0", - "org.scala-lang.modules" %% "scala-collection-compat" % "2.1.6", + "org.scala-lang.modules" %% "scala-collection-compat" % "2.5.0", "com.typesafe.akka" %% "akka-stream-testkit" % AkkaVersion % Test, "com.typesafe.akka" %% "akka-testkit" % AkkaVersion % Test, - "org.scalatest" %% "scalatest" % "3.1.2" % Test, - "io.github.embeddedkafka" %% "embedded-kafka" % "2.7.0" % Test + "org.scalatest" %% "scalatest" % "3.2.9" % Test, + "io.github.embeddedkafka" %% "embedded-kafka" % KafkaVersion % Test ) // @formatter:on diff --git a/project/build.properties b/project/build.properties index 797e7ccf..10fd9eee 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1 +1 @@ -sbt.version=1.3.10 +sbt.version=1.5.5 diff --git a/project/plugins.sbt b/project/plugins.sbt index 387faf8f..6884177c 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,3 +1,2 @@ -addSbtPlugin("com.github.gseitz" % "sbt-release" % "1.0.10") -addSbtPlugin("org.foundweekends" % "sbt-bintray" % "0.5.1") -addSbtPlugin("com.lucidchart" % "sbt-scalafmt" % "1.16") \ No newline at end of file +addSbtPlugin("com.github.gseitz" % "sbt-release" % "1.0.10") +addSbtPlugin("com.lucidchart" % "sbt-scalafmt" % "1.16") diff --git a/src/main/scala/com/sky/kafka/topicloader/TopicLoader.scala b/src/main/scala/com/sky/kafka/topicloader/TopicLoader.scala index b360e99c..56ced223 100644 --- a/src/main/scala/com/sky/kafka/topicloader/TopicLoader.scala +++ b/src/main/scala/com/sky/kafka/topicloader/TopicLoader.scala @@ -19,12 +19,11 @@ import org.apache.kafka.clients.consumer._ import org.apache.kafka.common.serialization._ import cats.syntax.bifunctor._ import org.apache.kafka.common.TopicPartition -import pureconfig._ +import pureconfig.ConfigSource import pureconfig.generic.auto._ -import scala.annotation.nowarn import scala.concurrent.Future -import scala.collection.JavaConverters._ +import scala.jdk.CollectionConverters._ object TopicLoader extends TopicLoader with DeprecatedMethods { private[topicloader] case class LogOffsets(lowest: Long, highest: Long) @@ -65,7 +64,6 @@ object TopicLoader extends TopicLoader with DeprecatedMethods { _.map(tp => s"${tp.topic}:${tp.partition}").mkString(", ") } -@nowarn("msg=JavaConverters") trait TopicLoader extends LazyLogging { import TopicLoader._ diff --git a/src/test/scala/base/AkkaSpecBase.scala b/src/test/scala/base/AkkaSpecBase.scala index 8271cc51..2e8e6e1a 100644 --- a/src/test/scala/base/AkkaSpecBase.scala +++ b/src/test/scala/base/AkkaSpecBase.scala @@ -5,7 +5,7 @@ import org.scalatest.{BeforeAndAfterAll, Suite} import org.scalatest.matchers.should.Matchers import scala.concurrent.ExecutionContext -import scala.concurrent.duration._ +import scala.concurrent.duration.DurationInt abstract class AkkaSpecBase extends TestKitBase with Suite with BeforeAndAfterAll with Matchers { diff --git a/src/test/scala/base/IntegrationSpecBase.scala b/src/test/scala/base/IntegrationSpecBase.scala index 177af701..4b59691d 100644 --- a/src/test/scala/base/IntegrationSpecBase.scala +++ b/src/test/scala/base/IntegrationSpecBase.scala @@ -9,21 +9,20 @@ import akka.util.Timeout import cats.data.NonEmptyList import cats.syntax.option._ import com.typesafe.config.ConfigFactory -import net.manub.embeddedkafka.{EmbeddedKafka, EmbeddedKafkaConfig} +import io.github.embeddedkafka.{EmbeddedKafka, EmbeddedKafkaConfig} +import io.github.embeddedkafka.Codecs.{stringDeserializer, stringSerializer} import org.apache.kafka.clients.CommonClientConfigs import org.apache.kafka.clients.consumer.{Consumer, ConsumerConfig, ConsumerRecord, ConsumerRecords} import org.apache.kafka.clients.producer.ProducerConfig import org.apache.kafka.common.TopicPartition import org.scalatest.Assertion import org.scalatest.concurrent.Eventually -import net.manub.embeddedkafka.Codecs.{stringDeserializer, stringSerializer} import utils.RandomPort -import scala.annotation.{nowarn, tailrec} -import scala.collection.JavaConverters._ -import scala.concurrent.duration._ +import scala.annotation.tailrec +import scala.jdk.CollectionConverters._ +import scala.concurrent.duration.DurationInt -@nowarn("msg=JavaConverters") abstract class IntegrationSpecBase extends WordSpecBase with Eventually { override implicit val patienceConfig = PatienceConfig(20.seconds, 200.millis) diff --git a/src/test/scala/integration/DeprecatedMethodsIntSpec.scala b/src/test/scala/integration/DeprecatedMethodsIntSpec.scala index 2f828e6a..9c9a27b1 100644 --- a/src/test/scala/integration/DeprecatedMethodsIntSpec.scala +++ b/src/test/scala/integration/DeprecatedMethodsIntSpec.scala @@ -8,11 +8,11 @@ import akka.util.Timeout import base.IntegrationSpecBase import cats.data.NonEmptyList import com.sky.kafka.topicloader._ -import net.manub.embeddedkafka.Codecs.{stringDeserializer, stringSerializer} +import io.github.embeddedkafka.Codecs.{stringDeserializer, stringSerializer} import org.apache.kafka.clients.consumer._ import org.apache.kafka.common.TopicPartition -import scala.collection.JavaConverters._ +import scala.jdk.CollectionConverters._ import scala.concurrent.Future @deprecated("Remove when deprecated methods are gone", "") @@ -20,7 +20,7 @@ class DeprecatedMethodsIntSpec extends IntegrationSpecBase { "fromTopics" should { "execute onRecord for all messages in provided topics" in new TestContext { - val store = new RecordStore() + val store = new RecordStore val (recordsTopic1, recordsTopic2) = records(1 to 30).splitAt(15) val topics = NonEmptyList.of(testTopic1, testTopic2) diff --git a/src/test/scala/integration/TopicLoaderIntSpec.scala b/src/test/scala/integration/TopicLoaderIntSpec.scala index e91d8208..2e15022e 100644 --- a/src/test/scala/integration/TopicLoaderIntSpec.scala +++ b/src/test/scala/integration/TopicLoaderIntSpec.scala @@ -9,7 +9,7 @@ import base.IntegrationSpecBase import cats.data.NonEmptyList import com.sky.kafka.topicloader._ import com.typesafe.config.ConfigFactory -import net.manub.embeddedkafka.Codecs.{stringDeserializer, stringSerializer} +import io.github.embeddedkafka.Codecs.{stringDeserializer, stringSerializer} import org.apache.kafka.common.errors.{TimeoutException => KafkaTimeoutException} import org.scalatest.prop.TableDrivenPropertyChecks._ import org.scalatest.prop.Tables.Table diff --git a/version.sbt b/version.sbt index c79d9b29..d25201d8 100644 --- a/version.sbt +++ b/version.sbt @@ -1 +1 @@ -version in ThisBuild := "1.4.2-SNAPSHOT" +ThisBuild / version := "1.4.2-SNAPSHOT"