Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

migrate to slash syntax #1636

Merged
merged 16 commits into from
Oct 13, 2024
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 3 additions & 7 deletions .github/workflows/validate-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -183,14 +183,10 @@ jobs:
key: ${{ runner.os }}-ivy-${{ hashFiles('**/*.sbt') }}
restore-keys: |
${{ runner.os }}-ivy-
- name: Download JDK 1.8
run: wget -O zulu-jdk.tar.gz https://cdn.azul.com/zulu/bin/zulu8.38.0.13-ca-fx-jdk8.0.212-linux_x64.tar.gz
- name: Set up JDK 1.8
uses: actions/setup-java@v1
- name: Set up Azul JDK 1.8 and SBT
uses: olafurpg/setup-scala@v10
with:
java-version: 1.8
# the standard zulu dist doesn't include javafx
jdkFile: 'zulu-jdk.tar.gz'
java-version: [email protected]
- name: Validate
run: sbt "^validateJdkPackagerTravis"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,5 +92,5 @@ object SettingsHelper {
* the ivy configuration to look for resolvers
*/
private def addResolver(config: Configuration): Seq[Setting[_]] =
Seq(otherResolvers ++= (publishTo in config).value.toSeq)
Seq(otherResolvers ++= (config / publishTo).value.toSeq)
}
16 changes: 8 additions & 8 deletions src/main/scala/com/typesafe/sbt/PackagerPlugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,14 @@ object SbtNativePackager extends AutoPlugin {

@deprecated("Use enablePlugins(xxxDeployPlugin)", "1.x")
def deploymentSettings =
makeDeploymentSettings(Debian, packageBin in Debian, "deb") ++
makeDeploymentSettings(Rpm, packageBin in Rpm, "rpm") ++
makeDeploymentSettings(Windows, packageBin in Windows, "msi") ++
makeDeploymentSettings(Universal, packageBin in Universal, "zip") ++
addPackage(Universal, packageZipTarball in Universal, "tgz") ++
makeDeploymentSettings(UniversalDocs, packageBin in UniversalDocs, "zip") ++
addPackage(UniversalDocs, packageXzTarball in UniversalDocs, "txz") ++
makeDeploymentSettings(Debian, genChanges in Debian, "changes")
makeDeploymentSettings(Debian, Debian / packageBin, "deb") ++
makeDeploymentSettings(Rpm, Rpm / packageBin, "rpm") ++
makeDeploymentSettings(Windows, Windows / packageBin, "msi") ++
makeDeploymentSettings(Universal, Universal / packageBin, "zip") ++
addPackage(Universal, Universal / packageZipTarball, "tgz") ++
makeDeploymentSettings(UniversalDocs, UniversalDocs / packageBin, "zip") ++
addPackage(UniversalDocs, UniversalDocs / packageXzTarball, "txz") ++
makeDeploymentSettings(Debian, Debian / genChanges, "changes")
}

import autoImport._
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.typesafe.sbt.packager.archetypes

