mirror of https://github.com/sbt/sbt.git
Add swoval java formatting plugin
The swoval javafmt plugin uses the google java formatter (which I believe is the only widely used java formatter) to format source files. It does not provide an automatic javafmtOnCompile method like the scalafmt plugin so I had to manually implement that functionality. In general the java formatter is much faster than scalafmt so the impact of having javafmtOnCompile set to true is very low.
This commit is contained in:
parent
f1370a25fe
commit
813864ec0f
|
|
@ -11,7 +11,7 @@ env:
|
|||
# WHITESOURCE_PASSWORD=
|
||||
- secure: d3bu2KNwsVHwfhbGgO+gmRfDKBJhfICdCJFGWKf2w3Gv86AJZX9nuTYRxz0KtdvEHO5Xw8WTBZLPb2thSJqhw9OCm4J8TBAVqCP0ruUj4+aqBUFy4bVexQ6WKE6nWHs4JPzPk8c6uC1LG3hMuzlC8RGETXtL/n81Ef1u7NjyXjs=
|
||||
matrix:
|
||||
- SBT_CMD="mimaReportBinaryIssues ;scalafmtCheckAll ; scalafmtSbtCheck; headerCheck ;test:headerCheck ;whitesourceOnPush ;test:compile; publishLocal ;mainSettingsProj/test ;safeUnitTests ;otherUnitTests; doc; $UTIL_TESTS; ++$SCALA_213; $UTIL_TESTS"
|
||||
- SBT_CMD="mimaReportBinaryIssues ; javafmtCheck ; Test / javafmtCheck; scalafmtCheckAll ; scalafmtSbtCheck; headerCheck ;test:headerCheck ;whitesourceOnPush ;test:compile; publishLocal ;mainSettingsProj/test ;safeUnitTests ;otherUnitTests; doc; $UTIL_TESTS; ++$SCALA_213; $UTIL_TESTS"
|
||||
- SBT_CMD="scripted actions/* apiinfo/* compiler-project/* ivy-deps-management/* reporter/* tests/* watch/* classloader-cache/* package/*"
|
||||
- SBT_CMD="scripted dependency-management/* plugins/* project-load/* java/* run/* nio/*"
|
||||
- SBT_CMD="repoOverrideTest:scripted dependency-management/*; scripted source-dependencies/* project/*"
|
||||
|
|
|
|||
11
build.sbt
11
build.sbt
|
|
@ -87,6 +87,16 @@ def commonBaseSettings: Seq[Setting[_]] = Def.settings(
|
|||
s"https://github.com/sbt/sbt/tree/$tagOrSha€{FILE_PATH}.scala"
|
||||
)
|
||||
},
|
||||
Compile / javafmtOnCompile := Def
|
||||
.taskDyn(if ((scalafmtOnCompile).value) Compile / javafmt else Def.task(()))
|
||||
.value,
|
||||
Test / javafmtOnCompile := Def
|
||||
.taskDyn(if ((Test / scalafmtOnCompile).value) Test / javafmt else Def.task(()))
|
||||
.value,
|
||||
Compile / unmanagedSources / inputFileStamps :=
|
||||
(Compile / unmanagedSources / inputFileStamps).dependsOn(Compile / javafmtOnCompile).value,
|
||||
Test / unmanagedSources / inputFileStamps :=
|
||||
(Test / unmanagedSources / inputFileStamps).dependsOn(Test / javafmtOnCompile).value,
|
||||
crossScalaVersions := Seq(baseScalaVersion),
|
||||
bintrayPackage := (bintrayPackage in ThisBuild).value,
|
||||
bintrayRepository := (bintrayRepository in ThisBuild).value,
|
||||
|
|
@ -1257,6 +1267,7 @@ lazy val otherProjects: ScopeFilter = ScopeFilter(
|
|||
),
|
||||
inConfigurations(Test)
|
||||
)
|
||||
lazy val javafmtOnCompile = taskKey[Unit]("Formats java sources before compile")
|
||||
|
||||
def customCommands: Seq[Setting[_]] = Seq(
|
||||
commands += Command.command("setupBuildScala212") { state =>
|
||||
|
|
|
|||
|
|
@ -10,3 +10,4 @@ addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.9.0")
|
|||
addSbtPlugin("com.lightbend" % "sbt-whitesource" % "0.1.14")
|
||||
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.14.9")
|
||||
addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "0.6.1")
|
||||
addSbtPlugin("com.swoval" % "sbt-java-format" % "0.2.3")
|
||||
|
|
|
|||
Loading…
Reference in New Issue