Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: scalameta/scalafmt
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v3.4.3
Choose a base ref
...
head repository: scalameta/scalafmt
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v3.7.16
Choose a head ref
Loading
Showing with 21,623 additions and 3,165 deletions.
  1. +38 −13 .github/ISSUE_TEMPLATE.md
  2. +33 −24 .github/workflows/ci.yml
  3. +6 −0 .github/workflows/release-drafter.yml
  4. +8 −5 .github/workflows/release.yml
  5. +1 −1 .scalafmt.conf
  6. +7 −7 bin/install-scalafmt-native.sh
  7. +16 −23 build.sbt
  8. +559 −23 docs/configuration.md
  9. +1 −1 docs/faq.md
  10. +62 −1 docs/installation.md
  11. +7 −5 project/Dependencies.scala
  12. +1 −1 project/build.properties
  13. +11 −11 project/plugins.sbt
  14. +1 −1 readme.md
  15. +2 −2 readme/src/main/scala/org/scalafmt/readme/Readme.scala
  16. +0 −2 ...mt-cli/src/main/resources/META-INF/native-image/org.scalafmt/scalafmt-cli/native-image.properties
  17. +30 −7 scalafmt-cli/src/main/scala/org/scalafmt/cli/Cli.scala
  18. +9 −8 scalafmt-cli/src/main/scala/org/scalafmt/cli/CliArgParser.scala
  19. +22 −7 scalafmt-cli/src/main/scala/org/scalafmt/cli/CliOptions.scala
  20. +15 −7 scalafmt-cli/src/main/scala/org/scalafmt/cli/FileFetchMode.scala
  21. +6 −2 scalafmt-cli/src/main/scala/org/scalafmt/cli/InputMethod.scala
  22. +0 −2 scalafmt-cli/src/main/scala/org/scalafmt/cli/ScalafmtCoreRunner.scala
  23. +0 −2 scalafmt-cli/src/main/scala/org/scalafmt/cli/ScalafmtDynamicRunner.scala
  24. +3 −1 scalafmt-config/jvm/src/main/scala/org/scalafmt/config/PlatformConfig.scala
  25. +14 −13 scalafmt-config/shared/src/main/scala/org/scalafmt/config/ConfParsed.scala
  26. +5 −2 scalafmt-core/shared/src/main/scala/org/scalafmt/Error.scala
  27. +29 −28 scalafmt-core/shared/src/main/scala/org/scalafmt/Scalafmt.scala
  28. +4 −1 scalafmt-core/shared/src/main/scala/org/scalafmt/config/Align.scala
  29. +11 −3 scalafmt-core/shared/src/main/scala/org/scalafmt/config/AlignToken.scala
  30. +2 −1 scalafmt-core/shared/src/main/scala/org/scalafmt/config/BinPack.scala
  31. +2 −1 scalafmt-core/shared/src/main/scala/org/scalafmt/config/Comments.scala
  32. +0 −46 scalafmt-core/shared/src/main/scala/org/scalafmt/config/Config.scala
  33. +5 −1 scalafmt-core/shared/src/main/scala/org/scalafmt/config/Docstrings.scala
  34. +1 −1 scalafmt-core/shared/src/main/scala/org/scalafmt/config/IndentOperator.scala
  35. +26 −0 scalafmt-core/shared/src/main/scala/org/scalafmt/config/Indents.scala
  36. +4 −1 scalafmt-core/shared/src/main/scala/org/scalafmt/config/NamedDialect.scala
  37. +22 −16 scalafmt-core/shared/src/main/scala/org/scalafmt/config/Newlines.scala
  38. +4 −1 scalafmt-core/shared/src/main/scala/org/scalafmt/config/RedundantBracesSettings.scala
  39. +25 −0 scalafmt-core/shared/src/main/scala/org/scalafmt/config/RedundantParensSettings.scala
  40. +46 −0 scalafmt-core/shared/src/main/scala/org/scalafmt/config/ReflectOps.scala
  41. +8 −2 scalafmt-core/shared/src/main/scala/org/scalafmt/config/RewriteSettings.scala
  42. +67 −13 scalafmt-core/shared/src/main/scala/org/scalafmt/config/ScalafmtConfig.scala
  43. +4 −1 scalafmt-core/shared/src/main/scala/org/scalafmt/config/ScalafmtParser.scala
  44. +57 −13 scalafmt-core/shared/src/main/scala/org/scalafmt/config/ScalafmtRunner.scala
  45. +26 −0 scalafmt-core/shared/src/main/scala/org/scalafmt/config/Spaces.scala
  46. +3 −1 scalafmt-core/shared/src/main/scala/org/scalafmt/config/TrailingCommas.scala
  47. +11 −8 scalafmt-core/shared/src/main/scala/org/scalafmt/internal/BestFirstSearch.scala
  48. +656 −586 scalafmt-core/shared/src/main/scala/org/scalafmt/internal/FormatOps.scala
  49. +1 −0 scalafmt-core/shared/src/main/scala/org/scalafmt/internal/FormatToken.scala
  50. +105 −36 scalafmt-core/shared/src/main/scala/org/scalafmt/internal/FormatTokens.scala
  51. +151 −147 scalafmt-core/shared/src/main/scala/org/scalafmt/internal/FormatWriter.scala
  52. +2 −2 scalafmt-core/shared/src/main/scala/org/scalafmt/internal/Indent.scala
  53. +3 −0 scalafmt-core/shared/src/main/scala/org/scalafmt/internal/ModExt.scala
  54. +28 −8 scalafmt-core/shared/src/main/scala/org/scalafmt/internal/Policy.scala
  55. +4 −1 scalafmt-core/shared/src/main/scala/org/scalafmt/internal/PolicySummary.scala
  56. +495 −395 scalafmt-core/shared/src/main/scala/org/scalafmt/internal/Router.scala
  57. +21 −13 scalafmt-core/shared/src/main/scala/org/scalafmt/internal/Split.scala
  58. +1 −0 scalafmt-core/shared/src/main/scala/org/scalafmt/internal/SplitTag.scala
  59. +78 −15 scalafmt-core/shared/src/main/scala/org/scalafmt/internal/State.scala
  60. +2 −4 scalafmt-core/shared/src/main/scala/org/scalafmt/internal/TreeSyntacticGroup.scala
  61. +68 −44 scalafmt-core/shared/src/main/scala/org/scalafmt/rewrite/AvoidInfix.scala
  62. +21 −8 scalafmt-core/shared/src/main/scala/org/scalafmt/rewrite/ConvertToNewScala3Syntax.scala
  63. +119 −63 scalafmt-core/shared/src/main/scala/org/scalafmt/rewrite/FormatTokensRewrite.scala
  64. +47 −31 scalafmt-core/shared/src/main/scala/org/scalafmt/rewrite/Imports.scala
  65. +3 −1 scalafmt-core/shared/src/main/scala/org/scalafmt/rewrite/PreferCurlyFors.scala
  66. +96 −50 scalafmt-core/shared/src/main/scala/org/scalafmt/rewrite/RedundantBraces.scala
  67. +180 −78 scalafmt-core/shared/src/main/scala/org/scalafmt/rewrite/RedundantParens.scala
  68. +21 −16 scalafmt-core/shared/src/main/scala/org/scalafmt/rewrite/RemoveScala3OptionalBraces.scala
  69. +30 −59 scalafmt-core/shared/src/main/scala/org/scalafmt/rewrite/Rewrite.scala
  70. +5 −16 scalafmt-core/shared/src/main/scala/org/scalafmt/rewrite/RewriteTrailingCommas.scala
  71. +10 −19 scalafmt-core/shared/src/main/scala/org/scalafmt/rewrite/SortModifiers.scala
  72. +5 −5 scalafmt-core/shared/src/main/scala/org/scalafmt/util/LoggerOps.scala
  73. +0 −119 scalafmt-core/shared/src/main/scala/org/scalafmt/util/MarkdownFile.scala
  74. +36 −0 scalafmt-core/shared/src/main/scala/org/scalafmt/util/MarkdownParser.scala
  75. +69 −35 scalafmt-core/shared/src/main/scala/org/scalafmt/util/PolicyOps.scala
  76. +18 −22 scalafmt-core/shared/src/main/scala/org/scalafmt/util/StyleMap.scala
  77. +6 −86 scalafmt-core/shared/src/main/scala/org/scalafmt/util/TokenClasses.scala
  78. +1 −35 scalafmt-core/shared/src/main/scala/org/scalafmt/util/TokenOps.scala
  79. +13 −3 scalafmt-core/shared/src/main/scala/org/scalafmt/util/TokenTraverser.scala
  80. +41 −28 scalafmt-core/shared/src/main/scala/org/scalafmt/util/TreeExtractors.scala
  81. +397 −299 scalafmt-core/shared/src/main/scala/org/scalafmt/util/TreeOps.scala
  82. +1 −2 scalafmt-docs/src/main/scala/docs/ScalafmtModifier.scala
  83. +5 −3 scalafmt-docs/src/main/scala/website/package.scala
  84. +0 −5 scalafmt-dynamic/src/main/scala/org/scalafmt/dynamic/ConsoleScalafmtReporter.scala
  85. +9 −3 scalafmt-dynamic/src/main/scala/org/scalafmt/dynamic/CoursierDependencyDownloader.scala
  86. +6 −0 scalafmt-dynamic/src/main/scala/org/scalafmt/dynamic/ScalafmtDynamic.scala
  87. +16 −13 scalafmt-dynamic/src/main/scala/org/scalafmt/dynamic/ScalafmtDynamicError.scala
  88. +1 −2 scalafmt-dynamic/src/main/scala/org/scalafmt/dynamic/ScalafmtDynamicSession.scala
  89. +1 −3 scalafmt-dynamic/src/main/scala/org/scalafmt/dynamic/ScalafmtModuleLoader.scala
  90. +10 −9 scalafmt-dynamic/src/main/scala/org/scalafmt/dynamic/ScalafmtProperties.scala
  91. +25 −18 scalafmt-dynamic/src/main/scala/org/scalafmt/dynamic/ScalafmtReflect.scala
  92. +22 −14 scalafmt-dynamic/src/main/scala/org/scalafmt/dynamic/utils/ReflectUtils.scala
  93. +58 −14 scalafmt-dynamic/src/test/scala/org/scalafmt/dynamic/DynamicSuite.scala
  94. +2 −3 scalafmt-dynamic/src/test/scala/org/scalafmt/dynamic/PositionSyntax.scala
  95. +18 −0 scalafmt-interfaces/src/main/java/org/scalafmt/interfaces/RepositoryCredential.java
  96. +8 −0 scalafmt-interfaces/src/main/java/org/scalafmt/interfaces/Scalafmt.java
  97. +2 −1 scalafmt-interfaces/src/main/java/org/scalafmt/interfaces/ScalafmtReporter.java
  98. +3 −1 scalafmt-sysops/shared/src/main/scala/org/scalafmt/sysops/FileOps.scala
  99. +9 −1 scalafmt-sysops/shared/src/main/scala/org/scalafmt/sysops/GitOps.scala
  100. +2 −1 scalafmt-sysops/shared/src/main/scala/org/scalafmt/sysops/OsSpecific.scala
  101. +253 −0 scalafmt-tests/src/test/resources/align/DefaultWithAlign.stat
  102. +242 −2 scalafmt-tests/src/test/resources/default/Apply.stat
  103. +109 −0 scalafmt-tests/src/test/resources/default/Class.stat
  104. +20 −2 scalafmt-tests/src/test/resources/default/For.stat
  105. +18 −0 scalafmt-tests/src/test/resources/default/If.stat
  106. +16 −2 scalafmt-tests/src/test/resources/default/Lambda.stat
  107. +14 −0 scalafmt-tests/src/test/resources/default/Select.stat
  108. +50 −0 scalafmt-tests/src/test/resources/default/String.stat
  109. +8 −0 scalafmt-tests/src/test/resources/default/Val.stat
  110. +1,632 −30 scalafmt-tests/src/test/resources/newlines/source_classic.stat
  111. +1,530 −31 scalafmt-tests/src/test/resources/newlines/source_fold.stat
  112. +1,705 −141 scalafmt-tests/src/test/resources/newlines/source_keep.stat
  113. +1,688 −140 scalafmt-tests/src/test/resources/newlines/source_unfold.stat
  114. +247 −3 scalafmt-tests/src/test/resources/rewrite/AvoidInfix.stat
  115. +128 −23 scalafmt-tests/src/test/resources/rewrite/AvoidInfix3.stat
  116. +18 −1 scalafmt-tests/src/test/resources/rewrite/ExpandImportSelectors.stat
  117. +144 −4 scalafmt-tests/src/test/resources/rewrite/Imports.source
  118. +36 −0 scalafmt-tests/src/test/resources/rewrite/RedundantBraces.stat
  119. +566 −24 scalafmt-tests/src/test/resources/rewrite/RedundantParens.stat
  120. +8 −0 scalafmt-tests/src/test/resources/rewrite/SortModifiersScala3.stat
  121. +1 −1 scalafmt-tests/src/test/resources/scala3/DependentFunction.stat
  122. +30 −0 scalafmt-tests/src/test/resources/scala3/Extension.stat
  123. +34 −0 scalafmt-tests/src/test/resources/scala3/Match.stat
  124. +1,842 −0 scalafmt-tests/src/test/resources/scala3/OptionalBraces.stat
  125. +1,769 −0 scalafmt-tests/src/test/resources/scala3/OptionalBraces_fold.stat
  126. +1,944 −58 scalafmt-tests/src/test/resources/scala3/OptionalBraces_keep.stat
  127. +1,917 −0 scalafmt-tests/src/test/resources/scala3/OptionalBraces_unfold.stat
  128. +5 −8 scalafmt-tests/src/test/resources/scala3/UnionIntersectionType.stat
  129. +66 −1 scalafmt-tests/src/test/resources/scalajs/DefDef.stat
  130. +13 −2 scalafmt-tests/src/test/resources/test/Dialect.source
  131. +301 −0 scalafmt-tests/src/test/resources/test/IndentOperator.stat
  132. +282 −0 scalafmt-tests/src/test/resources/test/IndentOperatorFormatInfix.stat
  133. +128 −0 scalafmt-tests/src/test/resources/test/JavaDoc.stat
  134. +14 −0 scalafmt-tests/src/test/resources/test/StripMargin.stat
  135. +2 −2 scalafmt-tests/src/test/resources/test/Unicode.stat
  136. +7 −0 scalafmt-tests/src/test/resources/trailing-commas/trailingCommasAlwaysSingleLine.stat
  137. +7 −0 scalafmt-tests/src/test/resources/trailing-commas/trailingCommasNeverSingleLine.stat
  138. +10 −0 scalafmt-tests/src/test/resources/trailing-commas/trailingCommasPreserve.stat
  139. +78 −0 scalafmt-tests/src/test/resources/unit/Apply.stat
  140. +96 −0 scalafmt-tests/src/test/resources/unit/ApplyInfix.stat
  141. +8 −0 scalafmt-tests/src/test/resources/unit/Comment.stat
  142. +62 −0 scalafmt-tests/src/test/resources/unit/DefDef.stat
  143. +17 −0 scalafmt-tests/src/test/resources/unit/Import.source
  144. +20 −0 scalafmt-tests/src/test/resources/unit/Lambda.stat
  145. +31 −0 scalafmt-tests/src/test/resources/unit/Markdown.source
  146. +17 −0 scalafmt-tests/src/test/resources/unit/Type.stat
  147. +24 −1 scalafmt-tests/src/test/resources/vertical-multiline/VerticalMultilineDefnSite.stat
  148. +2 −1 scalafmt-tests/src/test/resources/vertical-multiline/excludeDanglingInDef.stat
  149. +155 −10 scalafmt-tests/src/test/resources/vertical-multiline/verticalMultiline.stat
  150. +58 −0 scalafmt-tests/src/test/scala/org/scalafmt/CustomStructureTest.scala
  151. +7 −8 scalafmt-tests/src/test/scala/org/scalafmt/cli/CliOptionsTest.scala
  152. +14 −10 scalafmt-tests/src/test/scala/org/scalafmt/cli/CliTest.scala
  153. +45 −4 scalafmt-tests/src/test/scala/org/scalafmt/config/ScalafmtConfigTest.scala
  154. +8 −6 scalafmt-tests/src/test/scala/org/scalafmt/sysops/GitOpsTest.scala
  155. +7 −7 scalafmt-tests/src/test/scala/org/scalafmt/util/ErrorTest.scala
  156. +16 −10 scalafmt-tests/src/test/scala/org/scalafmt/util/FormatAssertions.scala
  157. +9 −7 scalafmt-tests/src/test/scala/org/scalafmt/util/HasTests.scala
