From ee9c1ebe430685bd90dd0a948b209476906e58e6 Mon Sep 17 00:00:00 2001 From: Piotr Chabelski Date: Tue, 19 Nov 2024 15:11:28 +0100 Subject: [PATCH] Compile with Scala 3 --- .scalafmt.conf | 2 +- build.sbt | 8 ++++---- .../main/scala/packager/cli/commands/BuildOptions.scala | 6 +++--- .../main/scala/packager/cli/commands/DebianOptions.scala | 8 +++----- .../main/scala/packager/cli/commands/DockerOptions.scala | 8 +++----- .../main/scala/packager/cli/commands/MacOSOptions.scala | 8 +++----- .../main/scala/packager/cli/commands/RedHatOptions.scala | 8 +++----- .../main/scala/packager/cli/commands/SharedOptions.scala | 7 +++---- .../main/scala/packager/cli/commands/WindowsOptions.scala | 4 ++-- project/ScalaVersions.scala | 3 ++- 10 files changed, 27 insertions(+), 35 deletions(-) diff --git a/.scalafmt.conf b/.scalafmt.conf index 3194834..652c3b7 100644 --- a/.scalafmt.conf +++ b/.scalafmt.conf @@ -12,7 +12,7 @@ newlines.beforeMultiline = keep newlines.afterCurlyLambdaParams = keep newlines.alwaysBeforeElseAfterCurlyIf = true -runner.dialect = scala213source3 +runner.dialect = scala3 rewrite.rules = [ RedundantBraces diff --git a/build.sbt b/build.sbt index c6646b4..149cba0 100644 --- a/build.sbt +++ b/build.sbt @@ -42,24 +42,24 @@ lazy val cliMainClass = Seq( ) lazy val compileOptions: Seq[Setting[_]] = Seq( - scalacOptions ++= Seq("-Xfatal-warnings", "-deprecation", "-Xsource:3") + scalacOptions ++= Seq("-Xfatal-warnings", "-deprecation") ) lazy val packagerProjectSettings = Seq( name := "scala-packager", - scalaVersion := ScalaVersions.scala213, + scalaVersion := ScalaVersions.scala3, crossScalaVersions := ScalaVersions.all ) lazy val imageResizerProjectSettings = Seq( name := "scala-packager-image-resizer", - scalaVersion := ScalaVersions.scala213, + scalaVersion := ScalaVersions.scala3, crossScalaVersions := ScalaVersions.all ) lazy val cliProjectSettings = Seq( name := "scala-packager-cli", - scalaVersion := ScalaVersions.scala213, + scalaVersion := ScalaVersions.scala3, crossScalaVersions := ScalaVersions.all, libraryDependencies ++= Seq(Deps.caseApp) ) diff --git a/modules/cli/src/main/scala/packager/cli/commands/BuildOptions.scala b/modules/cli/src/main/scala/packager/cli/commands/BuildOptions.scala index b033f89..0a56785 100644 --- a/modules/cli/src/main/scala/packager/cli/commands/BuildOptions.scala +++ b/modules/cli/src/main/scala/packager/cli/commands/BuildOptions.scala @@ -1,6 +1,6 @@ package packager.cli.commands -import caseapp.{Group, HelpMessage, Name, Parser, Recurse} +import caseapp._ import caseapp.core.help.Help import packager.cli.commands.BuildOptions.PackagerType import packager.config._ @@ -107,6 +107,6 @@ object BuildOptions { case object Rpm extends NativePackagerType } - implicit val parser: Parser[BuildOptions] = Parser[BuildOptions] - implicit val help: Help[BuildOptions] = Help[BuildOptions] + implicit lazy val parser: Parser[BuildOptions] = Parser.derive + implicit lazy val help: Help[BuildOptions] = Help.derive } diff --git a/modules/cli/src/main/scala/packager/cli/commands/DebianOptions.scala b/modules/cli/src/main/scala/packager/cli/commands/DebianOptions.scala index e1f39d1..9105b1b 100644 --- a/modules/cli/src/main/scala/packager/cli/commands/DebianOptions.scala +++ b/modules/cli/src/main/scala/packager/cli/commands/DebianOptions.scala @@ -1,7 +1,7 @@ package packager.cli.commands +import caseapp._ import caseapp.core.help.Help -import caseapp.{Group, HelpMessage, Parser, ValueDescription} import packager.cli.commands.SettingsHelpers.Mandatory import packager.config.{DebianSettings, SharedSettings} @@ -54,8 +54,6 @@ final case class DebianOptions( } case object DebianOptions { - - implicit val parser: Parser[DebianOptions] = Parser[DebianOptions] - implicit val help: Help[DebianOptions] = Help[DebianOptions] - + implicit lazy val parser: Parser[DebianOptions] = Parser.derive + implicit lazy val help: Help[DebianOptions] = Help.derive } diff --git a/modules/cli/src/main/scala/packager/cli/commands/DockerOptions.scala b/modules/cli/src/main/scala/packager/cli/commands/DockerOptions.scala index 938e936..ed9662b 100644 --- a/modules/cli/src/main/scala/packager/cli/commands/DockerOptions.scala +++ b/modules/cli/src/main/scala/packager/cli/commands/DockerOptions.scala @@ -1,7 +1,7 @@ package packager.cli.commands +import caseapp._ import caseapp.core.help.Help -import caseapp.{Group, HelpMessage, Parser, ValueDescription} import packager.cli.commands.SettingsHelpers.Mandatory import packager.config.DockerSettings import java.nio.file.Path; @@ -57,8 +57,6 @@ final case class DockerOptions( } case object DockerOptions { - - implicit val parser: Parser[DockerOptions] = Parser[DockerOptions] - implicit val help: Help[DockerOptions] = Help[DockerOptions] - + implicit lazy val parser: Parser[DockerOptions] = Parser.derive + implicit lazy val help: Help[DockerOptions] = Help.derive } diff --git a/modules/cli/src/main/scala/packager/cli/commands/MacOSOptions.scala b/modules/cli/src/main/scala/packager/cli/commands/MacOSOptions.scala index 270119b..1ddd242 100644 --- a/modules/cli/src/main/scala/packager/cli/commands/MacOSOptions.scala +++ b/modules/cli/src/main/scala/packager/cli/commands/MacOSOptions.scala @@ -1,6 +1,6 @@ package packager.cli.commands -import caseapp.{Group, HelpMessage, Parser} +import caseapp._ import caseapp.core.help.Help import packager.config.{MacOSSettings, SharedSettings} import SettingsHelpers._ @@ -22,8 +22,6 @@ final case class MacOSOptions( } case object MacOSOptions { - - implicit val parser: Parser[MacOSOptions] = Parser[MacOSOptions] - implicit val help: Help[MacOSOptions] = Help[MacOSOptions] - + implicit lazy val parser: Parser[MacOSOptions] = Parser.derive + implicit lazy val help: Help[MacOSOptions] = Help.derive } diff --git a/modules/cli/src/main/scala/packager/cli/commands/RedHatOptions.scala b/modules/cli/src/main/scala/packager/cli/commands/RedHatOptions.scala index 8c7027e..55a7c6b 100644 --- a/modules/cli/src/main/scala/packager/cli/commands/RedHatOptions.scala +++ b/modules/cli/src/main/scala/packager/cli/commands/RedHatOptions.scala @@ -1,6 +1,6 @@ package packager.cli.commands -import caseapp.{Group, HelpMessage, Parser} +import caseapp._ import caseapp.core.help.Help import packager.config.{RedHatSettings, SharedSettings} import SettingsHelpers._ @@ -40,8 +40,6 @@ final case class RedHatOptions( } case object RedHatOptions { - - implicit val parser: Parser[RedHatOptions] = Parser[RedHatOptions] - implicit val help: Help[RedHatOptions] = Help[RedHatOptions] - + implicit lazy val parser: Parser[RedHatOptions] = Parser.derive + implicit lazy val help: Help[RedHatOptions] = Help.derive } diff --git a/modules/cli/src/main/scala/packager/cli/commands/SharedOptions.scala b/modules/cli/src/main/scala/packager/cli/commands/SharedOptions.scala index 040c0b0..f4b0fbd 100644 --- a/modules/cli/src/main/scala/packager/cli/commands/SharedOptions.scala +++ b/modules/cli/src/main/scala/packager/cli/commands/SharedOptions.scala @@ -1,6 +1,6 @@ package packager.cli.commands -import caseapp.{Group, HelpMessage, Name, Parser, ValueDescription} +import caseapp._ import caseapp.core.help.Help final case class SharedOptions( @@ -32,7 +32,6 @@ final case class SharedOptions( logoPath: Option[String] = None ) case object SharedOptions { - - implicit val parser: Parser[SharedOptions] = Parser[SharedOptions] - implicit val help: Help[SharedOptions] = Help[SharedOptions] + implicit lazy val parser: Parser[SharedOptions] = Parser.derive + implicit lazy val help: Help[SharedOptions] = Help.derive } diff --git a/modules/cli/src/main/scala/packager/cli/commands/WindowsOptions.scala b/modules/cli/src/main/scala/packager/cli/commands/WindowsOptions.scala index 5a2e1a3..8313140 100644 --- a/modules/cli/src/main/scala/packager/cli/commands/WindowsOptions.scala +++ b/modules/cli/src/main/scala/packager/cli/commands/WindowsOptions.scala @@ -63,6 +63,6 @@ final case class WindowsOptions( case object WindowsOptions { - implicit val parser: Parser[WindowsOptions] = Parser[WindowsOptions] - implicit val help: Help[WindowsOptions] = Help[WindowsOptions] + implicit lazy val parser: Parser[WindowsOptions] = Parser.derive + implicit lazy val help: Help[WindowsOptions] = Help.derive } diff --git a/project/ScalaVersions.scala b/project/ScalaVersions.scala index 9d6b824..4b51a43 100644 --- a/project/ScalaVersions.scala +++ b/project/ScalaVersions.scala @@ -1,5 +1,6 @@ object ScalaVersions { def scala212 = "2.12.20" def scala213 = "2.13.15" - def all = Seq(scala213, scala212) + def scala3 = "3.3.4" // we stick to the LTS here + def all = Seq(scala3) }