Skip to content

Commit 0f69b0c

Browse files
mkurzscala-steward
andauthored
Upgrade to latest sbt-scalafmt and scalafmt (#1596)
* Update sbt-scalafmt to 2.5.2 * Format code * Adjust wrong formatting --------- Co-authored-by: Scala Steward <scala_steward@virtuslab.com>
1 parent 3894d05 commit 0f69b0c

56 files changed

Lines changed: 982 additions & 823 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.scalafmt.conf

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
# Version https://scalameta.org/scalafmt/docs/configuration.html#version
2+
version = 3.8.1
3+
# Dialect https://scalameta.org/scalafmt/docs/configuration.html#scala-dialects
4+
runner.dialect = scala212
5+
16
style = IntelliJ
27
maxColumn = 120
3-
rewrite.rules = [SortImports, RedundantBraces]
8+
rewrite.rules = [SortImports, RedundantBraces]
9+
docstrings.blankFirstLine = yes
10+
11+
project.excludePaths = [
12+
# [error] (Compile / scalafmt) org.scalafmt.sbt.ScalafmtSbtReporter$ScalafmtSbtError: scalafmt:
13+
# WixHelper.scala:105: error: Unable to format file due to bug in scalafmt
14+
"glob:**/src/main/scala/com/typesafe/sbt/packager/windows/WixHelper.scala"
15+
]

project/plugins.sbt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ libraryDependencies += "org.scala-sbt" %% "scripted-plugin" % sbtVersion.value
1010
libraryDependencies += "jline" % "jline" % "2.14.6"
1111

1212
// For code formatting
13-
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.2")
13+
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.5.2")
1414

1515
// binary compatibility checks
1616
addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "1.1.3")

src/main/scala-sbt-1.0/com/typesafe/sbt/packager/Compat.scala

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package com.typesafe.sbt.packager
22

3-
import sbt.{PathFinder, librarymanagement => lm}
3+
import sbt.{librarymanagement => lm, PathFinder}
44
import sbt.internal.{librarymanagement => ilm, BuildDependencies => InternalBuildDependencies}
55
import sbt.util.CacheStore
66

