Skip to content

Commit

Permalink
Merge branch 'master' into update/scalatest-3.2.19
Browse files Browse the repository at this point in the history
  • Loading branch information
muuki88 authored Jul 30, 2024
2 parents 2ea6e83 + 40be500 commit b2d4f3d
Show file tree
Hide file tree
Showing 73 changed files with 328 additions and 276 deletions.
2 changes: 2 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Scala Steward: Reformat with scalafmt 3.8.3
fb3b1e158c70f5b76207764dc42b128cb878b3be
2 changes: 1 addition & 1 deletion .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Version https://scalameta.org/scalafmt/docs/configuration.html#version
version = 3.8.1
version = 3.8.3
# Dialect https://scalameta.org/scalafmt/docs/configuration.html#scala-dialects
runner.dialect = scala212

Expand Down
10 changes: 1 addition & 9 deletions integration-tests-ansible/test-project-play-rpm/build.sbt
Original file line number Diff line number Diff line change
@@ -1,14 +1,6 @@
scalaVersion in ThisBuild := "2.11.6"

scalacOptions in ThisBuild ++= Seq(
"-deprecation",
"-encoding",
"UTF-8",
"-feature",
"-unchecked",
"-Xfuture",
"-Xlint"
)
scalacOptions in ThisBuild ++= Seq("-deprecation", "-encoding", "UTF-8", "-feature", "-unchecked", "-Xfuture", "-Xlint")

name := "test-project-play-rpm"