51 changes: 38 additions & 13 deletions .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,50 @@
This template is a guideline, not a strict requirement.
- **Version**: 0.5
- **Integration**: IntelliJ
- **Configuration**:
This template is mostly a guideline, not a strict requirement, except
the sections marked `(required)`.

Please make sure that the issue is observable using the latest version of `scalafmt` and
within the `scalafmt` **CLI**: `https://scalameta.org/scalafmt/docs/installation.html#cli`

Using the CLI is _mandatory_, in one of these configurations:
- latest version of CLI and latest version in `.scalafmt.conf`
- previous version of CLI and latest version in `.scalafmt.conf`
- latest version of CLI and previous version in `.scalafmt.conf`

## Configuration (required) ##

Please paste the contents of your `.scalafmt.conf` file here:
```
version = 2.0.1
maxColumn = 100
version = <please enter the version here and make sure it's the latest>
...
```

NB: before submitting, please confirm that the problem is observed in the
*latest published* version of the formatter! We don't publish hotfixes for older
versions, and the problem you have observed in an older version may have already
been fixed.

## Command-line parameters (required) ##

When I run scalafmt via CLI like this: `<command-line parameter>`

If you were not using CLI initially:
- please check using `scalafmt` CLI before submitting here (required)
- if the problem does not present via CLI, DO NOT SUBMIT
here: this is NOT a formatter issue
- it could be an issue with your integration (sbt-scalafmt, metals, intellij etc.)
- instead please submit the issue in the appropriate tool's repository
- for instance, if the tool is `sbt` with the `sbt-scalafmt` plugin: please
submit in `sbt-scalafmt` and include scalafmt parameters from `build.sbt`
and the `sbt` command used
- conversely, do not submit formatting issues into other tools; you must first
verify using `scalafmt` CLI