@@ -14,7 +14,7 @@ object Compat {
1414

1515
/**
1616
* Used in
17-
* - [[com.typesafe.sbt.packager.archetypes.JavaAppPackaging]]
17+
* - [[com.typesafe.sbt.packager.archetypes.JavaAppPackaging]]
1818
*/
1919
type BuildDependencies = InternalBuildDependencies
2020

@@ -24,15 +24,16 @@ object Compat {
2424

2525
/**
2626
* Used in
27-
* - [[com.typesafe.sbt.packager.docker.DockerPlugin]]
27+
* - [[com.typesafe.sbt.packager.docker.DockerPlugin]]
2828
*/
2929
type ProcessLogger = sys.process.ProcessLogger
3030

3131
/**
32-
* Used in
33-
* - [[com.typesafe.sbt.packager.Stager]]
32+
* Used in
33+
* - [[com.typesafe.sbt.packager.Stager]]
3434
* @param file
35-
* @return a CacheStore
35+
* @return
36+
* a CacheStore
3637
*/
3738
implicit def fileToCacheStore(file: java.io.File): CacheStore = CacheStore(file)
3839
}

src/main/scala-sbt-1.0/com/typesafe/sbt/packager/MappingsHelper.scala

Lines changed: 31 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,13 @@ object MappingsHelper extends Mapper {
1010
* It lightens the build file if one wants to give a string instead of file.
1111
*
1212
* @example
13-
* {{{
13+
* {{{
1414
* mappings in Universal ++= directory("extra")
15-
* }}}
15+
* }}}
1616
*
1717
* @param sourceDir
18-
* @return mappings
18+
* @return
19+
* mappings
1920
*/
2021
def directory(sourceDir: String): Seq[(File, String)] =
2122
directory(file(sourceDir))
@@ -24,50 +25,57 @@ object MappingsHelper extends Mapper {
2425
* It lightens the build file if one wants to give a string instead of file.
2526
*
2627
* @example
27-
* {{{
28+
* {{{
2829
* mappings in Universal ++= contentOf("extra")
29-
* }}}
30+
* }}}
3031
*
31-
* @param sourceDir as string representation
32-
* @return mappings
32+
* @param sourceDir
33+
* as string representation
34+
* @return
35+
* mappings
3336
*/
3437
def contentOf(sourceDir: String): Seq[(File, String)] =
3538
contentOf(file(sourceDir))
3639

3740
/**
38-
* Create mappings from your classpath. For example if you want to add additional
39-
* dependencies, like test or model.
41+
* Create mappings from your classpath. For example if you want to add additional dependencies, like test or model.
4042
*
41-
* @example Add all test artifacts to a separated test folder
42-
* {{{
43+
* @example
44+
* Add all test artifacts to a separated test folder
45+
* {{{
4346
* mappings in Universal ++= fromClasspath((managedClasspath in Test).value, target = "test")
44-
* }}}
47+
* }}}
4548
*
4649
* @param entries
4750
* @param target
48-
* @return a list of mappings
51+
* @return
52+
* a list of mappings
4953
*/
5054
def fromClasspath(entries: Seq[Attributed[File]], target: String): Seq[(File, String)] =
5155
fromClasspath(entries, target, _ => true)
5256

5357
/**
54-
* Create mappings from your classpath. For example if you want to add additional
55-
* dependencies, like test or model. You can also filter the artifacts that should
56-
* be mapped to mappings.
58+
* Create mappings from your classpath. For example if you want to add additional dependencies, like test or model.
59+
* You can also filter the artifacts that should be mapped to mappings.
5760
*
58-
* @example Filter all osgi bundles
59-
* {{{
61+
* @example
62+
* Filter all osgi bundles
63+
* {{{
6064
* mappings in Universal ++= fromClasspath(
6165
* (managedClasspath in Runtime).value,
6266
* "osgi",
6367
* artifact => artifact.`type` == "bundle"
6468
* )
65-
* }}}
69+
* }}}
6670
*
67-
* @param entries from where mappings should be created from
68-
* @param target folder, e.g. `model`. Must not end with a slash
69-
* @param includeArtifact function to determine if an artifact should result in a mapping
70-
* @param includeOnNoArtifact default is false. When there's no Artifact meta data remove it
71+
* @param entries
72+
* from where mappings should be created from
73+
* @param target
74+
* folder, e.g. `model`. Must not end with a slash
75+
* @param includeArtifact
76+
* function to determine if an artifact should result in a mapping
77+
* @param includeOnNoArtifact
78+
* default is false. When there's no Artifact meta data remove it
7179
*/
7280
def fromClasspath(
7381
entries: Seq[Attributed[File]],

src/main/scala-sbt-1.0/com/typesafe/sbt/packager/SettingsHelper.scala

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ import sbt.librarymanagement.{IvyFileConfiguration, PublishConfiguration}
66
import com.typesafe.sbt.packager.Compat._
77

88
/**
9-
* TODO write tests for the SettingsHelper
10-
* TODO document methods properly
11-
* TODO document the sbt internal stuff that is used
9+
* - TODO write tests for the SettingsHelper
10+
* - TODO document methods properly
11+
* - TODO document the sbt internal stuff that is used
1212
*/
1313
object SettingsHelper {
1414

@@ -78,8 +78,8 @@ object SettingsHelper {
7878
) ++ addPackage(config, packageTask, extension, classifier) ++ addResolver(config)
7979

8080
/**
81-
* SBT looks in the `otherResolvers` setting for resolvers defined in `publishTo`.
82-
* If a user scopes a `publishTo`, e.g.
81+
* SBT looks in the `otherResolvers` setting for resolvers defined in `publishTo`. If a user scopes a `publishTo`,
82+
* e.g.
8383
*
8484
* {{{
8585
* // publish the rpm to the target folder
@@ -88,7 +88,8 @@ object SettingsHelper {
8888
*
8989
* then the resolver must also be present in the `otherResolvers`
9090
*
91-
* @param config the ivy configuration to look for resolvers
91+
* @param config
92+
* the ivy configuration to look for resolvers
9293
*/
9394
private def addResolver(config: Configuration): Seq[Setting[_]] =
9495
Seq(otherResolvers ++= (publishTo in config).value.toSeq)

src/main/scala/com/typesafe/sbt/PackagerPlugin.scala

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -8,24 +8,20 @@ import sbt._
88
import sbt.Keys.{name, normalizedName, packageBin, streams}
99

1010
/**
11-
* == SBT Native Packager Plugin ==
11+
* ==SBT Native Packager Plugin==
1212
*
13-
* This is the top level plugin for the sbt native packager.
14-
* You don't have to enable this by yourself, instead we recommend
15-
* using an archetype for this.
13+
* This is the top level plugin for the sbt native packager. You don't have to enable this by yourself, instead we
14+
* recommend using an archetype for this.
1615
*
1716
* Currently you can choose between
1817
*
19-
* <ul>
20-
* <li>JavaAppPackaging</li>
21-
* <li>JavaServerPackaging</li>
22-
* <li>AkkaAppPackging</li>
23-
* </ul>
18+
* - JavaAppPackaging
19+
* - JavaServerPackaging
20+
* - AkkaAppPackging
2421
*
25-
* == Configuration ==
22+
* ==Configuration==
2623
*
27-
* The are a few settings you should set if you want to build package
28-
* no matter what format.
24+
* The are a few settings you should set if you want to build package no matter what format.
2925
*
3026
* {{{
3127
* maintainer := "Your name <your.name@your-company.org>"
@@ -34,10 +30,11 @@ import sbt.Keys.{name, normalizedName, packageBin, streams}
3430
*
3531
* For all other general settings take a look at [[com.typesafe.sbt.packager.NativePackagerKeys]]
3632
*
37-
* @example Enable the plugin in the `build.sbt`
38-
* {{{
33+
* @example
34+
* Enable the plugin in the `build.sbt`
35+
* {{{
3936
* enablePlugins(SbtNativePackager)
40-
* }}}
37+
* }}}
4138
*/
4239
object SbtNativePackager extends AutoPlugin {
4340

@@ -56,16 +53,16 @@ object SbtNativePackager extends AutoPlugin {
5653
/**
5754
* imports all [[com.typesafe.sbt.packager.NativePackagerKeys]] and two objects:
5855
*
59-
* === NativePackagerKeys ===
56+
* ===NativePackagerKeys===
6057
*
61-
* This inclues ''all'' available keys provided by the sbt-native-packager.
62-
* Used it if a setting/task key is not in scope.
58+
* This inclues ''all'' available keys provided by the sbt-native-packager. Used it if a setting/task key is not in
59+
* scope.
6360
*
6461
* {{{
6562
* NativePackagerKeys.notAutomaticallyImported := "cool!"
6663
* }}}
6764
*
68-
* === NativePackagerHelper ===
65+
* ===NativePackagerHelper===
6966
*
7067
* This object contains a set of helper methods for working with mappings.
7168
*/
@@ -106,7 +103,7 @@ object SbtNativePackager extends AutoPlugin {
106103
object packageArchetype {
107104

108105
/**
109-
* == Recommended usage ==
106+
* ==Recommended usage==
110107
*
111108
* {{{
112109
* enablePlugins(JavaAppPackaging)

src/main/scala/com/typesafe/sbt/packager/FileUtil.scala

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ object chmod {
1717
* Using java 7 nio API to set the permissions.
1818
*
1919
* @param file
20-
* @param perms in octal format
20+
* @param perms
21+
* in octal format
2122
*/
2223
def apply(file: File, perms: String): Unit = {
2324
val posix = permissions(perms)
@@ -41,14 +42,15 @@ object chmod {
4142
}
4243

4344
/**
44-
* Converts a octal unix permission representation into
45-
* a java `PosiFilePermissions` compatible string.
45+
* Converts a octal unix permission representation into a java `PosiFilePermissions` compatible string.
4646
*/
4747
object permissions {
4848

4949
/**
50-
* @param perms in octal format
51-
* @return java 7 posix file permissions
50+
* @param perms
51+
* in octal format
52+
* @return
53+
* java 7 posix file permissions
5254
*/
5355
def apply(perms: String): java.util.Set[PosixFilePermission] =
5456
PosixFilePermissions fromString convert(perms)
@@ -86,10 +88,10 @@ object permissions {
8688
object sourceDateEpoch {
8789

8890
/**
89-
* If the SOURCE_DATE_EPOCH environment variable is defined, change the mtime of the file (and
90-
* all children recursively) to the epoch value. This is useful when trying to create
91-
* reproducible builds since some packaging tools (e.g. tar, gzip) embed last modified times
92-
* in the package. If the environment variable is not defined, this does nothing.
91+
* If the SOURCE_DATE_EPOCH environment variable is defined, change the mtime of the file (and all children
92+
* recursively) to the epoch value. This is useful when trying to create reproducible builds since some packaging
93+
* tools (e.g. tar, gzip) embed last modified times in the package. If the environment variable is not defined, this
94+
* does nothing.
9395
*/
9496
def apply(file: File): Unit =
9597
sys.env.get("SOURCE_DATE_EPOCH").foreach { epoch =>

src/main/scala/com/typesafe/sbt/packager/Hashing.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ object Hashing {
2828
}
2929

3030
def convertToHex(data: Array[Byte]): String = {
31-
//TODO - use java.lang.Integer.toHexString() ?
31+
// TODO - use java.lang.Integer.toHexString() ?
3232
val buf = new StringBuffer
3333
def byteToHex(b: Int) =
3434
if ((0 <= b) && (b <= 9)) ('0' + b).toChar

src/main/scala/com/typesafe/sbt/packager/Keys.scala

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,20 +23,18 @@ trait NativePackagerKeys {
2323

2424
/**
2525
* This Keys object can be used for
26-
* <ul>
27-
* <li>non autoplugin builds</li>
28-
* <li>import single keys, which are not inside the autoImport</li>
29-
* </ul>
26+
* - non autoplugin builds
27+
* - import single keys, which are not inside the autoImport
3028
*
31-
* == Non autoplugin builds ==
29+
* ==Non autoplugin builds==
3230
*
3331
* {{{
3432
* import com.typesafe.sbt.packager.Keys._
3533
*
3634
* packageName := ""
3735
* }}}
3836
*
39-
* == autoplugin builds ==
37+
* ==autoplugin builds==
4038
*
4139
* {{{
4240
* NativePackagerKeys.packageName := ""

src/main/scala/com/typesafe/sbt/packager/Stager.scala

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,19 @@ object Stager {
1111
/**
1212
* create a cache and sync files if needed
1313
*
14-
* @param config - create a configuration specific cache directory
15-
* @param cacheDirectory - e.g. streams.value.cacheDirectory
16-
* @param stageDirectory - staging directory
17-
* @param mappings - staging content
18-
*
19-
* @example {{{
20-
*
21-
* }}}
14+
* @param config
15+
* create a configuration specific cache directory
16+
* @param cacheDirectory
17+
* e.g. streams.value.cacheDirectory
18+
* @param stageDirectory
19+
* staging directory
20+
* @param mappings
21+
* staging content
2222
*/
2323
def stageFiles(config: String)(cacheDirectory: File, stageDirectory: File, mappings: Seq[(File, String)]): File = {
2424
val cache = cacheDirectory / ("packager-mappings-" + config)
25-
val copies = mappings map {
26-
case (file, path) => file -> (stageDirectory / path)
25+
val copies = mappings map { case (file, path) =>
26+
file -> (stageDirectory / path)
2727
}
2828
Sync(cache, FileInfo.hash, FileInfo.exists)(copies)
2929
// Now set scripts to executable using Java's lack of understanding of permissions.
@@ -38,7 +38,8 @@ object Stager {
3838
}
3939

4040
/**
41-
* @see stageFiles
41+
* @see
42+
* stageFiles
4243
*/
4344
def stage(config: String)(streams: TaskStreams, stageDirectory: File, mappings: Seq[(File, String)]): File =
4445
stageFiles(config)(streams.cacheDirectory, stageDirectory, mappings)

0 commit comments

Comments
 (0)