Add verifyCodeStyle #29377 (#29378)

This commit is contained in:
Ignasi Marimon-Clos 2020-07-22 22:32:40 +02:00 committed by GitHub
parent 9cb9d3d44f
commit 438e195365
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 3 deletions

View file

@ -72,6 +72,7 @@ The steps are exactly the same for everyone involved in the project (be it core
1. Create a branch on your fork and work on the feature. For example: `git checkout -b custom-headers-akka-http` 1. Create a branch on your fork and work on the feature. For example: `git checkout -b custom-headers-akka-http`
- Please make sure to follow the general quality guidelines (specified below) when developing your patch. - Please make sure to follow the general quality guidelines (specified below) when developing your patch.
- Please write additional tests covering your feature and adjust existing ones if needed before submitting your pull request. The `validatePullRequest` sbt task ([explained below](#the-validatepullrequest-task)) may come in handy to verify your changes are correct. - Please write additional tests covering your feature and adjust existing ones if needed before submitting your pull request. The `validatePullRequest` sbt task ([explained below](#the-validatepullrequest-task)) may come in handy to verify your changes are correct.
- Use the `verifyCodeStyle` sbt task to make sure your code is properly formatted and includes the proper copyright headers.
1. Once your feature is complete, prepare the commit following our [Creating Commits And Writing Commit Messages](#creating-commits-and-writing-commit-messages). For example, a good commit message would be: `Adding compression support for Manifests #22222` (note the reference to the ticket it aimed to resolve). 1. Once your feature is complete, prepare the commit following our [Creating Commits And Writing Commit Messages](#creating-commits-and-writing-commit-messages). For example, a good commit message would be: `Adding compression support for Manifests #22222` (note the reference to the ticket it aimed to resolve).
1. If it's a new feature, or a change of behavior, document it on the [akka-docs](https://github.com/akka/akka/tree/master/akka-docs). If the feature was touching Scala or Java DSL, make sure to document both the Scala and Java APIs. 1. If it's a new feature, or a change of behavior, document it on the [akka-docs](https://github.com/akka/akka/tree/master/akka-docs). If the feature was touching Scala or Java DSL, make sure to document both the Scala and Java APIs.
1. Now it's finally time to [submit the pull request](https://help.github.com/articles/using-pull-requests)! 1. Now it's finally time to [submit the pull request](https://help.github.com/articles/using-pull-requests)!

View file

@ -9,6 +9,23 @@ enablePlugins(
ScalafixIgnoreFilePlugin, ScalafixIgnoreFilePlugin,
JavaFormatterPlugin) JavaFormatterPlugin)
disablePlugins(MimaPlugin) disablePlugins(MimaPlugin)
// check format and headers
TaskKey[Unit]("verifyCodeFmt") := {
javafmtCheckAll.all(ScopeFilter(inAnyProject)).result.value.toEither.left.foreach { _ =>
throw new MessageOnlyException(
"Unformatted Java code found. Please run 'javafmtAll' (or use the 'applyCodeStyle' alias) and commit the reformatted code")
}
scalafmtCheckAll.all(ScopeFilter(inAnyProject)).result.value.toEither.left.foreach { _ =>
throw new MessageOnlyException(
"Unformatted Scala code found. Please run 'scalafmtAll' (or use the 'applyCodeStyle' alias) and commit the reformatted code")
}
}
addCommandAlias("verifyCodeStyle", "headerCheckAll; verifyCodeFmt")
addCommandAlias("applyCodeStyle", "headerCreateAll; javafmtAll; scalafmtAll")
addCommandAlias( addCommandAlias(
name = "fixall", name = "fixall",
value = value =
@ -321,7 +338,8 @@ lazy val protobufV3 = akkaModule("akka-protobuf-v3")
exportJars := true, // in dependent projects, use assembled and shaded jar exportJars := true, // in dependent projects, use assembled and shaded jar
makePomConfiguration := makePomConfiguration.value makePomConfiguration := makePomConfiguration.value
.withConfigurations(Vector(Compile)), // prevent original dependency to be added to pom as runtime dep .withConfigurations(Vector(Compile)), // prevent original dependency to be added to pom as runtime dep
packagedArtifact in (Compile, packageBin) := Scoped.mkTuple2((artifact in (Compile, packageBin)).value, OsgiKeys.bundle.value), packagedArtifact in (Compile, packageBin) := Scoped
.mkTuple2((artifact in (Compile, packageBin)).value, OsgiKeys.bundle.value),
packageBin in Compile := ReproducibleBuildsPlugin packageBin in Compile := ReproducibleBuildsPlugin
.postProcessJar((assembly in Compile).value), // package by running assembly .postProcessJar((assembly in Compile).value), // package by running assembly
// Prevent cyclic task dependencies, see https://github.com/sbt/sbt-assembly/issues/365 // Prevent cyclic task dependencies, see https://github.com/sbt/sbt-assembly/issues/365