Skip to content

Commit

Permalink
scalafmt
Browse files Browse the repository at this point in the history
  • Loading branch information
jtjeferreira committed Oct 9, 2024
1 parent 992898b commit 744c533
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 80 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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[_]](
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 += {
Expand Down
66 changes: 33 additions & 33 deletions src/main/scala/com/typesafe/sbt/packager/rpm/RpmPlugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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")
Expand All @@ -153,29 +153,29 @@ 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
if (path.getCanonicalFile != defaultPath.getCanonicalFile) IO.copyFile(defaultPath, path)
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)
}
Expand All @@ -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")
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
},
Expand Down Expand Up @@ -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)
)

/**
Expand Down Expand Up @@ -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")
}

0 comments on commit 744c533

Please sign in to comment.