diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs index 753ff1a58..dc2d9d569 100644 --- a/.git-blame-ignore-revs +++ b/.git-blame-ignore-revs @@ -1,2 +1,5 @@ # Scala Steward: Reformat with scalafmt 3.8.3 fb3b1e158c70f5b76207764dc42b128cb878b3be + +# Scala Steward: Reformat with scalafmt 3.8.6 +be90ba629707a224c66d1d12e4e5a4556b354fa7 diff --git a/.scalafmt.conf b/.scalafmt.conf index de2f889c7..73508f466 100644 --- a/.scalafmt.conf +++ b/.scalafmt.conf @@ -1,5 +1,5 @@ # Version https://scalameta.org/scalafmt/docs/configuration.html#version -version = 3.8.3 +version = 3.8.6 # Dialect https://scalameta.org/scalafmt/docs/configuration.html#scala-dialects runner.dialect = scala212source3 diff --git a/src/main/scala/com/typesafe/sbt/packager/archetypes/JavaAppPackaging.scala b/src/main/scala/com/typesafe/sbt/packager/archetypes/JavaAppPackaging.scala index dc921efa9..2c49f7844 100644 --- a/src/main/scala/com/typesafe/sbt/packager/archetypes/JavaAppPackaging.scala +++ b/src/main/scala/com/typesafe/sbt/packager/archetypes/JavaAppPackaging.scala @@ -84,10 +84,10 @@ object JavaAppPackaging extends AutoPlugin { for { (_, name) <- mappings } yield - // Here we want the name relative to the lib/ folder... - // For now we just cheat... - if (name startsWith "lib/") name drop 4 - else "../" + name + // Here we want the name relative to the lib/ folder... + // For now we just cheat... + if (name startsWith "lib/") name drop 4 + else "../" + name /** * Constructs a jar name from components...(ModuleID/Artifact) diff --git a/src/main/scala/com/typesafe/sbt/packager/archetypes/JavaServerApplication.scala b/src/main/scala/com/typesafe/sbt/packager/archetypes/JavaServerApplication.scala index 974296af8..1d9969253 100644 --- a/src/main/scala/com/typesafe/sbt/packager/archetypes/JavaServerApplication.scala +++ b/src/main/scala/com/typesafe/sbt/packager/archetypes/JavaServerApplication.scala @@ -54,12 +54,11 @@ object JavaServerAppPackaging extends AutoPlugin { Seq( Linux / javaOptions := (Universal / javaOptions).value, // === logging directory mapping === - linuxPackageMappings += { + linuxPackageMappings += packageTemplateMapping(defaultLinuxLogsLocation.value + "/" + (Linux / packageName).value)() .withUser((Linux / daemonUser).value) .withGroup((Linux / daemonGroup).value) - .withPerms("755") - }, + .withPerms("755"), linuxPackageSymlinks += { val name = (Linux / packageName).value LinuxSymlink( @@ -126,12 +125,11 @@ object JavaServerAppPackaging extends AutoPlugin { linuxScriptReplacements ++= bashScriptEnvConfigLocation.value.map(ENV_CONFIG_REPLACEMENT -> _).toSeq, linuxScriptReplacements += Names.DaemonStdoutLogFileReplacement -> daemonStdoutLogFile.value.getOrElse(""), // === /var/run/app pid folder === - linuxPackageMappings += { + linuxPackageMappings += packageTemplateMapping("/var/run/" + packageName.value)() .withUser(daemonUser.value) .withGroup(daemonGroup.value) .withPerms("755") - } ) ) ++ Seq( // === Daemon User and Group === diff --git a/src/main/scala/com/typesafe/sbt/packager/archetypes/JavaServerBashScript.scala b/src/main/scala/com/typesafe/sbt/packager/archetypes/JavaServerBashScript.scala index e0a9d8126..46850c115 100644 --- a/src/main/scala/com/typesafe/sbt/packager/archetypes/JavaServerBashScript.scala +++ b/src/main/scala/com/typesafe/sbt/packager/archetypes/JavaServerBashScript.scala @@ -46,9 +46,8 @@ object JavaServerBashScript { template: Option[URL] = None ): Option[String] = { // use template or else search for a default - val url = template orElse { + val url = template orElse Option(getClass getResource s"$archetype/${config.name}/$script-template") - } // if an url was found, create the script url map { TemplateWriter generateScript (_, replacements) diff --git a/src/main/scala/com/typesafe/sbt/packager/debian/JDebPackaging.scala b/src/main/scala/com/typesafe/sbt/packager/debian/JDebPackaging.scala index 5cfeb43f2..0f0ec7aca 100644 --- a/src/main/scala/com/typesafe/sbt/packager/debian/JDebPackaging.scala +++ b/src/main/scala/com/typesafe/sbt/packager/debian/JDebPackaging.scala @@ -43,9 +43,8 @@ object JDebPackaging extends AutoPlugin with DebianPluginLike { def jdebSettings = Seq( // FIXME do nothing. Java7 posix needed - debianConffilesFile := { - target.value / Names.DebianMaintainerScripts / Names.Conffiles - }, + debianConffilesFile := + target.value / Names.DebianMaintainerScripts / Names.Conffiles, // FIXME copied from the debian plugin. Java7 posix needed debianControlFile := { val data = debianPackageMetadata.value diff --git a/src/main/scala/com/typesafe/sbt/packager/docker/DockerPlugin.scala b/src/main/scala/com/typesafe/sbt/packager/docker/DockerPlugin.scala index 9afe43d9c..fbd2cf0f0 100644 --- a/src/main/scala/com/typesafe/sbt/packager/docker/DockerPlugin.scala +++ b/src/main/scala/com/typesafe/sbt/packager/docker/DockerPlugin.scala @@ -161,7 +161,7 @@ object DockerPlugin extends AutoPlugin { Seq("-t", alias.toString) } ++ { if (dockerBuildInit.value) List("--init") else Nil }, dockerBuildEnvVars := Map.empty, - dockerBuildkitEnabled := { + dockerBuildkitEnabled := dockerBuildEnvVars.value .get("DOCKER_BUILDKIT") .orElse(sys.env.get("DOCKER_BUILDKIT")) @@ -169,8 +169,7 @@ object DockerPlugin extends AutoPlugin { .getOrElse { // BuildKit is the default since v23.0 dockerVersion.value.fold(false)(_.major >= 23) - } - }, + }, dockerRmiCommand := dockerExecCommand.value ++ Seq("rmi"), dockerBuildCommand := dockerExecCommand.value ++ Seq("build") ++ dockerBuildOptions.value ++ Seq("."), dockerAdditionalPermissions := { @@ -269,7 +268,7 @@ object DockerPlugin extends AutoPlugin { stage0 ++ stage1 } - ) ++ mapGenericFilesToDocker ++ inConfig(Docker)({ + ) ++ mapGenericFilesToDocker ++ inConfig(Docker) { def publishLocalTask = Def.task { @@ -383,7 +382,7 @@ object DockerPlugin extends AutoPlugin { generateDockerConfig(dockerCommands.value, stagingDirectory.value) } ) - }) + } /** * @param maintainer diff --git a/src/main/scala/com/typesafe/sbt/packager/jar/ClasspathJarPlugin.scala b/src/main/scala/com/typesafe/sbt/packager/jar/ClasspathJarPlugin.scala index f7bf7be97..942d315cf 100644 --- a/src/main/scala/com/typesafe/sbt/packager/jar/ClasspathJarPlugin.scala +++ b/src/main/scala/com/typesafe/sbt/packager/jar/ClasspathJarPlugin.scala @@ -34,12 +34,10 @@ object ClasspathJarPlugin extends AutoPlugin { moduleId.organization + "." + artifact.name + "-" + moduleId.revision + artifact.classifier.fold("")("-" + _) + "." + artifact.extension }, - bashScriptDefines / scriptClasspath := { - Seq(PluginCompat.getArtifactPathName((packageJavaClasspathJar / artifactPath).value)) - }, - batScriptReplacements / scriptClasspath := { - Seq(PluginCompat.getArtifactPathName((packageJavaClasspathJar / artifactPath).value)) - }, + bashScriptDefines / scriptClasspath := + Seq(PluginCompat.getArtifactPathName((packageJavaClasspathJar / artifactPath).value)), + batScriptReplacements / scriptClasspath := + Seq(PluginCompat.getArtifactPathName((packageJavaClasspathJar / artifactPath).value)), Universal / mappings += { val classpathJar = packageJavaClasspathJar.value classpathJar -> ("lib/" + PluginCompat.getName(classpathJar)) diff --git a/src/main/scala/com/typesafe/sbt/packager/rpm/RpmHelper.scala b/src/main/scala/com/typesafe/sbt/packager/rpm/RpmHelper.scala index 2de76b24b..5037346c5 100644 --- a/src/main/scala/com/typesafe/sbt/packager/rpm/RpmHelper.scala +++ b/src/main/scala/com/typesafe/sbt/packager/rpm/RpmHelper.scala @@ -88,9 +88,11 @@ object RpmHelper { LinuxSymlink.makeSymLinks(spec.symlinks, buildroot, relativeLinks = false) } - private[this] def writeSpecFile(spec: RpmSpec, workArea: File, log: sbt.Logger)(implicit - conv: FileConverter - ): File = { + private[this] def writeSpecFile( + spec: RpmSpec, + workArea: File, + log: sbt.Logger + )(implicit conv: FileConverter): File = { val specdir = workArea / "SPECS" val rpmBuildroot = workArea / "buildroot" val tmpBuildRoot = workArea / "tmp-buildroot" diff --git a/src/sbt-test/debian/file-permissions/build.sbt b/src/sbt-test/debian/file-permissions/build.sbt index 0a0561ae8..254ed7faa 100644 --- a/src/sbt-test/debian/file-permissions/build.sbt +++ b/src/sbt-test/debian/file-permissions/build.sbt @@ -11,6 +11,6 @@ packageSummary := "Test debian package" packageDescription := """A fun package description of our software, with multiple lines.""" -linuxPackageMappings += packageMapping( - ((Compile / resourceDirectory).value / "sudoers.d", "/etc/sudoers.d") -).withPerms("0440").asDocs() +linuxPackageMappings += packageMapping(((Compile / resourceDirectory).value / "sudoers.d", "/etc/sudoers.d")) + .withPerms("0440") + .asDocs() diff --git a/src/sbt-test/debian/test-mapping-helpers/build.sbt b/src/sbt-test/debian/test-mapping-helpers/build.sbt index 87d646131..adfe1873e 100644 --- a/src/sbt-test/debian/test-mapping-helpers/build.sbt +++ b/src/sbt-test/debian/test-mapping-helpers/build.sbt @@ -17,9 +17,8 @@ packageDescription := """A fun package description of our software, // linuxPackageMappings in Debian += packageTemplateMapping("/var/run/debian")() // not work Debian / linuxPackageMappings += packageTemplateMapping(Seq("/opt/test/other"): _*)() -Debian / linuxPackageMappings += { +Debian / linuxPackageMappings += packageTemplateMapping("/opt/test/" + Keys.normalizedName.value)(target.value) -} // Consider using mappings in Universal Debian / linuxPackageMappings += packageDirectoryAndContentsMapping( diff --git a/src/sbt-test/jdkpackager/test-package-image/build.sbt b/src/sbt-test/jdkpackager/test-package-image/build.sbt index 62e415b52..30762ff82 100644 --- a/src/sbt-test/jdkpackager/test-package-image/build.sbt +++ b/src/sbt-test/jdkpackager/test-package-image/build.sbt @@ -35,7 +35,9 @@ lazy val iconGlob = sys.props("os.name").toLowerCase match { case _ => "*.png" } -jdkAppIcon := (baseDirectory.value / ".." / ".." / ".." / ".." / "test-project-jdkpackager" ** iconGlob).getPaths().headOption +jdkAppIcon := (baseDirectory.value / ".." / ".." / ".." / ".." / "test-project-jdkpackager" ** iconGlob) + .getPaths() + .headOption .map(file) TaskKey[Unit]("checkImage") := { diff --git a/src/sbt-test/jdkpackager/test-package-image/src/main/scala/ExampleApp.scala b/src/sbt-test/jdkpackager/test-package-image/src/main/scala/ExampleApp.scala index 05a4ff1e5..9fe12f08c 100644 --- a/src/sbt-test/jdkpackager/test-package-image/src/main/scala/ExampleApp.scala +++ b/src/sbt-test/jdkpackager/test-package-image/src/main/scala/ExampleApp.scala @@ -13,7 +13,7 @@ import scala.collection.JavaConversions._ /** Silly GUI app launcher. */ object ExampleApp { def main(args: Array[String]): Unit = - Application.launch(classOf[ExampleApp], args: _*) + Application.launch(classOf[ExampleApp], args*) } /** Silly GUI app. */ diff --git a/src/sbt-test/jdkpackager/test-package-mappings/build.sbt b/src/sbt-test/jdkpackager/test-package-mappings/build.sbt index 09318d7fb..f0cac43db 100644 --- a/src/sbt-test/jdkpackager/test-package-mappings/build.sbt +++ b/src/sbt-test/jdkpackager/test-package-mappings/build.sbt @@ -32,7 +32,9 @@ lazy val iconGlob = sys.props("os.name").toLowerCase match { case _ => "*.png" } -jdkAppIcon := (baseDirectory.value / ".." / ".." / ".." / ".." / "test-project-jdkpackager" ** iconGlob).getPaths().headOption +jdkAppIcon := (baseDirectory.value / ".." / ".." / ".." / ".." / "test-project-jdkpackager" ** iconGlob) + .getPaths() + .headOption .map(file) TaskKey[Unit]("checkImage") := { diff --git a/src/sbt-test/jdkpackager/test-package-mappings/src/main/scala/ExampleApp.scala b/src/sbt-test/jdkpackager/test-package-mappings/src/main/scala/ExampleApp.scala index 17df4c6bc..b5c8ff043 100644 --- a/src/sbt-test/jdkpackager/test-package-mappings/src/main/scala/ExampleApp.scala +++ b/src/sbt-test/jdkpackager/test-package-mappings/src/main/scala/ExampleApp.scala @@ -12,7 +12,7 @@ import javafx.stage.{Modality, Stage, StageStyle} /** Silly GUI app launcher. */ object ExampleApp { def main(args: Array[String]): Unit = - Application.launch(classOf[ExampleApp], args: _*) + Application.launch(classOf[ExampleApp], args*) } /** Silly GUI app. */ diff --git a/src/sbt-test/jdkpackager/test-package-minimal/src/main/scala/ExampleApp.scala b/src/sbt-test/jdkpackager/test-package-minimal/src/main/scala/ExampleApp.scala index 17df4c6bc..b5c8ff043 100644 --- a/src/sbt-test/jdkpackager/test-package-minimal/src/main/scala/ExampleApp.scala +++ b/src/sbt-test/jdkpackager/test-package-minimal/src/main/scala/ExampleApp.scala @@ -12,7 +12,7 @@ import javafx.stage.{Modality, Stage, StageStyle} /** Silly GUI app launcher. */ object ExampleApp { def main(args: Array[String]): Unit = - Application.launch(classOf[ExampleApp], args: _*) + Application.launch(classOf[ExampleApp], args*) } /** Silly GUI app. */ diff --git a/src/sbt-test/jlink/test-jlink-misc/build.sbt b/src/sbt-test/jlink/test-jlink-misc/build.sbt index 9b33b033b..ec9c901e5 100644 --- a/src/sbt-test/jlink/test-jlink-misc/build.sbt +++ b/src/sbt-test/jlink/test-jlink-misc/build.sbt @@ -113,7 +113,8 @@ val issue1293 = project (jlinkBuildImage / fullClasspath).value // Find the ones that have `paranamer` as their artifact names. .filter { item => - item.get(PluginCompat.moduleIDStr) + item + .get(PluginCompat.moduleIDStr) .map(PluginCompat.parseModuleIDStrAttribute) .exists { modId => modId.name == "paranamer" diff --git a/src/sbt-test/universal/multiproject-classifiers/build.sbt b/src/sbt-test/universal/multiproject-classifiers/build.sbt index 142501d2b..ca46f6a35 100644 --- a/src/sbt-test/universal/multiproject-classifiers/build.sbt +++ b/src/sbt-test/universal/multiproject-classifiers/build.sbt @@ -4,17 +4,16 @@ import xsbti.FileConverter lazy val appVersion = "1.0" -lazy val mySettings: Seq[Setting[_]] = +lazy val mySettings: Seq[Setting[?]] = Seq( organization := "org.test", version := appVersion, - TaskKey[Unit]("showFiles") := { + TaskKey[Unit]("showFiles") := System.out.synchronized { println("Files in [" + name.value + "]") val files = (target.value / "universal/stage").**(AllPassFilter).get() files foreach println } - } ) lazy val Assets = config("assets") @@ -37,11 +36,14 @@ lazy val sub = project Assets / exportedProducts := { implicit val converter: FileConverter = fileConverter.value val assetsDir = baseDirectory.value / "src" / "main" / "assets" - assetsDir.**(AllPassFilter).filter(_.isFile).classpath.map( - _ - .put(PluginCompat.artifactStr, PluginCompat.artifactToStr((Assets / artifact).value)) - .put(PluginCompat.moduleIDStr, PluginCompat.moduleIDToStr(projectID.value)) - ) + assetsDir + .**(AllPassFilter) + .filter(_.isFile) + .classpath + .map( + _.put(PluginCompat.artifactStr, PluginCompat.artifactToStr((Assets / artifact).value)) + .put(PluginCompat.moduleIDStr, PluginCompat.moduleIDToStr(projectID.value)) + ) } ) diff --git a/src/sbt-test/windows/custom-wix/build.sbt b/src/sbt-test/windows/custom-wix/build.sbt index 3fb8fb142..dcaa88ea3 100644 --- a/src/sbt-test/windows/custom-wix/build.sbt +++ b/src/sbt-test/windows/custom-wix/build.sbt @@ -4,8 +4,7 @@ name := "custom-wix" version := "0.1.0" // make sure we don't somehow use the generated script -Windows / wixFile := { +Windows / wixFile := sys.error("wixFile shouldn't have been called") -} wixFiles := List(sourceDirectory.value / "wix" / "main.wsx", sourceDirectory.value / "wix" / "ui.wsx") diff --git a/src/test/scala/com/typesafe/sbt/packager/archetypes/scripts/ScriptUtilsTest.scala b/src/test/scala/com/typesafe/sbt/packager/archetypes/scripts/ScriptUtilsTest.scala index 3262d6c56..8c85fc105 100644 --- a/src/test/scala/com/typesafe/sbt/packager/archetypes/scripts/ScriptUtilsTest.scala +++ b/src/test/scala/com/typesafe/sbt/packager/archetypes/scripts/ScriptUtilsTest.scala @@ -28,28 +28,25 @@ class ScriptUtilsTest extends AnyFlatSpec with Matchers { private[this] def testMapping(testCase: (String, String)*): Unit = ScriptUtils.createScriptNames(testCase.map(_._1)) should contain theSameElementsAs testCase - "createScriptNames()" should "generate short names when no conflicts" in { + "createScriptNames()" should "generate short names when no conflicts" in testMapping( "pkg1.TestClass" -> "test-class", "pkg1.AnotherTestClass" -> "another-test-class", "pkg2.ThirdTestClass" -> "third-test-class" ) - } - it should "generate long names only when necessary" in { + it should "generate long names only when necessary" in testMapping( "pkg1.TestClass" -> "pkg-1_test-class", "pkg1.ui.TestClass" -> "pkg-1_ui_test-class", "pkg1.AnotherTestClass" -> "another-test-class", "pkg2.TestClass" -> "pkg-2_test-class" ) - } - it should "handle single main class" in { + it should "handle single main class" in testMapping("pkg1.Test" -> "test") - } - it should "be consistent with the docs" in { + it should "be consistent with the docs" in // see src/sphinx/archetypes/java_app/index.rst testMapping( "pkg1.TestClass" -> "pkg-1_test-class", @@ -57,7 +54,6 @@ class ScriptUtilsTest extends AnyFlatSpec with Matchers { "pkg2.SomeXMLLoader" -> "some-xml-loader", "pkg3.TestClass" -> "pkg-3_test-class" ) - } "duplicated script name detector" should "work" in { ScriptUtils.describeDuplicates( diff --git a/src/test/scala/com/typesafe/sbt/packager/universal/ZipHelperSpec.scala b/src/test/scala/com/typesafe/sbt/packager/universal/ZipHelperSpec.scala index 979ed21b5..e0d150f38 100644 --- a/src/test/scala/com/typesafe/sbt/packager/universal/ZipHelperSpec.scala +++ b/src/test/scala/com/typesafe/sbt/packager/universal/ZipHelperSpec.scala @@ -29,73 +29,58 @@ class ZipHelperSpec extends AnyWordSpec with Matchers with BeforeAndAfterEach wi "The ZipHelper.zip" should { - "create a zip with a single file" taggedAs (LinuxTag, WindowsTag) in { + "create a zip with a single file" taggedAs (LinuxTag, WindowsTag) in zipSingleFile(ZipHelper.zip) - } - "create a zip with nested directories" taggedAs (LinuxTag, WindowsTag) in { + "create a zip with nested directories" taggedAs (LinuxTag, WindowsTag) in zipNestedFile(ZipHelper.zip) - } - "create a zip with nested directories containing file" taggedAs (LinuxTag, WindowsTag) in { + "create a zip with nested directories containing file" taggedAs (LinuxTag, WindowsTag) in zipNestedDirsWithFiles(ZipHelper.zip) - } - "create directories if necessary" taggedAs (LinuxTag, WindowsTag) in { + "create directories if necessary" taggedAs (LinuxTag, WindowsTag) in createNecessaryDirectories(ZipHelper.zip) - } // works only on some systems - "preserve the executable bit" taggedAs (LinuxTag, WindowsTag) ignore { + "preserve the executable bit" taggedAs (LinuxTag, WindowsTag) ignore preserveExecutableBit(ZipHelper.zip) - } } "The ZipHelper.zipNIO" should { - "create a zip with a single file" taggedAs (LinuxTag, WindowsTag) in { + "create a zip with a single file" taggedAs (LinuxTag, WindowsTag) in zipSingleFile(ZipHelper.zipNIO) - } - "create a zip with nested directories" taggedAs (LinuxTag, WindowsTag) in { + "create a zip with nested directories" taggedAs (LinuxTag, WindowsTag) in zipNestedFile(ZipHelper.zipNIO) - } - "create a zip with nested directories containing file" taggedAs (LinuxTag, WindowsTag) in { + "create a zip with nested directories containing file" taggedAs (LinuxTag, WindowsTag) in zipNestedDirsWithFiles(ZipHelper.zipNIO) - } - "create directories if necessary" taggedAs (LinuxTag, WindowsTag) in { + "create directories if necessary" taggedAs (LinuxTag, WindowsTag) in createNecessaryDirectories(ZipHelper.zipNIO) - } // never works - "preserve the executable bit" taggedAs (LinuxTag, WindowsTag) ignore { + "preserve the executable bit" taggedAs (LinuxTag, WindowsTag) ignore preserveExecutableBit(ZipHelper.zipNIO) - } } "The ZipHelper.zipNative" should { - "create a zip with a single file" taggedAs (LinuxTag) in { + "create a zip with a single file" taggedAs (LinuxTag) in zipSingleFile(ZipHelper.zipNative) - } - "create a zip with nested directories" taggedAs (LinuxTag) in { + "create a zip with nested directories" taggedAs (LinuxTag) in zipNestedFile(ZipHelper.zipNative) - } - "create a zip with nested directories containing file" taggedAs (LinuxTag) in { + "create a zip with nested directories containing file" taggedAs (LinuxTag) in zipNestedDirsWithFiles(ZipHelper.zipNative) - } - "create directories if necessary" taggedAs (LinuxTag) in { + "create directories if necessary" taggedAs (LinuxTag) in createNecessaryDirectories(ZipHelper.zipNative) - } // never works - "preserve the executable bit" taggedAs (LinuxTag) ignore { + "preserve the executable bit" taggedAs (LinuxTag) ignore preserveExecutableBit(ZipHelper.zipNative) - } } /* ========================================================== */ diff --git a/test-project-jdkpackager/src/main/scala/ExampleApp.scala b/test-project-jdkpackager/src/main/scala/ExampleApp.scala index 17df4c6bc..b5c8ff043 100644 --- a/test-project-jdkpackager/src/main/scala/ExampleApp.scala +++ b/test-project-jdkpackager/src/main/scala/ExampleApp.scala @@ -12,7 +12,7 @@ import javafx.stage.{Modality, Stage, StageStyle} /** Silly GUI app launcher. */ object ExampleApp { def main(args: Array[String]): Unit = - Application.launch(classOf[ExampleApp], args: _*) + Application.launch(classOf[ExampleApp], args*) } /** Silly GUI app. */