Expand Down
24 changes: 14 additions & 10 deletions src/main/scala-sbt-0.13/com/typesafe/sbt/packager/Compat.scala
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,15 @@ object Compat {
/**
* Used in:
*
* - [[com.typesafe.sbt.packager.windows.WindowsPlugin]]
* - [[com.typesafe.sbt.packager.rpm.RpmHelper]]
* - [[com.typesafe.sbt.packager.docker.DockerPlugin]]
* - [[com.typesafe.sbt.packager.debian.DebianNativePackaging]]
* - [[com.typesafe.sbt.packager.rpm.RpmPlugin]]
* - [[com.typesafe.sbt.packager.windows.WindowsPlugin]]
* - [[com.typesafe.sbt.packager.rpm.RpmHelper]]
* - [[com.typesafe.sbt.packager.docker.DockerPlugin]]
* - [[com.typesafe.sbt.packager.debian.DebianNativePackaging]]
* - [[com.typesafe.sbt.packager.rpm.RpmPlugin]]
*
* @param log
* @return turns a Logger into a ProcessLogger
* @return
* turns a Logger into a ProcessLogger
*/
implicit def log2ProcessLogger(log: Logger): sys.process.ProcessLogger =
new BufferedLogger(new FullLogger(log)) with sys.process.ProcessLogger {
Expand All @@ -27,17 +28,20 @@ object Compat {
/**
* Used in
*
* - [[com.typesafe.sbt.packager.docker.DockerPlugin]]
* - [[com.typesafe.sbt.packager.docker.DockerPlugin]]
*
* @param logger The sbt.ProcessLogger that should be wrapped
* @return A scala ProcessLogger
* @param logger
* The sbt.ProcessLogger that should be wrapped
* @return
* A scala ProcessLogger
*/
implicit def sbtProcessLogger2ScalaProcessLogger(logger: sbt.ProcessLogger): sys.process.ProcessLogger =
ProcessLogger(msg => logger.info(msg), err => logger.error(err))

/**
* Use in the scripted `universal/multiproject-classifiers` test.
* @param artifact polyfill new methods
* @param artifact
* polyfill new methods
*/
implicit class CompatArtifact(artifact: Artifact) {
def withClassifier(classifier: Option[String]): Artifact =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@ object MappingsHelper {
* return a Seq of mappings which effect is to add a whole directory in the generated package
*
* @example
* {{{
* {{{
* mappings in Universal ++= directory(baseDirectory.value / "extra")
* }}}
* }}}
*
* @param sourceDir
* @return mappings
* @return
* mappings
*/
def directory(sourceDir: File): Seq[(File, String)] =
Option(sourceDir.getParentFile)
Expand All @@ -25,27 +26,29 @@ object MappingsHelper {
* It lightens the build file if one wants to give a string instead of file.
*
* @example
* {{{
* {{{
* mappings in Universal ++= directory("extra")
* }}}
* }}}
*
* @param sourceDir
* @return mappings
* @return
* mappings
*/
def directory(sourceDir: String): Seq[(File, String)] =
directory(file(sourceDir))

/**
* return a Seq of mappings which effect is to add the content of directory in the generated package,
* excluding the directory itself.
* return a Seq of mappings which effect is to add the content of directory in the generated package, excluding the
* directory itself.
*
* @example
* {{{
* {{{
* mappings in Universal ++= sourceDir(baseDirectory.value / "extra")
* }}}
* }}}
*
* @param sourceDir
* @return mappings
* @return
* mappings
*/
def contentOf(sourceDir: File): Seq[(File, String)] =
(sourceDir.*** --- sourceDir) pair relativeTo(sourceDir)
Expand All @@ -54,50 +57,57 @@ object MappingsHelper {
* It lightens the build file if one wants to give a string instead of file.
*
* @example
* {{{
* {{{
* mappings in Universal ++= sourceDir("extra")
* }}}
* }}}
*
* @param sourceDir as string representation
* @return mappings
* @param sourceDir
* as string representation
* @return
* mappings
*/
def contentOf(sourceDir: String): Seq[(File, String)] =
contentOf(file(sourceDir))

/**
* Create mappings from your classpath. For example if you want to add additional
* dependencies, like test or model.
* Create mappings from your classpath. For example if you want to add additional dependencies, like test or model.
*
* @example Add all test artifacts to a separated test folder
* {{{
* @example
* Add all test artifacts to a separated test folder
* {{{
* mappings in Universal ++= fromClasspath((managedClasspath in Test).value, target = "test")
* }}}
* }}}
*
* @param entries
* @param target
* @return a list of mappings
* @return
* a list of mappings
*/
def fromClasspath(entries: Seq[Attributed[File]], target: String): Seq[(File, String)] =
fromClasspath(entries, target, _ => true)

/**
* Create mappings from your classpath. For example if you want to add additional
* dependencies, like test or model. You can also filter the artifacts that should
* be mapped to mappings.
* Create mappings from your classpath. For example if you want to add additional dependencies, like test or model.
* You can also filter the artifacts that should be mapped to mappings.
*
* @example Filter all osgi bundles
* {{{
* @example
* Filter all osgi bundles
* {{{
* mappings in Universal ++= fromClasspath(
* (managedClasspath in Runtime).value,
* "osgi",
* artifact => artifact.`type` == "bundle"
* )
* }}}
* }}}
*
* @param entries from where mappings should be created from
* @param target folder, e.g. `model`. Must not end with a slash
* @param includeArtifact function to determine if an artifact should result in a mapping
* @param includeOnNoArtifact default is false. When there's no Artifact meta data remove it
* @param entries
* from where mappings should be created from
* @param target
* folder, e.g. `model`. Must not end with a slash
* @param includeArtifact
* function to determine if an artifact should result in a mapping
* @param includeOnNoArtifact
* default is false. When there's no Artifact meta data remove it
*/
def fromClasspath(
entries: Seq[Attributed[File]],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ object SettingsHelper {
) ++ addPackage(config, packageTask, extension, classifier) ++ addResolver(config)

/**
* SBT looks in the `otherResolvers` setting for resolvers defined in `publishTo`.
* If a user scopes a `publishTo`, e.g.
* SBT looks in the `otherResolvers` setting for resolvers defined in `publishTo`. If a user scopes a `publishTo`,
* e.g.
*
* {{{
* // publish the rpm to the target folder
Expand All @@ -82,7 +82,8 @@ object SettingsHelper {
*
* then the resolver must also be present in the `otherResolvers`
*
* @param config the ivy configuration to look for resolvers
* @param config
* the ivy configuration to look for resolvers
*/
private def addResolver(config: Configuration): Seq[Setting[_]] =
Seq(otherResolvers ++= (publishTo in config).value.toSeq)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ object DockerPlugin extends AutoPlugin {
* FROM command
*/
private final def makeFromAs(dockerBaseImage: String, name: String): CmdLike =
Cmd("FROM", dockerBaseImage, "as", name)
Cmd("FROM", dockerBaseImage, "AS", name)

/**
* @param label
Expand Down
4 changes: 2 additions & 2 deletions src/sbt-test/ash/add-app-settings/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ TaskKey[Unit]("scriptCheck") := {

TaskKey[Unit]("runCheck") := {
val cwd = (stagingDirectory in Universal).value
val cmd = Seq((cwd / "bin" / packageName.value).getAbsolutePath)
val cmd = Seq((cwd / "bin" / packageName.value).getAbsolutePath)
val output = (sys.process.Process(cmd, cwd).!!).replaceAll("\n", "")

assert(output.contains("info"), s"Application did not receive residual arg 'info'")
assert(output.contains("help"), s"Application did not receive residual arg 'help'")
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
object MainApp extends App {
object MainApp extends App {
println(args.mkString("|"))
}
18 changes: 17 additions & 1 deletion src/sbt-test/ash/command-line-settings/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,23 @@ TaskKey[Unit]("checkResidual") := {
}

TaskKey[Unit]("checkComplexResidual") := {
val args = Seq("-J-Dfoo=bar", "arg1", "--", "-J-Dfoo=bar", "arg 2", "--", "\"", "$foo", "'", "%s", "-y", "bla", "\\'", "\\\"", "''")
val args = Seq(
"-J-Dfoo=bar",
"arg1",
"--",
"-J-Dfoo=bar",
"arg 2",
"--",
"\"",
"$foo",
"'",
"%s",
"-y",
"bla",
"\\'",
"\\\"",
"''"
)
val cwd = (stagingDirectory in Universal).value
val cmd = Seq((cwd / "bin" / packageName.value).getAbsolutePath) ++ args
val expected = """arg1|-J-Dfoo=bar|arg 2|--|"|$foo|'|%s|-y|bla|\'|\"|''"""
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
object MainApp extends App {
object MainApp extends App {
println(sys.props.collect { case (k, v) => s"$k=$v" } mkString "\n")
println(args.mkString("|"))
}
5 changes: 3 additions & 2 deletions src/sbt-test/ash/override-templates/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ TaskKey[Unit]("runCheckAsh") := {
val cwd = (stagingDirectory in Universal).value
val source =
scala.io.Source.fromFile((cwd / "bin" / packageName.value).getAbsolutePath)
val contents = try source.getLines mkString "\n"
finally source.close()
val contents =
try source.getLines mkString "\n"
finally source.close()
assert(
contents contains "this is the custom bash template",
"Bash template didn't contain the right text: \n" + contents
Expand Down
10 changes: 6 additions & 4 deletions src/sbt-test/bash/override-templates/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ TaskKey[Unit]("runCheckBash") := {
val cwd = (stagingDirectory in Universal).value
val source =
scala.io.Source.fromFile((cwd / "bin" / packageName.value).getAbsolutePath)
val contents = try source.getLines mkString "\n"
finally source.close()
val contents =
try source.getLines mkString "\n"
finally source.close()
assert(
contents contains "this is the custom bash template",
"Bash template didn't contain the right text: \n" + contents
Expand All @@ -27,8 +28,9 @@ TaskKey[Unit]("runCheckBat") := {
val batFilename = packageName.value + ".bat"
val source =
scala.io.Source.fromFile((cwd / "bin" / batFilename).getAbsolutePath)
val contents = try source.getLines mkString "\n"
finally source.close()
val contents =
try source.getLines mkString "\n"
finally source.close()
assert(
contents contains "this is the custom bat template",
"Bat template didn't contain the right text: \n" + contents
Expand Down
4 changes: 3 additions & 1 deletion src/sbt-test/debian/file-permissions/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,6 @@ packageSummary := "Test debian package"
packageDescription := """A fun package description of our software,
with multiple lines."""

linuxPackageMappings += packageMapping(((resourceDirectory in Compile).value / "sudoers.d", "/etc/sudoers.d")) withPerms ("0440") asDocs ()
linuxPackageMappings += packageMapping(
((resourceDirectory in Compile).value / "sudoers.d", "/etc/sudoers.d")
) withPerms ("0440") asDocs ()
14 changes: 10 additions & 4 deletions src/sbt-test/debian/systemd-deb/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,21 @@ TaskKey[Unit]("checkEtcDefault") := {

TaskKey[Unit]("checkAutostart") := {
val script = IO.read(target.value / "debian-test-0.1.0" / "DEBIAN" / "postinst")
assert(script.contains("""addService debian-test || echo "debian-test could not be registered"
assert(
script.contains("""addService debian-test || echo "debian-test could not be registered"
|startService debian-test || echo "debian-test could not be started"
|""".stripMargin), "addService, startService post install commands missing or incorrect")
|""".stripMargin),
"addService, startService post install commands missing or incorrect"
)
()
}

TaskKey[Unit]("checkNoAutostart") := {
val script = IO.read(target.value / "debian-test-0.1.0" / "DEBIAN" / "postinst")
assert(script.contains("""addService debian-test || echo "debian-test could not be registered"
|""".stripMargin), "addService post install commands missing or incorrect")
assert(
script.contains("""addService debian-test || echo "debian-test could not be registered"
|""".stripMargin),
"addService post install commands missing or incorrect"
)
()
}
10 changes: 4 additions & 6 deletions src/sbt-test/debian/systemd-deb/src/main/scala/test/Main.scala
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
package test

object Main {
def main (args: Array[String]): Unit = {
//server app imitation
while (true){
def main(args: Array[String]): Unit =
// server app imitation
while (true)
Thread.sleep(1000L)
}
}
}
}
14 changes: 10 additions & 4 deletions src/sbt-test/debian/sysvinit-deb/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,21 @@ TaskKey[Unit]("checkStartupScript") := {

TaskKey[Unit]("checkAutostart") := {
val script = IO.read(target.value / "debian-test-0.1.0" / "DEBIAN" / "postinst")
assert(script.contains("""addService debian-test || echo "debian-test could not be registered"
assert(
script.contains("""addService debian-test || echo "debian-test could not be registered"
|startService debian-test || echo "debian-test could not be started"
|""".stripMargin), "addService, startService post install commands missing or incorrect")
|""".stripMargin),
"addService, startService post install commands missing or incorrect"
)
()
}

TaskKey[Unit]("checkNoAutostart") := {
val script = IO.read(target.value / "debian-test-0.1.0" / "DEBIAN" / "postinst")
assert(script.contains("""addService debian-test || echo "debian-test could not be registered"
|""".stripMargin), "addService post install commands missing or incorrect")
assert(
script.contains("""addService debian-test || echo "debian-test could not be registered"
|""".stripMargin),
"addService post install commands missing or incorrect"
)
()
}
Loading

0 comments on commit b2d4f3d

Please sign in to comment.