## Steps

Given code like this:
```scala
ORIGINAL CODE
```

When I run scalafmt like this:

```bash
scalafmt
```

## Problem

Scalafmt formats code like this:
@@ -40,4 +65,4 @@ I've found that by...

## Notes

See also..
See also...
57 changes: 33 additions & 24 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -9,24 +9,27 @@ on:
release:
types: [published]

permissions:
contents: read

jobs:
test:
strategy:
fail-fast: false
matrix:
java: [adopt@1.8, adopt@1.11]
java: [ '11', '21' ]
os: [windows-latest, ubuntu-latest]
exclude:
- os: windows-latest
java: adopt@1.8
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- uses: olafurpg/setup-scala@v13
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up JVM
uses: actions/setup-java@v3
with:
java-version: ${{ matrix.java }}
# https://github.com/dwijnand/sbt-dynver#setup
- run: git fetch --tags --unshallow -f
distribution: 'temurin'
cache: 'sbt'
- run:
# for GitOps tests
git config --global user.email "scalafmt@scalameta.org" && git config --global user.name "scalafmt"
@@ -37,12 +40,18 @@ jobs:
formatting:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: olafurpg/setup-scala@v13
- uses: actions/checkout@v4
- uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'temurin'
cache: 'sbt'
- run: ./scalafmt --test
- run: yarn install
- run: yarn format-check
native-image:
permissions:
contents: write # for actions/upload-release-asset to upload release asset
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
@@ -67,18 +76,18 @@ jobs:
artifact: scalafmt-linux-musl
env:
NATIVE_IMAGE_STATIC: true
NATIVE_IMAGE_MUSL: /home/runner/work/scalafmt/scalafmt/bundle
NATIVE_IMAGE_MUSL: true
env: ${{ matrix.env }}
steps:
- uses: actions/checkout@v2
- uses: olafurpg/setup-scala@v13
- uses: actions/checkout@v4
- name: Set up GraalVM
uses: graalvm/setup-graalvm@v1
with:
java-version: graalvm-ce-java11@20.1.0
- if: matrix.libc == 'musl'
name: Install musl bundle
run: |
wget https://github.com/gradinac/musl-bundle-example/releases/download/v1.0/musl.tar.gz
tar xvf musl.tar.gz
version: '22.3.0'
java-version: '11'
components: 'native-image'
native-image-musl: ${{ matrix.libc == 'musl' }}
github-token: ${{ secrets.GITHUB_TOKEN }}
- run: bin/build-native-image.sh
env:
CI: true
@@ -102,25 +111,25 @@ jobs:
if: startsWith(github.ref, 'refs/tags/v') && github.event_name != 'release'
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Docker Meta
id: meta
uses: docker/metadata-action@v3
uses: docker/metadata-action@v5
with:
images: scalameta/scalafmt
tags: type=semver,pattern={{raw}}
- name: Downloading scalafmt-linux-musl for Docker Build
uses: actions/download-artifact@v2.1.0
uses: actions/download-artifact@v3
with:
name: scalafmt-linux-musl
path: tmp/scalafmt-linux-musl
- name: Login to DockerHub
uses: docker/login-action@v1
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and push
uses: docker/build-push-action@v2
uses: docker/build-push-action@v5
with:
context: .
push: true
6 changes: 6 additions & 0 deletions .github/workflows/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -5,8 +5,14 @@ on:
branches:
- master

