From 744c53397deab522031a739780be58775b32e015 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Ferreira?= Date: Wed, 9 Oct 2024 14:27:54 +0100 Subject: [PATCH] scalafmt --- .../GraalVMNativeImagePlugin.scala | 4 +- .../sbt/packager/jar/ClasspathJarPlugin.scala | 16 ++--- .../sbt/packager/jar/LauncherJarPlugin.scala | 18 ++--- .../typesafe/sbt/packager/rpm/RpmPlugin.scala | 66 +++++++++---------- .../sbt/packager/windows/WindowsPlugin.scala | 52 +++++++-------- 5 files changed, 76 insertions(+), 80 deletions(-) diff --git a/src/main/scala/com/typesafe/sbt/packager/graalvmnativeimage/GraalVMNativeImagePlugin.scala b/src/main/scala/com/typesafe/sbt/packager/graalvmnativeimage/GraalVMNativeImagePlugin.scala index fb3d92d0f..8bba3d7dd 100644 --- a/src/main/scala/com/typesafe/sbt/packager/graalvmnativeimage/GraalVMNativeImagePlugin.scala +++ b/src/main/scala/com/typesafe/sbt/packager/graalvmnativeimage/GraalVMNativeImagePlugin.scala @@ -39,8 +39,8 @@ object GraalVMNativeImagePlugin extends AutoPlugin { graalVMNativeImageOptions := Seq.empty, graalVMNativeImageGraalVersion := None, graalVMNativeImageCommand := (if (scala.util.Properties.isWin) "native-image.cmd" else "native-image"), - GraalVMNativeImage /resourceDirectory := sourceDirectory.value / "graal", - GraalVMNativeImage / mainClass := (Compile / mainClass).value + GraalVMNativeImage / resourceDirectory := sourceDirectory.value / "graal", + GraalVMNativeImage / mainClass := (Compile / mainClass).value ) ++ inConfig(GraalVMNativeImage)(scopedSettings) private lazy val scopedSettings = Seq[Setting[_]]( 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 5222b36c3..7185aae56 100644 --- a/src/main/scala/com/typesafe/sbt/packager/jar/ClasspathJarPlugin.scala +++ b/src/main/scala/com/typesafe/sbt/packager/jar/ClasspathJarPlugin.scala @@ -23,20 +23,20 @@ object ClasspathJarPlugin extends AutoPlugin { override def requires = JavaAppPackaging override lazy val projectSettings: Seq[Setting[_]] = Defaults - .packageTaskSettings(packageJavaClasspathJar, packageJavaClasspathJar / mappings ) ++ Seq( - packageJavaClasspathJar / mappings := Nil, - packageJavaClasspathJar / artifactClassifier := Option("classpath"), - packageJavaClasspathJar / packageOptions := { - val classpath = (packageJavaClasspathJar / scriptClasspath ).value + .packageTaskSettings(packageJavaClasspathJar, packageJavaClasspathJar / mappings) ++ Seq( + packageJavaClasspathJar / mappings := Nil, + packageJavaClasspathJar / artifactClassifier := Option("classpath"), + packageJavaClasspathJar / packageOptions := { + val classpath = (packageJavaClasspathJar / scriptClasspath).value val manifestClasspath = Attributes.Name.CLASS_PATH -> classpath.mkString(" ") Seq(ManifestAttributes(manifestClasspath)) }, - packageJavaClasspathJar / artifactName := { (scalaVersion, moduleId, artifact) => + packageJavaClasspathJar / artifactName := { (scalaVersion, moduleId, artifact) => moduleId.organization + "." + artifact.name + "-" + moduleId.revision + artifact.classifier.fold("")("-" + _) + "." + artifact.extension }, - bashScriptDefines / scriptClasspath := Seq((packageJavaClasspathJar / artifactPath ).value.getName), - batScriptReplacements/ scriptClasspath := Seq((packageJavaClasspathJar / artifactPath ).value.getName), + bashScriptDefines / scriptClasspath := Seq((packageJavaClasspathJar / artifactPath).value.getName), + batScriptReplacements / scriptClasspath := Seq((packageJavaClasspathJar / artifactPath).value.getName), Universal / mappings += { val classpathJar = packageJavaClasspathJar.value classpathJar -> ("lib/" + classpathJar.getName) diff --git a/src/main/scala/com/typesafe/sbt/packager/jar/LauncherJarPlugin.scala b/src/main/scala/com/typesafe/sbt/packager/jar/LauncherJarPlugin.scala index d9a831737..ae32b4471 100644 --- a/src/main/scala/com/typesafe/sbt/packager/jar/LauncherJarPlugin.scala +++ b/src/main/scala/com/typesafe/sbt/packager/jar/LauncherJarPlugin.scala @@ -24,26 +24,26 @@ object LauncherJarPlugin extends AutoPlugin { override def requires = JavaAppPackaging override lazy val projectSettings: Seq[Setting[_]] = Defaults - .packageTaskSettings(packageJavaLauncherJar, packageJavaLauncherJar / mappings ) ++ Seq( - packageJavaLauncherJar / mappings := Nil, - packageJavaLauncherJar / artifactClassifier := Option("launcher"), - packageJavaLauncherJar / packageOptions := { - val classpath = (packageJavaLauncherJar / scriptClasspath ).value + .packageTaskSettings(packageJavaLauncherJar, packageJavaLauncherJar / mappings) ++ Seq( + packageJavaLauncherJar / mappings := Nil, + packageJavaLauncherJar / artifactClassifier := Option("launcher"), + packageJavaLauncherJar / packageOptions := { + val classpath = (packageJavaLauncherJar / scriptClasspath).value val manifestClasspath = Attributes.Name.CLASS_PATH -> classpath.mkString(" ") val manifestMainClass = (Compile / packageJavaLauncherJar / mainClass).value.map(Attributes.Name.MAIN_CLASS -> _) Seq(ManifestAttributes(manifestMainClass.toSeq :+ manifestClasspath: _*)) }, - packageJavaLauncherJar / artifactName := { (scalaVersion, moduleId, artifact) => + packageJavaLauncherJar / artifactName := { (scalaVersion, moduleId, artifact) => moduleId.organization + "." + artifact.name + "-" + moduleId.revision + artifact.classifier.fold("")("-" + _) + "." + artifact.extension }, Compile / bashScriptDefines / mainClass := { - Some(s"""-jar "$$lib_dir/${(packageJavaLauncherJar / artifactPath ).value.getName}"""") + Some(s"""-jar "$$lib_dir/${(packageJavaLauncherJar / artifactPath).value.getName}"""") }, - bashScriptDefines / scriptClasspath := Nil, + bashScriptDefines / scriptClasspath := Nil, Compile / batScriptReplacements / mainClass := { - Some(s"""-jar "%APP_LIB_DIR%\\${(packageJavaLauncherJar / artifactPath ).value.getName}"""") + Some(s"""-jar "%APP_LIB_DIR%\\${(packageJavaLauncherJar / artifactPath).value.getName}"""") }, batScriptReplacements / scriptClasspath := Nil, Universal / mappings += { diff --git a/src/main/scala/com/typesafe/sbt/packager/rpm/RpmPlugin.scala b/src/main/scala/com/typesafe/sbt/packager/rpm/RpmPlugin.scala index 358e6ffd1..ea23a39c9 100644 --- a/src/main/scala/com/typesafe/sbt/packager/rpm/RpmPlugin.scala +++ b/src/main/scala/com/typesafe/sbt/packager/rpm/RpmPlugin.scala @@ -95,34 +95,34 @@ object RpmPlugin extends AutoPlugin { rpmPostun := None, rpmScriptsDirectory := sourceDirectory.value / "rpm" / Names.Scriptlets, // Explicitly defer default settings to generic Linux Settings. - Rpm / maintainerScripts := (Linux / maintainerScripts ).value, - Rpm / packageSummary := (Linux / packageSummary ).value, - Rpm / packageDescription := (Linux / packageDescription ).value, - Rpm / target := target.value / "rpm", - Rpm / name := (Linux / name ).value, - Rpm / packageName := (Linux / packageName ).value, - Rpm / executableScriptName := (Linux / executableScriptName ).value, - rpmDaemonLogFile := s"${(Linux / packageName ).value}.log", - Rpm / daemonStdoutLogFile := Some(rpmDaemonLogFile.value), - Rpm / validatePackageValidators := Seq( - nonEmptyMappings((Rpm / linuxPackageMappings ).value.flatMap(_.mappings)), - filesExist((Rpm / linuxPackageMappings ).value.flatMap(_.mappings)), - checkMaintainer((Rpm / maintainer ).value, asWarning = false), - epochIsNaturalNumber((Rpm / rpmEpoch ).value.getOrElse(0)) + Rpm / maintainerScripts := (Linux / maintainerScripts).value, + Rpm / packageSummary := (Linux / packageSummary).value, + Rpm / packageDescription := (Linux / packageDescription).value, + Rpm / target := target.value / "rpm", + Rpm / name := (Linux / name).value, + Rpm / packageName := (Linux / packageName).value, + Rpm / executableScriptName := (Linux / executableScriptName).value, + rpmDaemonLogFile := s"${(Linux / packageName).value}.log", + Rpm / daemonStdoutLogFile := Some(rpmDaemonLogFile.value), + Rpm / validatePackageValidators := Seq( + nonEmptyMappings((Rpm / linuxPackageMappings).value.flatMap(_.mappings)), + filesExist((Rpm / linuxPackageMappings).value.flatMap(_.mappings)), + checkMaintainer((Rpm / maintainer).value, asWarning = false), + epochIsNaturalNumber((Rpm / rpmEpoch).value.getOrElse(0)) ), // override the linux sourceDirectory setting - Rpm / sourceDirectory := sourceDirectory.value, - Rpm / packageArchitecture := "noarch", + Rpm / sourceDirectory := sourceDirectory.value, + Rpm / packageArchitecture := "noarch", rpmMetadata := RpmMetadata( - (Rpm / packageName ).value, - (Rpm / version ).value.stripSuffix("-SNAPSHOT"), + (Rpm / packageName).value, + (Rpm / version).value.stripSuffix("-SNAPSHOT"), rpmRelease.value, rpmPrefix.value, - (Rpm / packageArchitecture ).value, + (Rpm / packageArchitecture).value, rpmVendor.value, rpmOs.value, - (Rpm / packageSummary ).value, - (Rpm / packageDescription ).value, + (Rpm / packageSummary).value, + (Rpm / packageDescription).value, rpmAutoprov.value, rpmAutoreq.value, rpmEpoch.value @@ -143,8 +143,8 @@ object RpmPlugin extends AutoPlugin { rpmObsoletes.value, rpmConflicts.value ), - Rpm / maintainerScripts := { - val scripts = (Rpm / maintainerScripts ).value + Rpm / maintainerScripts := { + val scripts = (Rpm / maintainerScripts).value if (!rpmBrpJavaRepackJars.value) { val pre = scripts.getOrElse(Names.Pre, Nil) val scriptBits = IO.readStream(RpmPlugin.osPostInstallMacro.openStream, Charset forName "UTF-8") @@ -153,21 +153,21 @@ object RpmPlugin extends AutoPlugin { scripts }, rpmScripts := RpmScripts - .fromMaintainerScripts((Rpm / maintainerScripts ).value, (Rpm / linuxScriptReplacements ).value), + .fromMaintainerScripts((Rpm / maintainerScripts).value, (Rpm / linuxScriptReplacements).value), rpmSpecConfig := RpmSpec( rpmMetadata.value, rpmDescription.value, rpmDependencies.value, rpmSetarch.value, rpmScripts.value, - (Rpm / linuxPackageMappings ).value, - (Rpm / linuxPackageSymlinks ).value, - (Rpm / defaultLinuxInstallLocation ).value + (Rpm / linuxPackageMappings).value, + (Rpm / linuxPackageSymlinks).value, + (Rpm / defaultLinuxInstallLocation).value ), - Rpm / stage := RpmHelper.stage(rpmSpecConfig.value, (Rpm / target ).value, streams.value.log), - Rpm / packageBin / artifactPath := RpmHelper.defaultRpmArtifactPath((Rpm / target ).value, rpmMetadata.value), - Rpm / packageBin := { - val defaultPath = RpmHelper.buildRpm(rpmSpecConfig.value, (Rpm / stage ).value, streams.value.log) + Rpm / stage := RpmHelper.stage(rpmSpecConfig.value, (Rpm / target).value, streams.value.log), + Rpm / packageBin / artifactPath := RpmHelper.defaultRpmArtifactPath((Rpm / target).value, rpmMetadata.value), + Rpm / packageBin := { + val defaultPath = RpmHelper.buildRpm(rpmSpecConfig.value, (Rpm / stage).value, streams.value.log) // `file` points to where buildRpm created the rpm. However we want it to be at `artifactPath`. // If `artifactPath` is not the default value then we need to copy the file. val path = (Rpm / packageBin / artifactPath).value @@ -175,7 +175,7 @@ object RpmPlugin extends AutoPlugin { path }, rpmLint := { - sys.process.Process(Seq("rpmlint", "-v", (Rpm / packageBin ).value.getAbsolutePath)) ! streams.value.log match { + sys.process.Process(Seq("rpmlint", "-v", (Rpm / packageBin).value.getAbsolutePath)) ! streams.value.log match { case 0 => () case x => sys.error("Failed to run rpmlint, exit status: " + x) } @@ -190,5 +190,5 @@ object RpmDeployPlugin extends AutoPlugin { override def requires = RpmPlugin override def projectSettings: Seq[Setting[_]] = - SettingsHelper.makeDeploymentSettings(Rpm, Rpm / packageBin , "rpm") + SettingsHelper.makeDeploymentSettings(Rpm, Rpm / packageBin, "rpm") } diff --git a/src/main/scala/com/typesafe/sbt/packager/windows/WindowsPlugin.scala b/src/main/scala/com/typesafe/sbt/packager/windows/WindowsPlugin.scala index 07685a91a..e310e0744 100644 --- a/src/main/scala/com/typesafe/sbt/packager/windows/WindowsPlugin.scala +++ b/src/main/scala/com/typesafe/sbt/packager/windows/WindowsPlugin.scala @@ -48,53 +48,49 @@ object WindowsPlugin extends AutoPlugin { */ def windowsSettings: Seq[Setting[_]] = Seq( - Windows / sourceDirectory := sourceDirectory.value / "windows", - Windows / target := target.value / "windows", + Windows / sourceDirectory := sourceDirectory.value / "windows", + Windows / target := target.value / "windows", // TODO - Should this use normalized name like the linux guys? - Windows / name := name.value, - Windows / packageName := packageName.value, + Windows / name := name.value, + Windows / packageName := packageName.value, // Defaults so that our simplified building works candleOptions := Seq("-ext", "WixUtilExtension"), lightOptions := Seq("-ext", "WixUIExtension", "-ext", "WixUtilExtension", "-cultures:en-us"), - wixProductId := WixHelper.makeGUID((Windows / packageName ).value + "_wixProductId"), - wixProductUpgradeId := WixHelper.makeGUID((Windows / packageName ).value + "_wixProductUpgradeId"), + wixProductId := WixHelper.makeGUID((Windows / packageName).value + "_wixProductId"), + wixProductUpgradeId := WixHelper.makeGUID((Windows / packageName).value + "_wixProductUpgradeId"), wixMajorVersion := 3, - Windows / maintainer := maintainer.value, - Windows / packageSummary := packageSummary.value, - Windows / packageDescription := packageDescription.value, + Windows / maintainer := maintainer.value, + Windows / packageSummary := packageSummary.value, + Windows / packageDescription := packageDescription.value, wixProductLicense := { // TODO - document this default. - val default = (Windows / sourceDirectory ).value / "License.rtf" + val default = (Windows / sourceDirectory).value / "License.rtf" if (default.exists) Some(default) else None }, wixPackageInfo := WindowsProductInfo( id = wixProductId.value, - title = (Windows / packageSummary ).value, - version = (Windows / version ).value, - maintainer = (Windows / maintainer ).value, - description = (Windows / packageDescription ).value, + title = (Windows / packageSummary).value, + version = (Windows / version).value, + maintainer = (Windows / maintainer).value, + description = (Windows / packageDescription).value, upgradeId = wixProductUpgradeId.value, comments = "TODO - we need comments." // TODO - allow comments ), wixFeatures := Seq.empty, - wixProductConfig := WixHelper.makeWixProductConfig( - (Windows / name ).value, - wixPackageInfo.value, - wixFeatures.value, - wixProductLicense.value - ), + wixProductConfig := WixHelper + .makeWixProductConfig((Windows / name).value, wixPackageInfo.value, wixFeatures.value, wixProductLicense.value), wixConfig := WixHelper.makeWixConfig( - (Windows / name ).value, + (Windows / name).value, wixPackageInfo.value, WixHelper.getNameSpaceDefinitions(wixMajorVersion.value), wixProductConfig.value ), - Windows / wixConfig := wixConfig.value, - Windows / wixProductConfig := wixProductConfig.value, + Windows / wixConfig := wixConfig.value, + Windows / wixProductConfig := wixProductConfig.value, wixFile := { - val config = (Windows / wixConfig ).value - val wixConfigFile = (Windows / target ).value / ((Windows / name ).value + ".wxs") + val config = (Windows / wixConfig).value + val wixConfigFile = (Windows / target).value / ((Windows / name).value + ".wxs") IO.write(wixConfigFile, config.toString) wixConfigFile }, @@ -149,8 +145,8 @@ object WindowsPlugin extends AutoPlugin { */ def mapGenericFilesToWindows: Seq[Setting[_]] = Seq( - Windows / mappings := (Universal / mappings).value, - wixFeatures := makeWindowsFeatures((Windows / packageName ).value, (Windows / mappings ).value) + Windows / mappings := (Universal / mappings).value, + wixFeatures := makeWindowsFeatures((Windows / packageName).value, (Windows / mappings).value) ) /** @@ -222,5 +218,5 @@ object WindowsDeployPlugin extends AutoPlugin { override def requires = WindowsPlugin override def projectSettings: Seq[Setting[_]] = - SettingsHelper.makeDeploymentSettings(Windows, Windows / packageBin , "msi") + SettingsHelper.makeDeploymentSettings(Windows, Windows / packageBin, "msi") }