From 2010423dd079d869841c13948c0376f9f64db6c4 Mon Sep 17 00:00:00 2001 From: Christian Egli Date: Mon, 1 Nov 2021 09:08:28 +0100 Subject: [PATCH 1/4] Add a config file for editor settings Related to #476 --- .editorconfig | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 00000000..4c17a8eb --- /dev/null +++ b/.editorconfig @@ -0,0 +1,21 @@ +# EditorConfig: maintain consistent coding styles for multiple +# developers working on the same project across various editors and +# IDEs, see https://EditorConfig.org + +# top-most EditorConfig file +root = true + +# Unix-style newlines with a newline ending every file +[*] +end_of_line = lf +insert_final_newline = true + +# Set default charset and 4 space indentation for all xml, xslt, xpl, +# xprocspec and xspec files +[*.{xml,xpl,xsl,xprocspec,xspec}] +charset = utf-8 +indent_style = space +indent_size = 4 + + + From cf4d7c46ffdcfac223df11f0d34a7bf87d58c8e2 Mon Sep 17 00:00:00 2001 From: Christian Egli Date: Mon, 1 Nov 2021 09:24:33 +0100 Subject: [PATCH 2/4] Add the editorconfig maven plugin so that the editorconfig settings can be checked with Maven Related to #476 --- README.md | 6 ++++++ pom.xml | 22 ++++++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/README.md b/README.md index daef2e1f..fec22530 100644 --- a/README.md +++ b/README.md @@ -67,6 +67,12 @@ The nordic migrator can be built with Maven, either directly (with for instance `mvn clean package`), or indirectly with Docker (with for instance `docker build .`). +To check the code conventions use a special Maven plugin: `mvn +editorconfig:check`. The conventions are defined in `.editorconfig` +which is picked up by most editors, see https://editorconfig.org/. You +can also fix the conventions in all files with `mvn +editorconfig:format`. + Releasing --------- diff --git a/pom.xml b/pom.xml index 42391675..5ceb20ef 100644 --- a/pom.xml +++ b/pom.xml @@ -172,6 +172,28 @@ + + org.ec4j.maven + editorconfig-maven-plugin + 0.1.1 + + + check + verify + + check + + + + + + + src/test/**/*.epub + **/*.otf + documentation/*.odg + + + From 1745c5bb92c4913270fd87c6ef4350c36ff8febe Mon Sep 17 00:00:00 2001 From: Christian Egli Date: Mon, 1 Nov 2021 09:47:08 +0100 Subject: [PATCH 3/4] Add a gh action to check every commit for coding conventions Related to #476 --- .github/workflows/check-format.yml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 .github/workflows/check-format.yml diff --git a/.github/workflows/check-format.yml b/.github/workflows/check-format.yml new file mode 100644 index 00000000..208360e1 --- /dev/null +++ b/.github/workflows/check-format.yml @@ -0,0 +1,17 @@ +name: Check code conventions + +on: [push] + +jobs: + check-code-conventions: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - name: Set up JDK 11 + uses: actions/setup-java@v2 + with: + distribution: 'temurin' + java-version: '11' + - name: Build with Maven + run: mvn --batch-mode editorconfig:check From 518f19ddb11724129c026beb44e4d3ad52ec2a02 Mon Sep 17 00:00:00 2001 From: Jostein Austvik Jacobsen Date: Mon, 1 Nov 2021 12:46:00 +0100 Subject: [PATCH 4/4] run editorconfig during compile phase --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 5ceb20ef..c026e6d4 100644 --- a/pom.xml +++ b/pom.xml @@ -179,7 +179,7 @@ check - verify + compile check