diff --git a/.circleci/config.yml b/.circleci/config.yml index 0481dbb4..7be5ed21 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -13,6 +13,16 @@ jobs: paths: - ~/.m2 key: circleci-demo-java-spring-{{ checksum "pom.xml" }} + - run: + name: Check formatting + command: | + if (mvn fmt:format); + then + echo "Code is well formatted" + else + echo "Code is not formatted well. Please run 'mvn fmt:format' and commit changes" + exit 1 + fi - run: mvn package publish_image: docker: diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 4544b903..ec997305 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -11,6 +11,13 @@ Prometheus uses GitHub to manage reviews of pull requests. This will avoid unnecessary work and surely give you and us a good deal of inspiration. +# Formatting + +Code is automatically formatted with [Spotify fmt mavne-plugin](https://github.com/spotify/fmt-maven-plugin) whenever you run standard `mvn install`. + +CI builds will fail if code is not formatted that way. + +To simply run the formatter you can always run: `mvn fmt:format` (requires JVM > 11) # Releasing For release instructions, see [RELEASING](RELEASING.md). diff --git a/pom.xml b/pom.xml index 21cdf9da..eba7edb4 100644 --- a/pom.xml +++ b/pom.xml @@ -208,6 +208,18 @@ + + com.spotify.fmt + fmt-maven-plugin + 2.18 + + + + format + + + +