From 7ae56999fa05fd523ec3a60b2edc2eade87f8655 Mon Sep 17 00:00:00 2001 From: Christoph Pirkl Date: Sun, 17 Mar 2024 13:33:20 +0100 Subject: [PATCH] Upgrade dependencies (#271) * Reduce workflow permissions * Update vscode config * Upgrade gradle * Upgrade dependencies * Fix compiler warnings * Remove unnecessary action --------- Co-authored-by: kaklakariada --- .github/workflows/build.yml | 19 +++++++++--------- .github/workflows/codeql-analysis.yml | 3 +++ .vscode/settings.json | 13 ++---------- build.gradle | 4 ++-- docs/developer_guide.md | 16 +++++++-------- docs/user_guide.md | 2 +- gradle/wrapper/gradle-wrapper.properties | 2 +- gradlew.bat | 20 +++++++++---------- .../table/activities/ActivitiesTable.java | 15 +++++++------- ...Origin.java => ClasspathPluginOrigin.java} | 4 ++-- .../service/plugin/origin/PluginOrigin.java | 12 +++++------ .../logic/service/project/ProjectImpl.java | 10 +++++----- ...st.java => ClasspathPluginOriginTest.java} | 6 +++--- .../CalculatedHolidaysTest.java | 8 +++++--- settings.gradle | 16 +++++++-------- 15 files changed, 73 insertions(+), 77 deletions(-) rename logic/src/main/java/org/itsallcode/whiterabbit/logic/service/plugin/origin/{CurrentClasspathOrigin.java => ClasspathPluginOrigin.java} (77%) rename logic/src/test/java/org/itsallcode/whiterabbit/logic/service/plugin/origin/{ClassPathPluginOriginTest.java => ClasspathPluginOriginTest.java} (86%) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ea1a52a3..8617c1d1 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -12,14 +12,19 @@ jobs: matrix: java: [21] os: ['ubuntu-latest', 'windows-latest'] + env: + DEFAULT_JAVA: 21 + DEFAULT_OS: 'ubuntu-latest' concurrency: group: ${{ github.workflow }}-${{ github.ref }}-${{ matrix.os }}-${{ matrix.java }} cancel-in-progress: true name: Build on ${{ matrix.os }} with Java ${{ matrix.java }} runs-on: ${{ matrix.os }} - env: - DEFAULT_JAVA: 21 - DEFAULT_OS: 'ubuntu-latest' + permissions: + contents: read + defaults: + run: + shell: bash steps: @@ -37,6 +42,7 @@ jobs: - name: Cache SonarQube packages uses: actions/cache@v4 + if: ${{ env.DEFAULT_JAVA == matrix.java && env.DEFAULT_OS == matrix.os }} with: path: ~/.sonar/cache key: ${{ runner.os }}-java-${{ matrix.java }}-sonar @@ -54,13 +60,6 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - - name: Publish Test Report - uses: scacap/action-surefire-report@v1 - if: ${{ always() && env.DEFAULT_OS == matrix.os && github.event.pull_request.head.repo.full_name == github.repository && github.actor != 'dependabot[bot]' }} - with: - report_paths: '**/build/test-results/*/TEST-*.xml' - github_token: ${{ secrets.GITHUB_TOKEN }} - - name: Archive executable JAR for ${{ matrix.java }} uses: actions/upload-artifact@v4 if: ${{ env.DEFAULT_JAVA == matrix.java && env.DEFAULT_OS == matrix.os }} diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 4ecc8c45..84117ddd 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -15,6 +15,9 @@ jobs: cancel-in-progress: true name: Analyze runs-on: ubuntu-latest + permissions: + contents: read + security-events: write strategy: fail-fast: false diff --git a/.vscode/settings.json b/.vscode/settings.json index 79c0fd49..fd2b156e 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,21 +1,12 @@ { - "files.exclude": { - "**/.classpath": true, - "**/.project": true, - "**/.settings": true, - "**/.factorypath": true, - "**/build/": false, - "**/bin/": true, - ".gradle/": true, - ".idea/": true, - }, "editor.codeActionsOnSave": { "source.organizeImports": "explicit", + "source.generate.finalModifiers": "explicit", "source.fixAll": "explicit" }, "java.codeGeneration.useBlocks": true, "editor.formatOnSave": true, - "editor.formatOnSaveMode": "modificationsIfAvailable", + "editor.formatOnSaveMode": "file", "sonarlint.connectedMode.project": { "connectionId": "itsallcode", "projectKey": "white-rabbit" diff --git a/build.gradle b/build.gradle index bdc84760..d0f16397 100644 --- a/build.gradle +++ b/build.gradle @@ -1,11 +1,11 @@ plugins { id 'eclipse' id "org.sonarqube" version "4.4.1.3373" - id "org.jetbrains.gradle.plugin.idea-ext" version "1.1.7" + id "org.jetbrains.gradle.plugin.idea-ext" version "1.1.8" id "io.codearte.nexus-staging" version "0.30.0" id 'com.github.johnrengelman.shadow' version '8.1.1' apply false id "com.moowork.node" version "1.3.1" apply false - id "com.github.ben-manes.versions" version "0.50.0" + id "com.github.ben-manes.versions" version "0.51.0" id "org.panteleyev.jpackageplugin" version "1.6.0" apply false id "org.gradle.crypto.checksum" version "1.4.0" apply false } diff --git a/docs/developer_guide.md b/docs/developer_guide.md index 3533a7f0..25f257e5 100644 --- a/docs/developer_guide.md +++ b/docs/developer_guide.md @@ -2,7 +2,7 @@ ## Clone and configure -```bash +```sh mkdir time-recording-data git clone https://github.com/itsallcode/white-rabbit.git cd white-rabbit @@ -14,7 +14,7 @@ echo "data = $HOME/time-recording-data/" > $HOME/.whiterabbit.properties ### Build and launch -```bash +```sh # Build WhiteRabbit and install plugins to $HOME/.whiterabbit/plugins/ ./gradlew build installPlugins # To skip unit and ui-tests, run @@ -34,13 +34,13 @@ java -jar jfxui/build/libs/white-rabbit-fx-[-SNAPSHOT].jar Run all tests: -```bash +```sh ./gradlew check ``` Run only UI-Tests: -```bash +```sh # Headless (default) ./gradlew check # Not Headless (don't move mouse while running!) @@ -49,13 +49,13 @@ Run only UI-Tests: Run a single test: -```bash +```sh ./gradlew uiTest -i --tests AboutDialogUiTest ``` ### Check that dependencies are up-to-date -```bash +```sh ./gradlew dependencyUpdates ``` @@ -63,7 +63,7 @@ Run a single test: Precondition for Windows: Install the [WiX Toolset](https://wixtoolset.org) and add it to the `PATH`. -```bash +```sh ./gradlew jpackage --info -PreleaseVersion=x.y.z ``` @@ -89,7 +89,7 @@ Add the following to your `~/.gradle/gradle.properties`: 1. Make sure the [Changelog](../CHANGELOG.md) is updated 2. Run the following command: - ```bash + ```sh ./gradlew clean build publish closeAndReleaseRepository --info -PreleaseVersion= ``` diff --git a/docs/user_guide.md b/docs/user_guide.md index f4fbb9d0..99b1d714 100644 --- a/docs/user_guide.md +++ b/docs/user_guide.md @@ -11,7 +11,7 @@ Precondition: Install Java Runtime Environment (JRE) 21, e.g. from [Adoptium / E * double clicking or * executing command - ```bash + ```sh java -jar whiterabbitfx-signed.jar ``` diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 1af9e093..a80b22ce 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/gradlew.bat b/gradlew.bat index 6689b85b..7101f8e4 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -43,11 +43,11 @@ set JAVA_EXE=java.exe %JAVA_EXE% -version >NUL 2>&1 if %ERRORLEVEL% equ 0 goto execute -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. +echo. 1>&2 +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 goto fail @@ -57,11 +57,11 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe if exist "%JAVA_EXE%" goto execute -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. +echo. 1>&2 +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 goto fail diff --git a/jfxui/src/main/java/org/itsallcode/whiterabbit/jfxui/table/activities/ActivitiesTable.java b/jfxui/src/main/java/org/itsallcode/whiterabbit/jfxui/table/activities/ActivitiesTable.java index fe28c21d..bb5a7d84 100644 --- a/jfxui/src/main/java/org/itsallcode/whiterabbit/jfxui/table/activities/ActivitiesTable.java +++ b/jfxui/src/main/java/org/itsallcode/whiterabbit/jfxui/table/activities/ActivitiesTable.java @@ -55,8 +55,9 @@ public class ActivitiesTable private final EditListener editListener; private final AppService appService; - public ActivitiesTable(ReadOnlyProperty selectedDay, SimpleObjectProperty selectedActivity, - EditListener editListener, AppService appService) + public ActivitiesTable(final ReadOnlyProperty selectedDay, + final SimpleObjectProperty selectedActivity, + final EditListener editListener, final AppService appService) { this.selectedActivity = selectedActivity; this.editListener = editListener; @@ -65,7 +66,7 @@ public ActivitiesTable(ReadOnlyProperty selectedDay, SimpleObjectProp selectedDay.addListener((observable, oldValue, newValue) -> updateTableValues(newValue)); } - public void updateTableValues(DayRecord day) + public void updateTableValues(final DayRecord day) { JavaFxUtil.runOnFxApplicationThread(() -> { if (day == null || day.activities().isEmpty()) @@ -142,18 +143,18 @@ public TableView initTable() return table; } - private boolean isDoubleClickEvent(MouseEvent event) + private boolean isDoubleClickEvent(final MouseEvent event) { return event.getButton().equals(MouseButton.PRIMARY) && event.getClickCount() == 2; } - private boolean targetIsEmptySpace(EventTarget target) + private boolean targetIsEmptySpace(final EventTarget target) { - if (target instanceof TableRow row) + if (target instanceof final TableRow row) { return row.getItem() == null; } - else if (target instanceof TableCell cell) + else if (target instanceof final TableCell cell) { return cell.getTableRow().getItem() == null; } diff --git a/logic/src/main/java/org/itsallcode/whiterabbit/logic/service/plugin/origin/CurrentClasspathOrigin.java b/logic/src/main/java/org/itsallcode/whiterabbit/logic/service/plugin/origin/ClasspathPluginOrigin.java similarity index 77% rename from logic/src/main/java/org/itsallcode/whiterabbit/logic/service/plugin/origin/CurrentClasspathOrigin.java rename to logic/src/main/java/org/itsallcode/whiterabbit/logic/service/plugin/origin/ClasspathPluginOrigin.java index 7db2f510..129f54bb 100644 --- a/logic/src/main/java/org/itsallcode/whiterabbit/logic/service/plugin/origin/CurrentClasspathOrigin.java +++ b/logic/src/main/java/org/itsallcode/whiterabbit/logic/service/plugin/origin/ClasspathPluginOrigin.java @@ -1,8 +1,8 @@ package org.itsallcode.whiterabbit.logic.service.plugin.origin; -class ClassPathPluginOrigin extends PluginOrigin +class ClasspathPluginOrigin extends PluginOrigin { - ClassPathPluginOrigin(ClassLoader classLoader) + ClasspathPluginOrigin(final ClassLoader classLoader) { super(classLoader); } diff --git a/logic/src/main/java/org/itsallcode/whiterabbit/logic/service/plugin/origin/PluginOrigin.java b/logic/src/main/java/org/itsallcode/whiterabbit/logic/service/plugin/origin/PluginOrigin.java index 8d6b174a..65ddbdbc 100644 --- a/logic/src/main/java/org/itsallcode/whiterabbit/logic/service/plugin/origin/PluginOrigin.java +++ b/logic/src/main/java/org/itsallcode/whiterabbit/logic/service/plugin/origin/PluginOrigin.java @@ -9,19 +9,19 @@ public abstract class PluginOrigin implements AppPluginOrigin { - private ClassLoader classLoader; + private final ClassLoader classLoader; - protected PluginOrigin(ClassLoader classLoader) + protected PluginOrigin(final ClassLoader classLoader) { this.classLoader = classLoader; } public static PluginOrigin forCurrentClassPath() { - return new ClassPathPluginOrigin(getBaseClassLoader()); + return new ClasspathPluginOrigin(getBaseClassLoader()); } - public static PluginOrigin forJar(Path jar) + public static PluginOrigin forJar(final Path jar) { return new JarPluginOrigin(jar, createClassLoader(jar)); } @@ -31,14 +31,14 @@ private static ClassLoader getBaseClassLoader() return PluginOrigin.class.getClassLoader(); } - private static ClassLoader createClassLoader(Path jar) + private static ClassLoader createClassLoader(final Path jar) { final String name = "PluginClassLoader-" + jar.getFileName(); final URL[] urls = new URL[] { toUrl(jar) }; return new URLClassLoader(name, urls, getBaseClassLoader()); } - private static URL toUrl(Path path) + private static URL toUrl(final Path path) { try { diff --git a/logic/src/main/java/org/itsallcode/whiterabbit/logic/service/project/ProjectImpl.java b/logic/src/main/java/org/itsallcode/whiterabbit/logic/service/project/ProjectImpl.java index f35c7160..fa984016 100644 --- a/logic/src/main/java/org/itsallcode/whiterabbit/logic/service/project/ProjectImpl.java +++ b/logic/src/main/java/org/itsallcode/whiterabbit/logic/service/project/ProjectImpl.java @@ -13,7 +13,7 @@ public class ProjectImpl implements Project @JsonbProperty("costCarrier") private String costCarrier; - public ProjectImpl(String projectId, String label, String costCarrier) + public ProjectImpl(final String projectId, final String label, final String costCarrier) { this.projectId = projectId; this.label = label; @@ -31,7 +31,7 @@ public String getProjectId() return projectId; } - public void setProjectId(String projectId) + public void setProjectId(final String projectId) { this.projectId = projectId; } @@ -42,7 +42,7 @@ public String getLabel() return label; } - public void setLabel(String label) + public void setLabel(final String label) { this.label = label; } @@ -53,7 +53,7 @@ public String getCostCarrier() return costCarrier; } - public void setCostCarrier(String costCarrier) + public void setCostCarrier(final String costCarrier) { this.costCarrier = costCarrier; } @@ -70,7 +70,7 @@ public int hashCode() } @Override - public boolean equals(Object obj) + public boolean equals(final Object obj) { if (this == obj) { diff --git a/logic/src/test/java/org/itsallcode/whiterabbit/logic/service/plugin/origin/ClassPathPluginOriginTest.java b/logic/src/test/java/org/itsallcode/whiterabbit/logic/service/plugin/origin/ClasspathPluginOriginTest.java similarity index 86% rename from logic/src/test/java/org/itsallcode/whiterabbit/logic/service/plugin/origin/ClassPathPluginOriginTest.java rename to logic/src/test/java/org/itsallcode/whiterabbit/logic/service/plugin/origin/ClasspathPluginOriginTest.java index e2aa06a7..40da86fb 100644 --- a/logic/src/test/java/org/itsallcode/whiterabbit/logic/service/plugin/origin/ClassPathPluginOriginTest.java +++ b/logic/src/test/java/org/itsallcode/whiterabbit/logic/service/plugin/origin/ClasspathPluginOriginTest.java @@ -9,16 +9,16 @@ import org.mockito.junit.jupiter.MockitoExtension; @ExtendWith(MockitoExtension.class) -class ClassPathPluginOriginTest +class ClasspathPluginOriginTest { @Mock private ClassLoader classLoaderMock; - private ClassPathPluginOrigin origin; + private ClasspathPluginOrigin origin; @BeforeEach void setup() { - origin = new ClassPathPluginOrigin(classLoaderMock); + origin = new ClasspathPluginOrigin(classLoaderMock); } @Test diff --git a/plugins/holiday-calculator/src/test/java/org/itsallcode/whiterabbit/plugin/holidaycalculator/CalculatedHolidaysTest.java b/plugins/holiday-calculator/src/test/java/org/itsallcode/whiterabbit/plugin/holidaycalculator/CalculatedHolidaysTest.java index 09915a43..c111a110 100644 --- a/plugins/holiday-calculator/src/test/java/org/itsallcode/whiterabbit/plugin/holidaycalculator/CalculatedHolidaysTest.java +++ b/plugins/holiday-calculator/src/test/java/org/itsallcode/whiterabbit/plugin/holidaycalculator/CalculatedHolidaysTest.java @@ -8,6 +8,7 @@ import java.time.LocalDate; import java.util.List; +import org.assertj.core.api.InstanceOfAssertFactories; import org.itsallcode.holidays.calculator.logic.variants.Holiday; import org.itsallcode.whiterabbit.api.features.Holidays.HolidayInstance; import org.junit.jupiter.api.Test; @@ -32,19 +33,20 @@ void success() throws URISyntaxException void nonExistingConfigurationFile() throws URISyntaxException { final Path path = Paths.get(this.getClass().getResource("/").toURI()); - assertThat(new CalculatedHolidaysMock(path).readHolidays(path.resolve("non-existing-file.cfg"))).asList() + assertThat(new CalculatedHolidaysMock(path).readHolidays(path.resolve("non-existing-file.cfg"))) + .asInstanceOf(InstanceOfAssertFactories.LIST) .isEmpty(); } private static class CalculatedHolidaysMock extends CalculatedHolidays { - public CalculatedHolidaysMock(Path dataDir) + public CalculatedHolidaysMock(final Path dataDir) { super(dataDir); } @Override - public List readHolidays(Path configurationFile) + public List readHolidays(final Path configurationFile) { return super.readHolidays(configurationFile); } diff --git a/settings.gradle b/settings.gradle index 56b1818c..07801653 100644 --- a/settings.gradle +++ b/settings.gradle @@ -19,28 +19,28 @@ dependencyResolutionManagement { } versionCatalogs { libs { - version('junitJupiter', '5.10.1') - version('mockito', '5.9.0') - version('log4j', '2.22.1') - version('javafx', '22-ea+16') // Versions >= 20-ea+11 and 20 causes UI-Test failures in non-headless mode (-PuiTestsHeadless=false) + version('junitJupiter', '5.10.2') + version('mockito', '5.11.0') + version('log4j', '2.23.1') + version('javafx', '23-ea+3') library('junitParams', 'org.junit.jupiter', 'junit-jupiter-params').versionRef('junitJupiter') - library('assertj', 'org.assertj:assertj-core:3.25.1') + library('assertj', 'org.assertj:assertj-core:3.25.3') library('junitPioneer', 'org.junit-pioneer:junit-pioneer:2.2.0') - library('equalsverifier', 'nl.jqno.equalsverifier:equalsverifier:3.15.6') + library('equalsverifier', 'nl.jqno.equalsverifier:equalsverifier:3.15.8') library('tostringverifier', 'com.jparams:to-string-verifier:1.4.8') library('hamcrest', 'org.hamcrest:hamcrest-all:1.3') library('mockito', 'org.mockito', 'mockito-core').versionRef('mockito') library('mocktioJunit', 'org.mockito', 'mockito-junit-jupiter').versionRef('mockito') bundle('testUtils', ['assertj', 'junitPioneer', 'junitParams', 'equalsverifier', 'tostringverifier', 'hamcrest', 'mockito', 'mocktioJunit']) - library('testfx', 'org.testfx:testfx-junit5:4.0.17') + library('testfx', 'org.testfx:testfx-junit5:4.0.18') library('monocle', 'org.pdfsam:javafx-monocle:21') library('jsonBindApi', 'jakarta.json.bind:jakarta.json.bind-api:3.0.0') library('yasson', 'org.eclipse:yasson:3.0.3') - library('jdtAnnotations', 'org.eclipse.jdt:org.eclipse.jdt.annotation:2.2.800') + library('jdtAnnotations', 'org.eclipse.jdt:org.eclipse.jdt.annotation:2.3.0') library('jansi', 'org.fusesource.jansi:jansi:2.4.1') library('log4j.api', 'org.apache.logging.log4j', 'log4j-api').versionRef('log4j') library('log4j.core', 'org.apache.logging.log4j', 'log4j-core').versionRef('log4j')