Skip to content

Commit 843224e

Browse files
koeningerdongjoon-hyun
authored andcommitted
[SPARK-30570][BUILD] Update scalafmt plugin to 1.0.3 with onlyChangedFiles feature
### What changes were proposed in this pull request? Update the scalafmt plugin to 1.0.3 and use its new onlyChangedFiles feature rather than --diff ### Why are the changes needed? Older versions of the plugin either didn't work with scala 2.13, or got rid of the --diff argument and didn't allow for formatting only changed files ### Does this PR introduce any user-facing change? The /dev/scalafmt script no longer passes through arbitrary args, instead using the arg to select scala version. The issue here is the plugin name literally contains the scala version, and doesn't appear to have a shorter way to refer to it. If srowen or someone else with better maven-fu has an idea I'm all ears. ### How was this patch tested? Manually, e.g. edited a file and ran dev/scalafmt or dev/scalafmt 2.13 Closes #27279 from koeninger/SPARK-30570. Authored-by: cody koeninger <cody@koeninger.org> Signed-off-by: Dongjoon Hyun <dhyun@apple.com>
1 parent afe70b3 commit 843224e

File tree

2 files changed

+24
-25
lines changed

2 files changed

+24
-25
lines changed

dev/scalafmt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
# limitations under the License.
1818
#
1919

20-
# by default, format only files that differ from git master
21-
params="${@:---diff}"
20+
VERSION="${@:-2.12}"
21+
./build/mvn -Pscala-$VERSION mvn-scalafmt_$VERSION:format -Dscalafmt.skip=false
2222

23-
./build/mvn -Pscala-2.12 mvn-scalafmt_2.12:format -Dscalafmt.skip=false -Dscalafmt.parameters="$params"

pom.xml

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@
162162
<commons.collections.version>3.2.2</commons.collections.version>
163163
<scala.version>2.12.10</scala.version>
164164
<scala.binary.version>2.12</scala.binary.version>
165-
<scalafmt.parameters>--diff --test</scalafmt.parameters>
165+
<scalafmt.parameters>--test</scalafmt.parameters>
166166
<!-- for now, not running scalafmt as part of default verify pipeline -->
167167
<scalafmt.skip>true</scalafmt.skip>
168168
<codehaus.jackson.version>1.9.13</codehaus.jackson.version>
@@ -2895,6 +2895,27 @@
28952895
</execution>
28962896
</executions>
28972897
</plugin>
2898+
<plugin>
2899+
<groupId>org.antipathy</groupId>
2900+
<artifactId>mvn-scalafmt_${scala.binary.version}</artifactId>
2901+
<version>1.0.3</version>
2902+
<configuration>
2903+
<parameters>${scalafmt.parameters}</parameters> <!-- (Optional) Additional command line arguments -->
2904+
<skip>${scalafmt.skip}</skip> <!-- (Optional) skip formatting -->
2905+
<skipSources>${scalafmt.skip}</skipSources>
2906+
<skipTestSources>${scalafmt.skip}</skipTestSources>
2907+
<configLocation>dev/.scalafmt.conf</configLocation> <!-- (Optional) config location -->
2908+
<onlyChangedFiles>true</onlyChangedFiles>
2909+
</configuration>
2910+
<executions>
2911+
<execution>
2912+
<phase>validate</phase>
2913+
<goals>
2914+
<goal>format</goal>
2915+
</goals>
2916+
</execution>
2917+
</executions>
2918+
</plugin>
28982919
<!--
28992920
Couple of dependencies are coming in bundle format (bundle is just a normal jar which
29002921
contains OSGi metadata in the manifest). If one don't use OSGi, then a bundle will work as
@@ -3059,27 +3080,6 @@
30593080
<build>
30603081
<pluginManagement>
30613082
<plugins>
3062-
<!-- SPARK-29293 currently not able to update to 1.x for Scala 2.13 -->
3063-
<plugin>
3064-
<groupId>org.antipathy</groupId>
3065-
<artifactId>mvn-scalafmt_2.12</artifactId>
3066-
<version>0.12_1.5.1</version>
3067-
<configuration>
3068-
<parameters>${scalafmt.parameters}</parameters> <!-- (Optional) Additional command line arguments -->
3069-
<skip>${scalafmt.skip}</skip> <!-- (Optional) skip formatting -->
3070-
<skipSources>${scalafmt.skip}</skipSources>
3071-
<skipTestSources>${scalafmt.skip}</skipTestSources>
3072-
<configLocation>dev/.scalafmt.conf</configLocation> <!-- (Optional) config location -->
3073-
</configuration>
3074-
<executions>
3075-
<execution>
3076-
<phase>validate</phase>
3077-
<goals>
3078-
<goal>format</goal>
3079-
</goals>
3080-
</execution>
3081-
</executions>
3082-
</plugin>
30833083
</plugins>
30843084
</pluginManagement>
30853085
</build>

0 commit comments

Comments
 (0)