From af2d22abe08300b8fa0bcf8a93e53a0d2b66c3f0 Mon Sep 17 00:00:00 2001
From: GCHQDeveloper314 <94527357+GCHQDeveloper314@users.noreply.github.com>
Date: Wed, 13 Jul 2022 17:02:34 +0100
Subject: [PATCH] gh-1001: Improve process for updating copyright headers
(#1002)
* Enable use of spotless copyright header check
* Remove checkstyle header checks
* Fix typo
---
.github/workflows/continuous-integration.yaml | 8 +++++++-
code-style/checkstyle.xml | 4 ----
code-style/licence-header-java.txt | 16 ++++++++++++++++
code-style/licence-header-pom.txt | 17 +++++++++++++++++
code-style/licenseHeader.txt | 15 ---------------
pom.xml | 6 +-----
6 files changed, 41 insertions(+), 25 deletions(-)
create mode 100644 code-style/licence-header-java.txt
create mode 100644 code-style/licence-header-pom.txt
delete mode 100644 code-style/licenseHeader.txt
diff --git a/.github/workflows/continuous-integration.yaml b/.github/workflows/continuous-integration.yaml
index 227b65e0b..7b8015059 100644
--- a/.github/workflows/continuous-integration.yaml
+++ b/.github/workflows/continuous-integration.yaml
@@ -111,7 +111,9 @@ jobs:
env:
MAVEN_OPTS: -Dmaven.wagon.http.retryHandler.count=3 -Dmaven.wagon.httpconnectionManager.ttlSeconds=25
steps:
- - uses: actions/checkout@v2
+ - uses: actions/checkout@v3
+ with:
+ fetch-depth: 0
- name: Setup JDK
uses: actions/setup-java@v2
@@ -133,5 +135,9 @@ jobs:
- name: Test
run: mvn verify -B -P coverage -pl ${{matrix.modules}}
+ - name: Check Copyright Headers
+ if: github.event_name == 'pull_request'
+ run: mvn -B -q spotless:check -pl ${{matrix.modules}}
+
- name: Upload Coverage
uses: codecov/codecov-action@v2
diff --git a/code-style/checkstyle.xml b/code-style/checkstyle.xml
index 206796bbc..145d83214 100644
--- a/code-style/checkstyle.xml
+++ b/code-style/checkstyle.xml
@@ -33,10 +33,6 @@
-
-
-
-
diff --git a/code-style/licence-header-java.txt b/code-style/licence-header-java.txt
new file mode 100644
index 000000000..83bd240da
--- /dev/null
+++ b/code-style/licence-header-java.txt
@@ -0,0 +1,16 @@
+/*
+ * Copyright $YEAR Crown Copyright
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
diff --git a/code-style/licence-header-pom.txt b/code-style/licence-header-pom.txt
new file mode 100644
index 000000000..9c80942af
--- /dev/null
+++ b/code-style/licence-header-pom.txt
@@ -0,0 +1,17 @@
+
+
+
diff --git a/code-style/licenseHeader.txt b/code-style/licenseHeader.txt
deleted file mode 100644
index be4402b13..000000000
--- a/code-style/licenseHeader.txt
+++ /dev/null
@@ -1,15 +0,0 @@
-^(/\*|#)$
-^(\s\*|#) Copyright (20\d\d)(-20\d\d)?
-^(\s\*|#)$
-^(\s\*|#) Licensed under the Apache License, Version 2.0 \(the "License"\);$
-^(\s\*|#) you may not use this file except in compliance with the License.$
-^(\s\*|#) You may obtain a copy of the License at$
-^(\s\*|#)$
-^(\s\*|#) http://www.apache.org/licenses/LICENSE-2.0$
-^(\s\*|#)$
-^(\s\*|#) Unless required by applicable law or agreed to in writing, software$
-^(\s\*|#) distributed under the License is distributed on an "AS IS" BASIS,$
-^(\s\*|#) WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.$
-^(\s\*|#) See the License for the specific language governing permissions and$
-^(\s\*|#) limitations under the License.$
-^(\s\*/|#)$
diff --git a/pom.xml b/pom.xml
index 1a164e2bb..2fcc1eaad 100755
--- a/pom.xml
+++ b/pom.xml
@@ -1,6 +1,6 @@