permissions:
contents: read

jobs:
update_release_draft:
permissions:
contents: write # for release-drafter/release-drafter to create a github release
pull-requests: write # for release-drafter/release-drafter to add label to PR
runs-on: ubuntu-latest
steps:
- uses: release-drafter/release-drafter@v5
13 changes: 8 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -7,11 +7,14 @@ jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: olafurpg/setup-scala@v13
- uses: olafurpg/setup-gpg@v3
# https://github.com/dwijnand/sbt-dynver#setup
- run: git fetch --tags --unshallow -f
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'temurin'
cache: 'sbt'
- name: Publish ${{ github.ref }}
run: sbt ci-release docs/docusaurusPublishGhpages
env:
2 changes: 1 addition & 1 deletion .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version=3.3.3
version=3.7.15
runner.dialect = scala213
project.git = true
project.excludeFilters = [
14 changes: 7 additions & 7 deletions bin/install-scalafmt-native.sh
Original file line number Diff line number Diff line change
@@ -71,21 +71,21 @@ elif [ "$VERSION_COMPARE" -le 0 ]; then
fi

TMP=$(mktemp -d)
cd $TMP
cd "$TMP"
if [ "$VERSION_COMPARE" -le 0 ]; then
curl --fail -Lo $NAME https://github.com/scalameta/scalafmt/releases/download/$VERSION/$NAME
cp $NAME $INSTALL_LOCATION
cp $NAME "$INSTALL_LOCATION"
else
ZIP=$NAME.zip
curl --fail -Lo $ZIP https://github.com/scalameta/scalafmt/releases/download/$VERSION/$ZIP
unzip $ZIP
cp scalafmt $INSTALL_LOCATION
cp scalafmt "$INSTALL_LOCATION"
fi

chmod +x $INSTALL_LOCATION
chmod +x "$INSTALL_LOCATION"

cd $CWD
rm -rf $TMP
cd "$CWD"
rm -rf "$TMP"

echo Installed $INSTALL_LOCATION
echo Installed "$INSTALL_LOCATION"

39 changes: 16 additions & 23 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -9,8 +9,8 @@ def parseTagVersion: String = {
def localSnapshotVersion: String = s"$parseTagVersion-SNAPSHOT"
def isCI = System.getenv("CI") != null

def scala212 = "2.12.15"
def scala213 = "2.13.8"
def scala212 = "2.12.18"
def scala213 = "2.13.11"

inThisBuild(
List(
@@ -33,10 +33,8 @@ inThisBuild(
),
scalaVersion := scala213,
crossScalaVersions := List(scala213, scala212),
resolvers ++= Seq(
Resolver.sonatypeRepo("releases"),
Resolver.sonatypeRepo("snapshots")
),
resolvers ++= Resolver.sonatypeOssRepos("releases"),
resolvers ++= Resolver.sonatypeOssRepos("snapshots"),
libraryDependencies ++= List(
munit.value % Test,
scalacheck % Test,
@@ -75,7 +73,7 @@ lazy val dynamic = project
buildInfoObject := "BuildInfo",
libraryDependencies ++= List(
"io.get-coursier" % "interface" % "0.0.17",
"com.typesafe" % "config" % "1.4.1",
"com.typesafe" % "config" % "1.4.3",
munit.value % Test,
scalametaTestkit % Test
),
@@ -155,6 +153,7 @@ lazy val core = crossProject(JVMPlatform)
scalacOptions ++= scalacJvmOptions.value,
libraryDependencies ++= Seq(
scalameta.value,
"org.scalameta" %% "mdoc-parser" % mdocV,
// scala-reflect is an undeclared dependency of fansi, see #1252.
// Scalafmt itself does not require scala-reflect.
"org.scala-lang" % "scala-reflect" % scalaVersion.value
@@ -190,7 +189,6 @@ import sbtassembly.AssemblyPlugin.defaultUniversalScript

val scalacJvmOptions = Def.setting {
val cross = CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, 11)) => Seq("-target:jvm-1.8")
case Some((2, 13)) =>
Seq(
"-Ymacro-annotations",
@@ -228,24 +226,19 @@ lazy val cli = project
libraryDependencies ++= Seq(
"com.googlecode.java-diff-utils" % "diffutils" % "1.3.0",
"com.martiansoftware" % "nailgun-server" % "0.9.1",
"com.github.scopt" %% "scopt" % "4.0.1",
// undeclared transitive dependency of coursier-small
"org.scala-lang.modules" %% "scala-xml" % "1.3.0"
"com.github.scopt" %% "scopt" % "4.1.0"
),
scalacOptions ++= scalacJvmOptions.value,
Compile / mainClass := Some("org.scalafmt.cli.Cli"),
nativeImageVersion := "20.1.0",
nativeImageVersion := "22.3.0",
nativeImageInstalled := isCI,
nativeImageOptions ++= {
val isMusl = sys.env.get("NATIVE_IMAGE_MUSL").exists(_.toBoolean)
if (isMusl) Seq("--libc=musl") else Nil
},
nativeImageOptions ++= {
sys.env
.get("NATIVE_IMAGE_MUSL")
.map(path => s"-H:UseMuslC=$path")
.toSeq ++
sys.env
.get("NATIVE_IMAGE_STATIC")
.map(_.toBoolean)
.filter(identity)
.map(_ => "--static")
.toSeq
val isStatic = sys.env.get("NATIVE_IMAGE_STATIC").exists(_.toBoolean)
if (isStatic) Seq("--static") else Nil
}
)
.dependsOn(coreJVM, dynamic)
@@ -257,7 +250,7 @@ lazy val tests = project
publish / skip := true,
libraryDependencies ++= Seq(
// Test dependencies
"com.lihaoyi" %% "scalatags" % "0.11.1",
"com.lihaoyi" %% "scalatags" % "0.12.0",
scalametaTestkit,
munit.value
),
Loading