From 2d542bdfa16d0f28cd83e7b6427f0672b88f53b5 Mon Sep 17 00:00:00 2001 From: Ulli Hafner Date: Fri, 13 Oct 2023 10:21:59 +0200 Subject: [PATCH 1/3] Remove dependency to javax.annotation-api. --- .../assertion_class_template.txt | 26 +++++++++++++++++++ .../assertions_entry_point_class_template.txt | 2 +- ..._assertions_entry_point_class_template.txt | 2 +- pom.xml | 6 +---- .../java/edu/hm/hafner/util/Generated.java | 4 +-- 5 files changed, 31 insertions(+), 9 deletions(-) create mode 100644 etc/assertj-templates/assertion_class_template.txt diff --git a/etc/assertj-templates/assertion_class_template.txt b/etc/assertj-templates/assertion_class_template.txt new file mode 100644 index 00000000..320e3603 --- /dev/null +++ b/etc/assertj-templates/assertion_class_template.txt @@ -0,0 +1,26 @@ +package ${package}; +${imports} +/** + * {@link ${class_to_assert}} specific assertions - Generated by CustomAssertionGenerator. + */ +@edu.hm.hafner.util.Generated(value="assertj-assertions-generator") +public class ${custom_assertion_class} extends AbstractObjectAssert<${custom_assertion_class}, ${class_to_assert}> { + + /** + * Creates a new {@link ${custom_assertion_class}} to make assertions on actual ${class_to_assert}. + * @param actual the ${class_to_assert} we want to make assertions on. + */ + public ${custom_assertion_class}(${class_to_assert} actual) { + super(actual, ${custom_assertion_class}.class); + } + + /** + * An entry point for ${custom_assertion_class} to follow AssertJ standard assertThat() statements.
+ * With a static import, one can write directly: assertThat(my${class_to_assert}) and get specific assertion with code completion. + * @param actual the ${class_to_assert} we want to make assertions on. + * @return a new {@link ${custom_assertion_class}} + */ + @org.assertj.core.util.CheckReturnValue + public static ${custom_assertion_class} assertThat(${class_to_assert} actual) { + return new ${custom_assertion_class}(actual); + } diff --git a/etc/assertj-templates/assertions_entry_point_class_template.txt b/etc/assertj-templates/assertions_entry_point_class_template.txt index f5204a15..a275e227 100644 --- a/etc/assertj-templates/assertions_entry_point_class_template.txt +++ b/etc/assertj-templates/assertions_entry_point_class_template.txt @@ -5,7 +5,7 @@ package ${package}; * type-specific assertion objects. */ @edu.umd.cs.findbugs.annotations.SuppressFBWarnings("NM") -@javax.annotation.Generated(value="assertj-assertions-generator") +@edu.hm.hafner.util.Generated(value="assertj-assertions-generator") public class Assertions extends org.assertj.core.api.Assertions { ${all_assertions_entry_points} /** diff --git a/etc/assertj-templates/soft_assertions_entry_point_class_template.txt b/etc/assertj-templates/soft_assertions_entry_point_class_template.txt index c7485e42..68df9869 100644 --- a/etc/assertj-templates/soft_assertions_entry_point_class_template.txt +++ b/etc/assertj-templates/soft_assertions_entry_point_class_template.txt @@ -4,7 +4,7 @@ package ${package}; * Entry point for soft assertions of different data types. */ @edu.umd.cs.findbugs.annotations.SuppressFBWarnings("NM") -@javax.annotation.Generated(value="assertj-assertions-generator") +@edu.hm.hafner.util.Generated(value="assertj-assertions-generator") public class SoftAssertions extends org.assertj.core.api.AutoCloseableSoftAssertions { ${all_assertions_entry_points} } diff --git a/pom.xml b/pom.xml index a2ead274..a2ae71e4 100644 --- a/pom.xml +++ b/pom.xml @@ -136,11 +136,6 @@ - - javax.annotation - javax.annotation-api - ${javax.annotation-api.version} - com.github.spotbugs spotbugs-annotations @@ -487,6 +482,7 @@ assertions_entry_point_class_template.txt soft_assertions_entry_point_class_template.txt has_assertion_template.txt + assertion_class_template.txt edu.hm.hafner.util diff --git a/src/main/java/edu/hm/hafner/util/Generated.java b/src/main/java/edu/hm/hafner/util/Generated.java index e9aa23ce..a4eaadd8 100644 --- a/src/main/java/edu/hm/hafner/util/Generated.java +++ b/src/main/java/edu/hm/hafner/util/Generated.java @@ -8,8 +8,8 @@ /** * This annotation is used to mark source code that has been generated or is somehow not relevant for style checking or - * code coverage analysis. This annotation is quite similar to the annotation @{@link javax.annotation.Generated}. The - * main difference is that it has class retention on so is available for tools that work on the bytecode (like JaCoCo, + * code coverage analysis. It is quite similar to the {@code javax.annotation.Generated} annotation. The + * main difference is that it has class retention on so is available for tools that work on bytecode (like JaCoCo, * PIT, or SpotBugs). */ @Retention(CLASS) From c41c680c806b723fdf5113f459389e927a878fd4 Mon Sep 17 00:00:00 2001 From: Ulli Hafner Date: Fri, 13 Oct 2023 10:22:28 +0200 Subject: [PATCH 2/3] Switch builds environment matrix to Java 17 and 21. --- .github/workflows/ci.yml | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cd028ff0..2d47c9b0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,11 +14,6 @@ jobs: matrix: platform: [ubuntu-latest, macos-latest, windows-latest] jdk: [17, 21] - include: - - platform: ubuntu-latest - jdk: 11 - - platform: macos-latest - jdk: 11 runs-on: ${{ matrix.platform }} name: on ${{ matrix.platform }} with JDK ${{ matrix.jdk }} @@ -28,7 +23,7 @@ jobs: - name: Set up JDK ${{ matrix.jdk }} uses: actions/setup-java@v3 with: - distribution: 'zulu' + distribution: 'temurin' java-version: '${{ matrix.jdk }}' check-latest: true cache: 'maven' From 06e3915f1890c6d7d2a7a64d5edb90d9edb763d9 Mon Sep 17 00:00:00 2001 From: Ulli Hafner Date: Fri, 13 Oct 2023 10:39:02 +0200 Subject: [PATCH 3/3] Use Maven setup in CI. --- .github/workflows/ci.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2d47c9b0..644a32f9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -27,6 +27,10 @@ jobs: java-version: '${{ matrix.jdk }}' check-latest: true cache: 'maven' + - name: Set up Maven + uses: stCarolas/setup-maven@v4 + with: + maven-version: 3.9.5 - name: Build with Maven env: BROWSER: chrome-container