diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 06b8dc6cbf..032b056283 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -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` - 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. + - 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. 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)! diff --git a/build.sbt b/build.sbt index 42c233ded0..a53103bdac 100644 --- a/build.sbt +++ b/build.sbt @@ -9,14 +9,31 @@ enablePlugins( ScalafixIgnoreFilePlugin, JavaFormatterPlugin) 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( name = "fixall", value = - ";scalafixEnable;compile:scalafix;test:scalafix;multi-jvm:scalafix;scalafmtAll;test:compile;multi-jvm:compile;reload") + ";scalafixEnable; compile:scalafix; test:scalafix; multi-jvm:scalafix; scalafmtAll; test:compile; multi-jvm:compile; reload") addCommandAlias( name = "sortImports", - value = ";scalafixEnable;compile:scalafix SortImports;test:scalafix SortImports;scalafmtAll") + value = ";scalafixEnable; compile:scalafix SortImports; test:scalafix SortImports; scalafmtAll") import akka.AkkaBuild._ import akka.{ AkkaBuild, Dependencies, OSGi, Protobuf, SigarLoader, VersionGenerator } @@ -321,7 +338,8 @@ lazy val protobufV3 = akkaModule("akka-protobuf-v3") exportJars := true, // in dependent projects, use assembled and shaded jar makePomConfiguration := makePomConfiguration.value .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 .postProcessJar((assembly in Compile).value), // package by running assembly // Prevent cyclic task dependencies, see https://github.com/sbt/sbt-assembly/issues/365