import sbt._
import sbt.{given, _}
jtjeferreira marked this conversation as resolved.
Show resolved Hide resolved
import sbt.Keys._
import com.typesafe.sbt.SbtNativePackager.{Debian, Universal}
import com.typesafe.sbt.packager._
Expand Down Expand Up @@ -44,31 +44,31 @@ object JavaAppPackaging extends AutoPlugin {

override def projectSettings =
Seq(
javaOptions in Universal := Nil,
Universal / javaOptions := Nil,
// Here we record the classpath as it's added to the mappings separately, so
// we can use its order to generate the bash/bat scripts.
scriptClasspathOrdering := Nil,
// Note: This is sometimes on the classpath via dependencyClasspath in Runtime.
// Note: This is sometimes on the classpath via Runtime / dependencyClasspath.
// We need to figure out why sometimes the Attributed[File] is correctly configured
// and sometimes not.
scriptClasspathOrdering += {
val jar = (packageBin in Compile).value
val jar = (Compile / packageBin).value
val id = projectID.value
val art = (artifact in Compile in packageBin).value
val art = (Compile / packageBin / artifact).value
jar -> ("lib/" + makeJarName(id.organization, id.name, id.revision, art.name, art.classifier))
},
projectDependencyArtifacts := findProjectDependencyArtifacts.value,
scriptClasspathOrdering ++= universalDepMappings(
(dependencyClasspath in Runtime).value,
(Runtime / dependencyClasspath).value,
projectDependencyArtifacts.value
),
scriptClasspathOrdering := scriptClasspathOrdering.value.distinct,
mappings in Universal ++= scriptClasspathOrdering.value,
Universal / mappings ++= scriptClasspathOrdering.value,
scriptClasspath := makeRelativeClasspathNames(scriptClasspathOrdering.value),
linuxPackageMappings in Debian += {
val name = (packageName in Debian).value
Debian / linuxPackageMappings += {
val name = (Debian / packageName).value
val installLocation = defaultLinuxInstallLocation.value
val targetDir = (target in Debian).value
val targetDir = (Debian / target).value
// create empty var/log directory
val d = targetDir / installLocation
d.mkdirs()
Expand Down Expand Up @@ -153,8 +153,8 @@ object JavaAppPackaging extends AutoPlugin {
stateTask.flatMap { state =>
val extracted = Project.extract(state)
// TODO - Is this correct?
val module = extracted.get(projectID in ref)
val artifactTask = extracted.get(packagedArtifacts in ref)
val module = extracted.get(ref / projectID)
val artifactTask = extracted.get(ref / packagedArtifacts)
for {
arts <- artifactTask
} yield for {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,23 +50,23 @@ object JavaServerAppPackaging extends AutoPlugin {
*/
def linuxSettings: Seq[Setting[_]] =
Seq(
javaOptions in Linux := (javaOptions in Universal).value,
Linux / javaOptions := (Universal / javaOptions).value,
// === logging directory mapping ===
linuxPackageMappings += {
packageTemplateMapping(defaultLinuxLogsLocation.value + "/" + (packageName in Linux).value)()
.withUser((daemonUser in Linux).value)
.withGroup((daemonGroup in Linux).value)
packageTemplateMapping(defaultLinuxLogsLocation.value + "/" + (Linux / packageName).value)()
.withUser((Linux / daemonUser).value)
.withGroup((Linux / daemonGroup).value)
.withPerms("755")
},
linuxPackageSymlinks += {
val name = (packageName in Linux).value
val name = (Linux / packageName).value
LinuxSymlink(
defaultLinuxInstallLocation.value + "/" + name + "/logs",
defaultLinuxLogsLocation.value + "/" + name
)
},
// === etc config mapping ===
bashScriptEnvConfigLocation := Some("/etc/default/" + (packageName in Linux).value),
bashScriptEnvConfigLocation := Some("/etc/default/" + (Linux / packageName).value),
linuxStartScriptName := None,
daemonStdoutLogFile := None
)
Expand All @@ -78,7 +78,7 @@ object JavaServerAppPackaging extends AutoPlugin {
linuxEtcDefaultTemplate := getEtcTemplateSource(sourceDirectory.value, (serverLoading ?? None).value),
makeEtcDefault := makeEtcDefaultScript(
packageName.value,
(target in Universal).value,
(Universal / target).value,
linuxEtcDefaultTemplate.value,
linuxScriptReplacements.value
),
Expand All @@ -95,8 +95,8 @@ object JavaServerAppPackaging extends AutoPlugin {
linuxScriptReplacements += Names.DaemonStdoutLogFileReplacement -> daemonStdoutLogFile.value.getOrElse(""),
// === Maintainer scripts ===
maintainerScripts := {
val scripts = (maintainerScripts in Debian).value
val replacements = (linuxScriptReplacements in Debian).value
val scripts = (Debian / maintainerScripts).value
val replacements = (Debian / linuxScriptReplacements).value
val contentOf = getScriptContent(Debian, replacements) _

scripts ++ Map(
Expand All @@ -109,10 +109,10 @@ object JavaServerAppPackaging extends AutoPlugin {
)
) ++ Seq(
// === Daemon User and Group ===
daemonUser in Debian := (daemonUser in Linux).value,
daemonUserUid in Debian := (daemonUserUid in Linux).value,
daemonGroup in Debian := (daemonGroup in Linux).value,
daemonGroupGid in Debian := (daemonGroupGid in Linux).value
Debian / daemonUser := (Linux / daemonUser).value,
Debian / daemonUserUid := (Linux / daemonUserUid).value,
Debian / daemonGroup := (Linux / daemonGroup).value,
Debian / daemonGroupGid := (Linux / daemonGroupGid).value
)
}

Expand All @@ -133,15 +133,15 @@ object JavaServerAppPackaging extends AutoPlugin {
)
) ++ Seq(
// === Daemon User and Group ===
daemonUser in Rpm := (daemonUser in Linux).value,
daemonUserUid in Rpm := (daemonUserUid in Linux).value,
daemonGroup in Rpm := (daemonGroup in Linux).value,
daemonGroupGid in Rpm := (daemonGroupGid in Linux).value,
Rpm / daemonUser := (Linux / daemonUser).value,
Rpm / daemonUserUid := (Linux / daemonUserUid).value,
Rpm / daemonGroup := (Linux / daemonGroup).value,
Rpm / daemonGroupGid := (Linux / daemonGroupGid).value,
// == Maintainer scripts ===
maintainerScripts in Rpm := rpmScriptletContents(
Rpm / maintainerScripts := rpmScriptletContents(
rpmScriptsDirectory.value,
(maintainerScripts in Rpm).value,
(linuxScriptReplacements in Rpm).value
(Rpm / maintainerScripts).value,
(Rpm / linuxScriptReplacements).value
)
)

Expand Down Expand Up @@ -209,7 +209,7 @@ object JavaServerAppPackaging extends AutoPlugin {
* @param name
* of the etc-default config file
* @param tmpDir
* to store the resulting file in (e.g. target in Universal)
* to store the resulting file in (e.g. Universal / target)
* @param source
* of etc-default script
* @param replacements
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ trait MaintainerScriptHelper {
* @example
* {{{
* import DebianConstants._
* maintainerScripts in Debian := maintainerScriptsFromDirectory(
* Debian / maintainerScripts := maintainerScriptsFromDirectory(
* sourceDirectory.value / DebianSource / DebianMaintainerScripts, Seq(Preinst, Postinst, Prerm, Postrm)
* )
* }}}
Expand All @@ -43,29 +43,29 @@ trait MaintainerScriptHelper {
* Adding content from a string
* {{{
* import RpmConstants._
* maintainerScripts in Rpm := maintainerScriptsAppend((maintainerScripts in Rpm).value)(
* Rpm / maintainerScripts := maintainerScriptsAppend((Rpm / maintainerScripts).value)(
* Pretrans -> "echo 'hello, world'",
* Post -> "echo 'installing " + (packageName in Rpm).value + "'"
* Post -> "echo 'installing " + (Rpm / packageName).value + "'"
* )
* }}}
*
* @example
* Adding content from a string and use script replacements
* {{{
* import DebianConstants._
* maintainerScripts in Rpm := maintainerScriptsAppend(
* (maintainerScripts in Debian).value,
* (linuxScriptReplacements in Debian).value
* Rpm / maintainerScripts := maintainerScriptsAppend(
* (Debian / maintainerScripts).value,
* (Debian / linuxScriptReplacements).value
* )(
* Preinst -> "echo 'hello, world'",
* Postinst -> s"echo 'installing ${(packageName in Debian).value}'"
* Postinst -> s"echo 'installing ${(Debian packageName).value}'"
* )
* }}}
*
* @param current
* maintainer scripts
* @param replacements
* (e.g. (linuxScriptReplacements in Debian).value)
* (e.g. (Debian / linuxScriptReplacements).value)
* @param scripts
* scriptName -> scriptContent pairs
* @return
Expand All @@ -90,7 +90,7 @@ trait MaintainerScriptHelper {
* Adding content from a string
* {{{
* import RpmConstants._
* maintainerScripts in Rpm := maintainerScriptsAppendFromFile((maintainerScripts in Rpm).value)(
* Rpm / maintainerScripts := maintainerScriptsAppendFromFile((Rpm / maintainerScripts).value)(
* Pretrans -> (sourceDirectory.value / "rpm" / "pretrans"),
* Post -> (sourceDirectory.value / "rpm" / "posttrans")
* )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ trait ApplicationIniGenerator {
// TODO: merge JVM options into the existing application.ini?
log.warn("--------!!! JVM Options are defined twice !!!-----------")
log.warn(
"application.ini is already present in output package. Will be overridden by 'javaOptions in Universal'"
"application.ini is already present in output package. Will be overridden by 'Universal / javaOptions'"
)
false

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ object AshScriptPlugin extends AutoPlugin {
bashScriptTemplateLocation := (sourceDirectory.value / "templates" / ashTemplate),
bashForwarderTemplateLocation := Some(sourceDirectory.value / "templates" / ashForwarderTemplate),
bashScriptDefines := Defines(
(scriptClasspath in bashScriptDefines).value,
(bashScriptDefines / scriptClasspath).value,
bashScriptConfigLocation.value,
bundledJvmLocation.value
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ object BashStartScriptPlugin extends AutoPlugin with ApplicationIniGenerator wit
bashForwarderTemplateLocation := Some(sourceDirectory.value / "templates" / forwarderTemplateName),
bashScriptExtraDefines := Nil,
bashScriptDefines := Defines(
(scriptClasspath in bashScriptDefines).value,
(bashScriptDefines / scriptClasspath).value,
bashScriptConfigLocation.value,
bundledJvmLocation.value
),
Expand All @@ -69,27 +69,27 @@ object BashStartScriptPlugin extends AutoPlugin with ApplicationIniGenerator wit
bashScriptConfigLocation := (bashScriptConfigLocation ?? Some(appIniLocation)).value,
bashScriptEnvConfigLocation := (bashScriptEnvConfigLocation ?? None).value,
// Generating the application configuration
mappings in Universal := generateApplicationIni(
(mappings in Universal).value,
(javaOptions in Universal).value,
Universal / mappings := generateApplicationIni(
(Universal / mappings).value,
(Universal / javaOptions).value,
bashScriptConfigLocation.value,
(target in Universal).value,
(Universal / target).value,
streams.value.log
),
makeBashScripts := generateStartScripts(
BashScriptConfig(
executableScriptName = executableScriptName.value,
scriptClasspath = (scriptClasspath in bashScriptDefines).value,
scriptClasspath = (bashScriptDefines / scriptClasspath).value,
replacements = bashScriptReplacements.value,
templateLocation = bashScriptTemplateLocation.value,
forwarderTemplateLocation = bashForwarderTemplateLocation.value
),
(mainClass in (Compile, bashScriptDefines)).value,
(discoveredMainClasses in Compile).value,
(target in Universal).value / "scripts",
(Compile / bashScriptDefines / mainClass).value,
(Compile / discoveredMainClasses).value,
(Universal / target).value / "scripts",
streams.value.log
),
mappings in Universal ++= makeBashScripts.value
Universal / mappings ++= makeBashScripts.value
)

private[this] def generateScriptReplacements(defines: Seq[String]): Seq[(String, String)] = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,30 +134,30 @@ object BatStartScriptPlugin extends AutoPlugin with ApplicationIniGenerator with
batScriptExtraDefines := Nil,
batScriptReplacements := Replacements(executableScriptName.value),
// Generating the application configuration
mappings in Universal := generateApplicationIni(
(mappings in Universal).value,
(javaOptions in Universal).value,
Universal / mappings := generateApplicationIni(
(Universal / mappings).value,
(Universal / javaOptions).value,
batScriptConfigLocation.value,
(target in Universal).value,
(Universal / target).value,
streams.value.log
),
makeBatScripts := generateStartScripts(
BatScriptConfig(
executableScriptName = executableScriptName.value,
scriptClasspath = (scriptClasspath in batScriptReplacements).value,
scriptClasspath = (batScriptReplacements / scriptClasspath).value,
configLocation = batScriptConfigLocation.value,
extraDefines = batScriptExtraDefines.value,
replacements = batScriptReplacements.value,
templateLocation = batScriptTemplateLocation.value,
bundledJvmLocation = bundledJvmLocation.value,
forwarderTemplateLocation = batForwarderTemplateLocation.value
),
(mainClass in (Compile, batScriptReplacements)).value,
(discoveredMainClasses in Compile).value,
(target in Universal).value / "scripts",
(Compile / batScriptReplacements / mainClass).value,
(Compile / discoveredMainClasses).value,
(Universal / target).value / "scripts",
streams.value.log
),
mappings in Universal ++= makeBatScripts.value
Universal / mappings ++= makeBatScripts.value
)

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ object StartScriptMainClassConfig {

/**
* @param mainClass
* optional main class, e.g. from (mainClass in Compile).value
* optional main class, e.g. from (Compile / mainClass).value
* @param discoveredMainClasses
* all discovered main classes, e.g. from (discoveredMainClasses in Compile).value
* all discovered main classes, e.g. from (Compile / discoveredMainClasses).value
* @return
* A start script configuration
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ object SystemloaderPlugin extends AutoPlugin {
linuxMakeStartScript := makeStartScript(
linuxStartScriptTemplate.value,
linuxScriptReplacements.value,
(target in Universal).value,
(Universal / target).value,
defaultLinuxStartScriptLocation.value,
linuxStartScriptName.value.getOrElse(sys.error("`linuxStartScriptName` is not defined"))
)
Expand Down Expand Up @@ -111,7 +111,7 @@ object SystemloaderPlugin extends AutoPlugin {
inConfig(Rpm)(
Seq(
// add automatic service start/stop
maintainerScripts in Rpm := maintainerScriptsAppend(maintainerScripts.value, linuxScriptReplacements.value)(
Rpm / maintainerScripts := maintainerScriptsAppend(maintainerScripts.value, linuxScriptReplacements.value)(
RpmConstants.Post -> s"""|# ${getOrUnsupported(serverLoading.value)} support
|$${{loader-functions}}
|# Scriptlet syntax: http://fedoraproject.org/wiki/Packaging:ScriptletSnippets#Syntax
Expand Down
Loading
Loading