From 10376ea33f427774faeaf514965a5746975f437f Mon Sep 17 00:00:00 2001 From: Frank Delporte Date: Sat, 16 Nov 2024 15:52:39 +0100 Subject: [PATCH 01/13] Bump java version and Pi4j --- .github/workflows/ci-develop-snapshot.yml | 4 ++-- .github/workflows/ci-pull-request.yml | 2 +- .github/workflows/ci-release-tags.yml | 4 ++-- README.md | 14 +++++++------- libraries/pi4j-library-gpiod/pom.xml | 2 +- libraries/pi4j-library-linuxfs/pom.xml | 2 +- libraries/pi4j-library-pigpio/pom.xml | 2 +- .../com_pi4j_library_pigpio_internal_PIGPIO.c | 2 +- libraries/pi4j-library/pom.xml | 2 +- pi4j-core/pom.xml | 2 +- pi4j-distribution/pom.xml | 2 +- pi4j-test/pom.xml | 2 +- plugins/pi4j-plugin-gpiod/pom.xml | 2 +- plugins/pi4j-plugin-linuxfs/pom.xml | 2 +- plugins/pi4j-plugin-mock/pom.xml | 2 +- plugins/pi4j-plugin-pigpio/pom.xml | 2 +- plugins/pi4j-plugin-raspberrypi/pom.xml | 2 +- plugins/pi4j-plugin/pom.xml | 2 +- pom.xml | 16 ++++++++-------- 19 files changed, 34 insertions(+), 34 deletions(-) diff --git a/.github/workflows/ci-develop-snapshot.yml b/.github/workflows/ci-develop-snapshot.yml index 7c106931..1c5316cd 100644 --- a/.github/workflows/ci-develop-snapshot.yml +++ b/.github/workflows/ci-develop-snapshot.yml @@ -27,7 +27,7 @@ jobs: - name: Upload distribution files to staging uses: actions/upload-artifact@v4 with: - name: pi4j-v2-dist + name: pi4j-dist path: staging DeployPackages: name: Deploy to APT/Download Repo @@ -40,7 +40,7 @@ jobs: - name: Download staged artifacts from build uses: actions/download-artifact@v4 with: - name: pi4j-v2-dist + name: pi4j-dist - name: Display downloaded build artifacts shell: bash run: tree diff --git a/.github/workflows/ci-pull-request.yml b/.github/workflows/ci-pull-request.yml index 1a7b1f49..a7f26747 100644 --- a/.github/workflows/ci-pull-request.yml +++ b/.github/workflows/ci-pull-request.yml @@ -27,5 +27,5 @@ jobs: - name: Upload distribution files to staging uses: actions/upload-artifact@v4 with: - name: pi4j-v2-dist + name: pi4j-dist path: staging diff --git a/.github/workflows/ci-release-tags.yml b/.github/workflows/ci-release-tags.yml index f93885c4..64e3ee6c 100644 --- a/.github/workflows/ci-release-tags.yml +++ b/.github/workflows/ci-release-tags.yml @@ -28,7 +28,7 @@ jobs: - name: Upload distribution files to staging uses: actions/upload-artifact@v4 with: - name: pi4j-v2-dist + name: pi4j-dist path: staging DeployPackages: name: Deploy to APT/Download Repo @@ -41,7 +41,7 @@ jobs: - name: Download staged artifacts from build uses: actions/download-artifact@v4 with: - name: pi4j-v2-dist + name: pi4j-dist - name: Display downloaded build artifacts shell: bash run: tree diff --git a/README.md b/README.md index a1f780f3..4ea7adec 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ [![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.pi4j/pi4j-core/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.pi4j/pi4j-core) [![Sonatype Nexus (Snapshots)](https://img.shields.io/nexus/s/com.pi4j/pi4j-core?server=https%3A%2F%2Foss.sonatype.org)](https://oss.sonatype.org/#nexus-search;gav~com.pi4j~~~~) -[![License](https://img.shields.io/github/license/pi4j/pi4j-v2)](http://www.apache.org/licenses/LICENSE-2.0) +[![License](https://img.shields.io/github/license/pi4j/pi4j)](http://www.apache.org/licenses/LICENSE-2.0) [![Site](https://img.shields.io/badge/Website-pi4j.com-green)](https://pi4j.com) [![Chat on Slack](https://img.shields.io/badge/Chat-on%20Slack-blue)](https://join.slack.com/t/pi4j/shared_invite/zt-1ttqt8wgj-E6t69qaLrNuCMPLiYnBCsg) @@ -24,8 +24,8 @@ This project is intended to provide a **friendly object-oriented I/O API and imp ![Pi4J diagram](https://pi4j.com/assets/about/home/pi4j-overview.jpg) -* Pi4J V2 Discussions: [github.com/Pi4J/pi4j-v2/discussions](https://github.com/Pi4J/pi4j-v2/discussions) -* Pi4J V2 issues: [github.com/Pi4J/pi4j-v2/issues](https://github.com/Pi4J/pi4j-v2/issues) +* Pi4J V2 Discussions: [github.com/Pi4J/pi4j/discussions](https://github.com/Pi4J/pi4j/discussions) +* Pi4J V2 issues: [github.com/Pi4J/pi4j/issues](https://github.com/Pi4J/pi4j/issues) Builds are available from: @@ -60,7 +60,7 @@ while (true) { For full description of the code structure, how to compile... see the ["About the code" on our website](https://pi4j.com/architecture/about-the-code/). -![Pi4J V2 code structure](assets/draw.io/pi4j-v2-code-structure.jpg) +![Pi4J V2 code structure](assets/draw.io/pi4j-code-structure.jpg) ### Project Overview @@ -68,7 +68,7 @@ Starting with the Pi4J 2.0 builds, the Pi4J project is prioritizing focus on providing Java programs access, control and communication with the core I/O capabilities of the Raspberry Pi platform. -Read all about it on [pi4j.com: "What’s New in 2.0?"](https://pi4j.com/about/new-in-v2/). +Read all about it on [pi4j.com: "What’s New in 2.0?"](https://pi4j.com/about/new-in/). ### Build Instructions @@ -109,10 +109,10 @@ with your experience, ideas, and what you would like to contribute to the projec * **Releases** * V1: [github.com/Pi4J/pi4j-v1/releases](https://github.com/Pi4J/pi4j-v1/releases) (archived) - * V2: [github.com/Pi4J/pi4j-v2/releases](https://github.com/Pi4J/pi4j-v2/releases) + * V2: [github.com/Pi4J/pi4j/releases](https://github.com/Pi4J/pi4j/releases) * **Source Code**: * V1: [github.com/Pi4J/pi4j-v1/branches](https://github.com/Pi4J/pi4j-v1/branches) (archived) - * V2: [github.com/Pi4J/pi4j-v2/branches](https://github.com/Pi4J/pi4j-v2/branches) + * V2: [github.com/Pi4J/pi4j/branches](https://github.com/Pi4J/pi4j/branches) ## License diff --git a/libraries/pi4j-library-gpiod/pom.xml b/libraries/pi4j-library-gpiod/pom.xml index a78703a3..fd093492 100644 --- a/libraries/pi4j-library-gpiod/pom.xml +++ b/libraries/pi4j-library-gpiod/pom.xml @@ -6,7 +6,7 @@ com.pi4j pi4j-library - 2.7.0-SNAPSHOT + 3.0.0-SNAPSHOT ../pi4j-library/pom.xml diff --git a/libraries/pi4j-library-linuxfs/pom.xml b/libraries/pi4j-library-linuxfs/pom.xml index e2781f51..e1024e6f 100644 --- a/libraries/pi4j-library-linuxfs/pom.xml +++ b/libraries/pi4j-library-linuxfs/pom.xml @@ -8,7 +8,7 @@ pi4j-library com.pi4j - 2.7.0-SNAPSHOT + 3.0.0-SNAPSHOT ../pi4j-library/pom.xml diff --git a/libraries/pi4j-library-pigpio/pom.xml b/libraries/pi4j-library-pigpio/pom.xml index c48d65c0..94871cc5 100644 --- a/libraries/pi4j-library-pigpio/pom.xml +++ b/libraries/pi4j-library-pigpio/pom.xml @@ -8,7 +8,7 @@ pi4j-library com.pi4j - 2.7.0-SNAPSHOT + 3.0.0-SNAPSHOT ../pi4j-library/pom.xml diff --git a/libraries/pi4j-library-pigpio/src/main/native/com_pi4j_library_pigpio_internal_PIGPIO.c b/libraries/pi4j-library-pigpio/src/main/native/com_pi4j_library_pigpio_internal_PIGPIO.c index a57b827b..85067fe5 100644 --- a/libraries/pi4j-library-pigpio/src/main/native/com_pi4j_library_pigpio_internal_PIGPIO.c +++ b/libraries/pi4j-library-pigpio/src/main/native/com_pi4j_library_pigpio_internal_PIGPIO.c @@ -153,7 +153,7 @@ JNIEXPORT jint JNICALL Java_com_pi4j_library_pigpio_internal_PIGPIO_gpioHardware JNIEXPORT jint JNICALL Java_com_pi4j_library_pigpio_internal_PIGPIO_gpioInitialise (JNIEnv *env, jclass class) { - // SEE: https://github.com/Pi4J/pi4j-v2/issues/15 + // SEE: https://github.com/Pi4J/pi4j/issues/15 // By default, PIGPIO steals all the signal handlers. The JVM doesn't like this // as it uses them in running the JVM so it ends up with the program crashing. // The following should disable the signal handlers inside the PIGPIO library. diff --git a/libraries/pi4j-library/pom.xml b/libraries/pi4j-library/pom.xml index 1924323f..1d8519d6 100644 --- a/libraries/pi4j-library/pom.xml +++ b/libraries/pi4j-library/pom.xml @@ -5,7 +5,7 @@ pi4j-parent com.pi4j - 2.7.0-SNAPSHOT + 3.0.0-SNAPSHOT ../../pom.xml 4.0.0 diff --git a/pi4j-core/pom.xml b/pi4j-core/pom.xml index 5541399e..bc529975 100644 --- a/pi4j-core/pom.xml +++ b/pi4j-core/pom.xml @@ -11,7 +11,7 @@ com.pi4j pi4j-parent - 2.7.0-SNAPSHOT + 3.0.0-SNAPSHOT ../pom.xml diff --git a/pi4j-distribution/pom.xml b/pi4j-distribution/pom.xml index e8add137..70de38c9 100644 --- a/pi4j-distribution/pom.xml +++ b/pi4j-distribution/pom.xml @@ -4,7 +4,7 @@ pi4j-parent com.pi4j - 2.7.0-SNAPSHOT + 3.0.0-SNAPSHOT ../pom.xml diff --git a/pi4j-test/pom.xml b/pi4j-test/pom.xml index f0ad3315..ddc7f02c 100644 --- a/pi4j-test/pom.xml +++ b/pi4j-test/pom.xml @@ -5,7 +5,7 @@ pi4j-parent com.pi4j - 2.7.0-SNAPSHOT + 3.0.0-SNAPSHOT ../pom.xml diff --git a/plugins/pi4j-plugin-gpiod/pom.xml b/plugins/pi4j-plugin-gpiod/pom.xml index 01cd4865..5cdbe16b 100644 --- a/plugins/pi4j-plugin-gpiod/pom.xml +++ b/plugins/pi4j-plugin-gpiod/pom.xml @@ -5,7 +5,7 @@ com.pi4j pi4j-plugin - 2.7.0-SNAPSHOT + 3.0.0-SNAPSHOT ../pi4j-plugin/pom.xml 4.0.0 diff --git a/plugins/pi4j-plugin-linuxfs/pom.xml b/plugins/pi4j-plugin-linuxfs/pom.xml index 3ed501bf..2be07202 100644 --- a/plugins/pi4j-plugin-linuxfs/pom.xml +++ b/plugins/pi4j-plugin-linuxfs/pom.xml @@ -5,7 +5,7 @@ com.pi4j pi4j-plugin - 2.7.0-SNAPSHOT + 3.0.0-SNAPSHOT ../pi4j-plugin/pom.xml 4.0.0 diff --git a/plugins/pi4j-plugin-mock/pom.xml b/plugins/pi4j-plugin-mock/pom.xml index bbd8e287..569336b5 100644 --- a/plugins/pi4j-plugin-mock/pom.xml +++ b/plugins/pi4j-plugin-mock/pom.xml @@ -5,7 +5,7 @@ pi4j-plugin com.pi4j - 2.7.0-SNAPSHOT + 3.0.0-SNAPSHOT ../pi4j-plugin/pom.xml 4.0.0 diff --git a/plugins/pi4j-plugin-pigpio/pom.xml b/plugins/pi4j-plugin-pigpio/pom.xml index 6b72d942..1cdf0396 100644 --- a/plugins/pi4j-plugin-pigpio/pom.xml +++ b/plugins/pi4j-plugin-pigpio/pom.xml @@ -5,7 +5,7 @@ pi4j-plugin com.pi4j - 2.7.0-SNAPSHOT + 3.0.0-SNAPSHOT ../pi4j-plugin/pom.xml 4.0.0 diff --git a/plugins/pi4j-plugin-raspberrypi/pom.xml b/plugins/pi4j-plugin-raspberrypi/pom.xml index a3ec2db8..998db1c0 100644 --- a/plugins/pi4j-plugin-raspberrypi/pom.xml +++ b/plugins/pi4j-plugin-raspberrypi/pom.xml @@ -5,7 +5,7 @@ pi4j-plugin com.pi4j - 2.7.0-SNAPSHOT + 3.0.0-SNAPSHOT ../pi4j-plugin/pom.xml 4.0.0 diff --git a/plugins/pi4j-plugin/pom.xml b/plugins/pi4j-plugin/pom.xml index 79dcc567..238d14cf 100644 --- a/plugins/pi4j-plugin/pom.xml +++ b/plugins/pi4j-plugin/pom.xml @@ -5,7 +5,7 @@ pi4j-parent com.pi4j - 2.7.0-SNAPSHOT + 3.0.0-SNAPSHOT ../../pom.xml 4.0.0 diff --git a/pom.xml b/pom.xml index a670d4c9..6c620585 100644 --- a/pom.xml +++ b/pom.xml @@ -3,17 +3,17 @@ 4.0.0 com.pi4j pi4j-parent - 2.7.0-SNAPSHOT + 3.0.0-SNAPSHOT Pi4J :: Parent POM Parent Maven POM for the Pi4J Project - https://v2.pi4j.com + https://pi4j.com 2012 pom Pi4J - https://v2.pi4j.com + https://pi4j.com @@ -111,14 +111,14 @@ - scm:git:ssh://git@github.com/Pi4J/pi4j-v2.git - scm:git:ssh://git@github.com/Pi4J/pi4j-v2.git - https://github.com/Pi4J/pi4j-v2.git + scm:git:ssh://git@github.com/Pi4J/pi4j.git + scm:git:ssh://git@github.com/Pi4J/pi4j.git + https://github.com/Pi4J/pi4j.git - https://github.com/Pi4J/pi4j-v2/issues + https://github.com/Pi4J/pi4j/issues github @@ -249,7 +249,7 @@ UTF-8 - 11 + 21 ${java.version} ${java.version} From 98ad3c06a43a4bbfff070518a3ca0222b7acadda Mon Sep 17 00:00:00 2001 From: Frank Delporte Date: Sat, 16 Nov 2024 16:05:15 +0100 Subject: [PATCH 02/13] Bump dependencies --- pom.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index 6c620585..0f2e5a1e 100644 --- a/pom.xml +++ b/pom.xml @@ -260,11 +260,11 @@ org.apache.tools.ant.util.FileUtils.getFileUtils() --> 20020829 - 1.10.8 + 1.10.15 0.1.55 - 5.10.2 + 5.11.3 2.0.12 - 2.10.4 + 2.11.0 3.2.0 From 3b0339db385d1cf0d30dffc98c3c2920e698d2d7 Mon Sep 17 00:00:00 2001 From: Frank Delporte Date: Sat, 16 Nov 2024 16:23:08 +0100 Subject: [PATCH 03/13] Bump dependencies --- pom.xml | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 0f2e5a1e..0e7bb58c 100644 --- a/pom.xml +++ b/pom.xml @@ -268,7 +268,7 @@ 3.2.0 - 3.2.0 + 3.5.0 1.8 1.0.0 3.1.0 @@ -708,6 +708,28 @@ + + + org.apache.maven.plugins + maven-enforcer-plugin + 3.5.0 + + + enforce-maven + + enforce + + + + + [3.9,) + + + + + + + org.apache.maven.plugins From a140aaed5b68a9f87af48e151fcb3d857ec3ce43 Mon Sep 17 00:00:00 2001 From: Frank Delporte Date: Sat, 16 Nov 2024 16:49:24 +0100 Subject: [PATCH 04/13] Validate Java and Maven version --- .github/workflows/ci-develop-snapshot.yml | 6 ++++++ .github/workflows/ci-pull-request.yml | 6 ++++++ .github/workflows/ci-release-tags.yml | 6 ++++++ 3 files changed, 18 insertions(+) diff --git a/.github/workflows/ci-develop-snapshot.yml b/.github/workflows/ci-develop-snapshot.yml index 1c5316cd..86a4f4bd 100644 --- a/.github/workflows/ci-develop-snapshot.yml +++ b/.github/workflows/ci-develop-snapshot.yml @@ -13,6 +13,12 @@ jobs: - uses: actions/checkout@v4 - name: Get latest Docker image run: docker pull pi4j/pi4j-builder:2.0 + - name: Validating Java and Maven versions + run: | + echo "Java Version:" + docker run --rm pi4j/pi4j-builder:2.0 java -version + echo "Maven Version:" + docker run --rm pi4j/pi4j-builder:2.0 mvn -version - name: Build entire Pi4J Project in Docker env: MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }} diff --git a/.github/workflows/ci-pull-request.yml b/.github/workflows/ci-pull-request.yml index a7f26747..094a56b3 100644 --- a/.github/workflows/ci-pull-request.yml +++ b/.github/workflows/ci-pull-request.yml @@ -13,6 +13,12 @@ jobs: - uses: actions/checkout@v4 - name: Get latest Docker image run: docker pull pi4j/pi4j-builder:2.0 + - name: Validating Java and Maven versions + run: | + echo "Java Version:" + docker run --rm pi4j/pi4j-builder:2.0 java -version + echo "Maven Version:" + docker run --rm pi4j/pi4j-builder:2.0 mvn -version - name: Build entire Pi4J Project in Docker env: MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }} diff --git a/.github/workflows/ci-release-tags.yml b/.github/workflows/ci-release-tags.yml index 64e3ee6c..d22b224b 100644 --- a/.github/workflows/ci-release-tags.yml +++ b/.github/workflows/ci-release-tags.yml @@ -14,6 +14,12 @@ jobs: - uses: actions/checkout@v4 - name: Get latest Docker image run: docker pull pi4j/pi4j-builder:2.0 + - name: Validating Java and Maven versions + run: | + echo "Java Version:" + docker run --rm pi4j/pi4j-builder:2.0 java -version + echo "Maven Version:" + docker run --rm pi4j/pi4j-builder:2.0 mvn -version - name: Build entire Pi4J Project in Docker env: MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }} From 8b49a30270a8ffdb5cfa4389f6f63a733ec9c87b Mon Sep 17 00:00:00 2001 From: Frank Delporte Date: Sat, 16 Nov 2024 16:52:12 +0100 Subject: [PATCH 05/13] Validate Java and Maven version --- .github/workflows/ci-develop-snapshot.yml | 7 ++++--- .github/workflows/ci-pull-request.yml | 7 ++++--- .github/workflows/ci-release-tags.yml | 7 ++++--- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/.github/workflows/ci-develop-snapshot.yml b/.github/workflows/ci-develop-snapshot.yml index 86a4f4bd..460534f9 100644 --- a/.github/workflows/ci-develop-snapshot.yml +++ b/.github/workflows/ci-develop-snapshot.yml @@ -14,11 +14,12 @@ jobs: - name: Get latest Docker image run: docker pull pi4j/pi4j-builder:2.0 - name: Validating Java and Maven versions + env: + MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }} + MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }} run: | - echo "Java Version:" - docker run --rm pi4j/pi4j-builder:2.0 java -version echo "Maven Version:" - docker run --rm pi4j/pi4j-builder:2.0 mvn -version + docker run --env MAVEN_USERNAME=$MAVEN_USERNAME --env MAVEN_PASSWORD=$MAVEN_PASSWORD --user "$(id -u):$(id -g)" --rm --volume $(pwd):/build pi4j/pi4j-builder:2.0 mvn -v - name: Build entire Pi4J Project in Docker env: MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }} diff --git a/.github/workflows/ci-pull-request.yml b/.github/workflows/ci-pull-request.yml index 094a56b3..43bf76bb 100644 --- a/.github/workflows/ci-pull-request.yml +++ b/.github/workflows/ci-pull-request.yml @@ -14,11 +14,12 @@ jobs: - name: Get latest Docker image run: docker pull pi4j/pi4j-builder:2.0 - name: Validating Java and Maven versions + env: + MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }} + MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }} run: | - echo "Java Version:" - docker run --rm pi4j/pi4j-builder:2.0 java -version echo "Maven Version:" - docker run --rm pi4j/pi4j-builder:2.0 mvn -version + docker run --env MAVEN_USERNAME=$MAVEN_USERNAME --env MAVEN_PASSWORD=$MAVEN_PASSWORD --user "$(id -u):$(id -g)" --rm --volume $(pwd):/build pi4j/pi4j-builder:2.0 mvn -v - name: Build entire Pi4J Project in Docker env: MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }} diff --git a/.github/workflows/ci-release-tags.yml b/.github/workflows/ci-release-tags.yml index d22b224b..687e91b0 100644 --- a/.github/workflows/ci-release-tags.yml +++ b/.github/workflows/ci-release-tags.yml @@ -15,11 +15,12 @@ jobs: - name: Get latest Docker image run: docker pull pi4j/pi4j-builder:2.0 - name: Validating Java and Maven versions + env: + MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }} + MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }} run: | - echo "Java Version:" - docker run --rm pi4j/pi4j-builder:2.0 java -version echo "Maven Version:" - docker run --rm pi4j/pi4j-builder:2.0 mvn -version + docker run --env MAVEN_USERNAME=$MAVEN_USERNAME --env MAVEN_PASSWORD=$MAVEN_PASSWORD --user "$(id -u):$(id -g)" --rm --volume $(pwd):/build pi4j/pi4j-builder:2.0 mvn -v - name: Build entire Pi4J Project in Docker env: MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }} From 4fd7dbddfbd6c8a5ffa2663d9adaacb23b894f48 Mon Sep 17 00:00:00 2001 From: Frank Delporte Date: Sat, 16 Nov 2024 16:53:18 +0100 Subject: [PATCH 06/13] Validate Java and Maven version --- .github/workflows/ci-develop-snapshot.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/ci-develop-snapshot.yml b/.github/workflows/ci-develop-snapshot.yml index 460534f9..9aad0ad7 100644 --- a/.github/workflows/ci-develop-snapshot.yml +++ b/.github/workflows/ci-develop-snapshot.yml @@ -17,9 +17,7 @@ jobs: env: MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }} MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }} - run: | - echo "Maven Version:" - docker run --env MAVEN_USERNAME=$MAVEN_USERNAME --env MAVEN_PASSWORD=$MAVEN_PASSWORD --user "$(id -u):$(id -g)" --rm --volume $(pwd):/build pi4j/pi4j-builder:2.0 mvn -v + run: docker run --env MAVEN_USERNAME=$MAVEN_USERNAME --env MAVEN_PASSWORD=$MAVEN_PASSWORD --user "$(id -u):$(id -g)" --rm --volume $(pwd):/build pi4j/pi4j-builder:2.0 -v - name: Build entire Pi4J Project in Docker env: MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }} From d3ef60ae67e2138c4a3a1e24a15b07517f4b0676 Mon Sep 17 00:00:00 2001 From: Frank Delporte Date: Sat, 16 Nov 2024 16:54:42 +0100 Subject: [PATCH 07/13] Validate Java and Maven version --- .github/workflows/ci-pull-request.yml | 4 +--- .github/workflows/ci-release-tags.yml | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci-pull-request.yml b/.github/workflows/ci-pull-request.yml index 43bf76bb..2045e39c 100644 --- a/.github/workflows/ci-pull-request.yml +++ b/.github/workflows/ci-pull-request.yml @@ -17,9 +17,7 @@ jobs: env: MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }} MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }} - run: | - echo "Maven Version:" - docker run --env MAVEN_USERNAME=$MAVEN_USERNAME --env MAVEN_PASSWORD=$MAVEN_PASSWORD --user "$(id -u):$(id -g)" --rm --volume $(pwd):/build pi4j/pi4j-builder:2.0 mvn -v + run: docker run --env MAVEN_USERNAME=$MAVEN_USERNAME --env MAVEN_PASSWORD=$MAVEN_PASSWORD --user "$(id -u):$(id -g)" --rm --volume $(pwd):/build pi4j/pi4j-builder:2.0 -v - name: Build entire Pi4J Project in Docker env: MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }} diff --git a/.github/workflows/ci-release-tags.yml b/.github/workflows/ci-release-tags.yml index 687e91b0..a886e5c7 100644 --- a/.github/workflows/ci-release-tags.yml +++ b/.github/workflows/ci-release-tags.yml @@ -18,9 +18,7 @@ jobs: env: MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }} MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }} - run: | - echo "Maven Version:" - docker run --env MAVEN_USERNAME=$MAVEN_USERNAME --env MAVEN_PASSWORD=$MAVEN_PASSWORD --user "$(id -u):$(id -g)" --rm --volume $(pwd):/build pi4j/pi4j-builder:2.0 mvn -v + run: docker run --env MAVEN_USERNAME=$MAVEN_USERNAME --env MAVEN_PASSWORD=$MAVEN_PASSWORD --user "$(id -u):$(id -g)" --rm --volume $(pwd):/build pi4j/pi4j-builder:2.0 -v - name: Build entire Pi4J Project in Docker env: MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }} From 85a0a508e583ee7e45fb64c2d71b36ca40b4bbaa Mon Sep 17 00:00:00 2001 From: Frank Delporte Date: Sat, 16 Nov 2024 17:09:25 +0100 Subject: [PATCH 08/13] Revert validate Java and Maven version --- .github/workflows/ci-develop-snapshot.yml | 5 ----- .github/workflows/ci-pull-request.yml | 7 +------ .github/workflows/ci-release-tags.yml | 5 ----- 3 files changed, 1 insertion(+), 16 deletions(-) diff --git a/.github/workflows/ci-develop-snapshot.yml b/.github/workflows/ci-develop-snapshot.yml index 9aad0ad7..1c5316cd 100644 --- a/.github/workflows/ci-develop-snapshot.yml +++ b/.github/workflows/ci-develop-snapshot.yml @@ -13,11 +13,6 @@ jobs: - uses: actions/checkout@v4 - name: Get latest Docker image run: docker pull pi4j/pi4j-builder:2.0 - - name: Validating Java and Maven versions - env: - MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }} - MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }} - run: docker run --env MAVEN_USERNAME=$MAVEN_USERNAME --env MAVEN_PASSWORD=$MAVEN_PASSWORD --user "$(id -u):$(id -g)" --rm --volume $(pwd):/build pi4j/pi4j-builder:2.0 -v - name: Build entire Pi4J Project in Docker env: MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }} diff --git a/.github/workflows/ci-pull-request.yml b/.github/workflows/ci-pull-request.yml index 2045e39c..d42d6f53 100644 --- a/.github/workflows/ci-pull-request.yml +++ b/.github/workflows/ci-pull-request.yml @@ -13,16 +13,11 @@ jobs: - uses: actions/checkout@v4 - name: Get latest Docker image run: docker pull pi4j/pi4j-builder:2.0 - - name: Validating Java and Maven versions - env: - MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }} - MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }} - run: docker run --env MAVEN_USERNAME=$MAVEN_USERNAME --env MAVEN_PASSWORD=$MAVEN_PASSWORD --user "$(id -u):$(id -g)" --rm --volume $(pwd):/build pi4j/pi4j-builder:2.0 -v - name: Build entire Pi4J Project in Docker env: MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }} MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }} - run: docker run --env MAVEN_USERNAME=$MAVEN_USERNAME --env MAVEN_PASSWORD=$MAVEN_PASSWORD --user "$(id -u):$(id -g)" --rm --volume $(pwd):/build pi4j/pi4j-builder:2.0 clean install -Pnative,cross-compile --batch-mode + run: docker run --env MAVEN_USERNAME=$MAVEN_USERNAME --env MAVEN_PASSWORD=$MAVEN_PASSWORD --user "$(id -u):$(id -g)" --rm --volume $(pwd):/build pi4j/pi4j-builder:2.0 mvn clean install -Pnative,cross-compile --batch-mode - name: Make staging directory run: mkdir staging - name: Copy distribution files to staging diff --git a/.github/workflows/ci-release-tags.yml b/.github/workflows/ci-release-tags.yml index a886e5c7..64e3ee6c 100644 --- a/.github/workflows/ci-release-tags.yml +++ b/.github/workflows/ci-release-tags.yml @@ -14,11 +14,6 @@ jobs: - uses: actions/checkout@v4 - name: Get latest Docker image run: docker pull pi4j/pi4j-builder:2.0 - - name: Validating Java and Maven versions - env: - MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }} - MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }} - run: docker run --env MAVEN_USERNAME=$MAVEN_USERNAME --env MAVEN_PASSWORD=$MAVEN_PASSWORD --user "$(id -u):$(id -g)" --rm --volume $(pwd):/build pi4j/pi4j-builder:2.0 -v - name: Build entire Pi4J Project in Docker env: MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }} From f118c049a264f36b9b46df3fd0995066f31921c3 Mon Sep 17 00:00:00 2001 From: Frank Delporte Date: Sat, 16 Nov 2024 17:12:40 +0100 Subject: [PATCH 09/13] Revert validate Java and Maven version --- .github/workflows/ci-pull-request.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci-pull-request.yml b/.github/workflows/ci-pull-request.yml index d42d6f53..a7f26747 100644 --- a/.github/workflows/ci-pull-request.yml +++ b/.github/workflows/ci-pull-request.yml @@ -17,7 +17,7 @@ jobs: env: MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }} MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }} - run: docker run --env MAVEN_USERNAME=$MAVEN_USERNAME --env MAVEN_PASSWORD=$MAVEN_PASSWORD --user "$(id -u):$(id -g)" --rm --volume $(pwd):/build pi4j/pi4j-builder:2.0 mvn clean install -Pnative,cross-compile --batch-mode + run: docker run --env MAVEN_USERNAME=$MAVEN_USERNAME --env MAVEN_PASSWORD=$MAVEN_PASSWORD --user "$(id -u):$(id -g)" --rm --volume $(pwd):/build pi4j/pi4j-builder:2.0 clean install -Pnative,cross-compile --batch-mode - name: Make staging directory run: mkdir staging - name: Copy distribution files to staging From eb6d578f40f3f529f0473b3ec6f9fff543959f80 Mon Sep 17 00:00:00 2001 From: Dariusz Zbyrad Date: Wed, 27 Nov 2024 13:42:24 +0100 Subject: [PATCH 10/13] Update Maven Plugin Versions and add Apache Maven Wrapper --- .mvn/wrapper/maven-wrapper.properties | 19 ++ mvnw | 259 ++++++++++++++++++++++++++ mvnw.cmd | 149 +++++++++++++++ pom.xml | 27 +-- 4 files changed, 441 insertions(+), 13 deletions(-) create mode 100644 .mvn/wrapper/maven-wrapper.properties create mode 100755 mvnw create mode 100644 mvnw.cmd diff --git a/.mvn/wrapper/maven-wrapper.properties b/.mvn/wrapper/maven-wrapper.properties new file mode 100644 index 00000000..93a0d797 --- /dev/null +++ b/.mvn/wrapper/maven-wrapper.properties @@ -0,0 +1,19 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. +wrapperVersion=3.3.2 +distributionType=only-script +distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.4/apache-maven-3.9.4-bin.zip diff --git a/mvnw b/mvnw new file mode 100755 index 00000000..19529ddf --- /dev/null +++ b/mvnw @@ -0,0 +1,259 @@ +#!/bin/sh +# ---------------------------------------------------------------------------- +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. +# ---------------------------------------------------------------------------- + +# ---------------------------------------------------------------------------- +# Apache Maven Wrapper startup batch script, version 3.3.2 +# +# Optional ENV vars +# ----------------- +# JAVA_HOME - location of a JDK home dir, required when download maven via java source +# MVNW_REPOURL - repo url base for downloading maven distribution +# MVNW_USERNAME/MVNW_PASSWORD - user and password for downloading maven +# MVNW_VERBOSE - true: enable verbose log; debug: trace the mvnw script; others: silence the output +# ---------------------------------------------------------------------------- + +set -euf +[ "${MVNW_VERBOSE-}" != debug ] || set -x + +# OS specific support. +native_path() { printf %s\\n "$1"; } +case "$(uname)" in +CYGWIN* | MINGW*) + [ -z "${JAVA_HOME-}" ] || JAVA_HOME="$(cygpath --unix "$JAVA_HOME")" + native_path() { cygpath --path --windows "$1"; } + ;; +esac + +# set JAVACMD and JAVACCMD +set_java_home() { + # For Cygwin and MinGW, ensure paths are in Unix format before anything is touched + if [ -n "${JAVA_HOME-}" ]; then + if [ -x "$JAVA_HOME/jre/sh/java" ]; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + JAVACCMD="$JAVA_HOME/jre/sh/javac" + else + JAVACMD="$JAVA_HOME/bin/java" + JAVACCMD="$JAVA_HOME/bin/javac" + + if [ ! -x "$JAVACMD" ] || [ ! -x "$JAVACCMD" ]; then + echo "The JAVA_HOME environment variable is not defined correctly, so mvnw cannot run." >&2 + echo "JAVA_HOME is set to \"$JAVA_HOME\", but \"\$JAVA_HOME/bin/java\" or \"\$JAVA_HOME/bin/javac\" does not exist." >&2 + return 1 + fi + fi + else + JAVACMD="$( + 'set' +e + 'unset' -f command 2>/dev/null + 'command' -v java + )" || : + JAVACCMD="$( + 'set' +e + 'unset' -f command 2>/dev/null + 'command' -v javac + )" || : + + if [ ! -x "${JAVACMD-}" ] || [ ! -x "${JAVACCMD-}" ]; then + echo "The java/javac command does not exist in PATH nor is JAVA_HOME set, so mvnw cannot run." >&2 + return 1 + fi + fi +} + +# hash string like Java String::hashCode +hash_string() { + str="${1:-}" h=0 + while [ -n "$str" ]; do + char="${str%"${str#?}"}" + h=$(((h * 31 + $(LC_CTYPE=C printf %d "'$char")) % 4294967296)) + str="${str#?}" + done + printf %x\\n $h +} + +verbose() { :; } +[ "${MVNW_VERBOSE-}" != true ] || verbose() { printf %s\\n "${1-}"; } + +die() { + printf %s\\n "$1" >&2 + exit 1 +} + +trim() { + # MWRAPPER-139: + # Trims trailing and leading whitespace, carriage returns, tabs, and linefeeds. + # Needed for removing poorly interpreted newline sequences when running in more + # exotic environments such as mingw bash on Windows. + printf "%s" "${1}" | tr -d '[:space:]' +} + +# parse distributionUrl and optional distributionSha256Sum, requires .mvn/wrapper/maven-wrapper.properties +while IFS="=" read -r key value; do + case "${key-}" in + distributionUrl) distributionUrl=$(trim "${value-}") ;; + distributionSha256Sum) distributionSha256Sum=$(trim "${value-}") ;; + esac +done <"${0%/*}/.mvn/wrapper/maven-wrapper.properties" +[ -n "${distributionUrl-}" ] || die "cannot read distributionUrl property in ${0%/*}/.mvn/wrapper/maven-wrapper.properties" + +case "${distributionUrl##*/}" in +maven-mvnd-*bin.*) + MVN_CMD=mvnd.sh _MVNW_REPO_PATTERN=/maven/mvnd/ + case "${PROCESSOR_ARCHITECTURE-}${PROCESSOR_ARCHITEW6432-}:$(uname -a)" in + *AMD64:CYGWIN* | *AMD64:MINGW*) distributionPlatform=windows-amd64 ;; + :Darwin*x86_64) distributionPlatform=darwin-amd64 ;; + :Darwin*arm64) distributionPlatform=darwin-aarch64 ;; + :Linux*x86_64*) distributionPlatform=linux-amd64 ;; + *) + echo "Cannot detect native platform for mvnd on $(uname)-$(uname -m), use pure java version" >&2 + distributionPlatform=linux-amd64 + ;; + esac + distributionUrl="${distributionUrl%-bin.*}-$distributionPlatform.zip" + ;; +maven-mvnd-*) MVN_CMD=mvnd.sh _MVNW_REPO_PATTERN=/maven/mvnd/ ;; +*) MVN_CMD="mvn${0##*/mvnw}" _MVNW_REPO_PATTERN=/org/apache/maven/ ;; +esac + +# apply MVNW_REPOURL and calculate MAVEN_HOME +# maven home pattern: ~/.m2/wrapper/dists/{apache-maven-,maven-mvnd--}/ +[ -z "${MVNW_REPOURL-}" ] || distributionUrl="$MVNW_REPOURL$_MVNW_REPO_PATTERN${distributionUrl#*"$_MVNW_REPO_PATTERN"}" +distributionUrlName="${distributionUrl##*/}" +distributionUrlNameMain="${distributionUrlName%.*}" +distributionUrlNameMain="${distributionUrlNameMain%-bin}" +MAVEN_USER_HOME="${MAVEN_USER_HOME:-${HOME}/.m2}" +MAVEN_HOME="${MAVEN_USER_HOME}/wrapper/dists/${distributionUrlNameMain-}/$(hash_string "$distributionUrl")" + +exec_maven() { + unset MVNW_VERBOSE MVNW_USERNAME MVNW_PASSWORD MVNW_REPOURL || : + exec "$MAVEN_HOME/bin/$MVN_CMD" "$@" || die "cannot exec $MAVEN_HOME/bin/$MVN_CMD" +} + +if [ -d "$MAVEN_HOME" ]; then + verbose "found existing MAVEN_HOME at $MAVEN_HOME" + exec_maven "$@" +fi + +case "${distributionUrl-}" in +*?-bin.zip | *?maven-mvnd-?*-?*.zip) ;; +*) die "distributionUrl is not valid, must match *-bin.zip or maven-mvnd-*.zip, but found '${distributionUrl-}'" ;; +esac + +# prepare tmp dir +if TMP_DOWNLOAD_DIR="$(mktemp -d)" && [ -d "$TMP_DOWNLOAD_DIR" ]; then + clean() { rm -rf -- "$TMP_DOWNLOAD_DIR"; } + trap clean HUP INT TERM EXIT +else + die "cannot create temp dir" +fi + +mkdir -p -- "${MAVEN_HOME%/*}" + +# Download and Install Apache Maven +verbose "Couldn't find MAVEN_HOME, downloading and installing it ..." +verbose "Downloading from: $distributionUrl" +verbose "Downloading to: $TMP_DOWNLOAD_DIR/$distributionUrlName" + +# select .zip or .tar.gz +if ! command -v unzip >/dev/null; then + distributionUrl="${distributionUrl%.zip}.tar.gz" + distributionUrlName="${distributionUrl##*/}" +fi + +# verbose opt +__MVNW_QUIET_WGET=--quiet __MVNW_QUIET_CURL=--silent __MVNW_QUIET_UNZIP=-q __MVNW_QUIET_TAR='' +[ "${MVNW_VERBOSE-}" != true ] || __MVNW_QUIET_WGET='' __MVNW_QUIET_CURL='' __MVNW_QUIET_UNZIP='' __MVNW_QUIET_TAR=v + +# normalize http auth +case "${MVNW_PASSWORD:+has-password}" in +'') MVNW_USERNAME='' MVNW_PASSWORD='' ;; +has-password) [ -n "${MVNW_USERNAME-}" ] || MVNW_USERNAME='' MVNW_PASSWORD='' ;; +esac + +if [ -z "${MVNW_USERNAME-}" ] && command -v wget >/dev/null; then + verbose "Found wget ... using wget" + wget ${__MVNW_QUIET_WGET:+"$__MVNW_QUIET_WGET"} "$distributionUrl" -O "$TMP_DOWNLOAD_DIR/$distributionUrlName" || die "wget: Failed to fetch $distributionUrl" +elif [ -z "${MVNW_USERNAME-}" ] && command -v curl >/dev/null; then + verbose "Found curl ... using curl" + curl ${__MVNW_QUIET_CURL:+"$__MVNW_QUIET_CURL"} -f -L -o "$TMP_DOWNLOAD_DIR/$distributionUrlName" "$distributionUrl" || die "curl: Failed to fetch $distributionUrl" +elif set_java_home; then + verbose "Falling back to use Java to download" + javaSource="$TMP_DOWNLOAD_DIR/Downloader.java" + targetZip="$TMP_DOWNLOAD_DIR/$distributionUrlName" + cat >"$javaSource" <<-END + public class Downloader extends java.net.Authenticator + { + protected java.net.PasswordAuthentication getPasswordAuthentication() + { + return new java.net.PasswordAuthentication( System.getenv( "MVNW_USERNAME" ), System.getenv( "MVNW_PASSWORD" ).toCharArray() ); + } + public static void main( String[] args ) throws Exception + { + setDefault( new Downloader() ); + java.nio.file.Files.copy( java.net.URI.create( args[0] ).toURL().openStream(), java.nio.file.Paths.get( args[1] ).toAbsolutePath().normalize() ); + } + } + END + # For Cygwin/MinGW, switch paths to Windows format before running javac and java + verbose " - Compiling Downloader.java ..." + "$(native_path "$JAVACCMD")" "$(native_path "$javaSource")" || die "Failed to compile Downloader.java" + verbose " - Running Downloader.java ..." + "$(native_path "$JAVACMD")" -cp "$(native_path "$TMP_DOWNLOAD_DIR")" Downloader "$distributionUrl" "$(native_path "$targetZip")" +fi + +# If specified, validate the SHA-256 sum of the Maven distribution zip file +if [ -n "${distributionSha256Sum-}" ]; then + distributionSha256Result=false + if [ "$MVN_CMD" = mvnd.sh ]; then + echo "Checksum validation is not supported for maven-mvnd." >&2 + echo "Please disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties." >&2 + exit 1 + elif command -v sha256sum >/dev/null; then + if echo "$distributionSha256Sum $TMP_DOWNLOAD_DIR/$distributionUrlName" | sha256sum -c >/dev/null 2>&1; then + distributionSha256Result=true + fi + elif command -v shasum >/dev/null; then + if echo "$distributionSha256Sum $TMP_DOWNLOAD_DIR/$distributionUrlName" | shasum -a 256 -c >/dev/null 2>&1; then + distributionSha256Result=true + fi + else + echo "Checksum validation was requested but neither 'sha256sum' or 'shasum' are available." >&2 + echo "Please install either command, or disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties." >&2 + exit 1 + fi + if [ $distributionSha256Result = false ]; then + echo "Error: Failed to validate Maven distribution SHA-256, your Maven distribution might be compromised." >&2 + echo "If you updated your Maven version, you need to update the specified distributionSha256Sum property." >&2 + exit 1 + fi +fi + +# unzip and move +if command -v unzip >/dev/null; then + unzip ${__MVNW_QUIET_UNZIP:+"$__MVNW_QUIET_UNZIP"} "$TMP_DOWNLOAD_DIR/$distributionUrlName" -d "$TMP_DOWNLOAD_DIR" || die "failed to unzip" +else + tar xzf${__MVNW_QUIET_TAR:+"$__MVNW_QUIET_TAR"} "$TMP_DOWNLOAD_DIR/$distributionUrlName" -C "$TMP_DOWNLOAD_DIR" || die "failed to untar" +fi +printf %s\\n "$distributionUrl" >"$TMP_DOWNLOAD_DIR/$distributionUrlNameMain/mvnw.url" +mv -- "$TMP_DOWNLOAD_DIR/$distributionUrlNameMain" "$MAVEN_HOME" || [ -d "$MAVEN_HOME" ] || die "fail to move MAVEN_HOME" + +clean || : +exec_maven "$@" diff --git a/mvnw.cmd b/mvnw.cmd new file mode 100644 index 00000000..249bdf38 --- /dev/null +++ b/mvnw.cmd @@ -0,0 +1,149 @@ +<# : batch portion +@REM ---------------------------------------------------------------------------- +@REM Licensed to the Apache Software Foundation (ASF) under one +@REM or more contributor license agreements. See the NOTICE file +@REM distributed with this work for additional information +@REM regarding copyright ownership. The ASF licenses this file +@REM to you under the Apache License, Version 2.0 (the +@REM "License"); you may not use this file except in compliance +@REM with the License. You may obtain a copy of the License at +@REM +@REM http://www.apache.org/licenses/LICENSE-2.0 +@REM +@REM Unless required by applicable law or agreed to in writing, +@REM software distributed under the License is distributed on an +@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +@REM KIND, either express or implied. See the License for the +@REM specific language governing permissions and limitations +@REM under the License. +@REM ---------------------------------------------------------------------------- + +@REM ---------------------------------------------------------------------------- +@REM Apache Maven Wrapper startup batch script, version 3.3.2 +@REM +@REM Optional ENV vars +@REM MVNW_REPOURL - repo url base for downloading maven distribution +@REM MVNW_USERNAME/MVNW_PASSWORD - user and password for downloading maven +@REM MVNW_VERBOSE - true: enable verbose log; others: silence the output +@REM ---------------------------------------------------------------------------- + +@IF "%__MVNW_ARG0_NAME__%"=="" (SET __MVNW_ARG0_NAME__=%~nx0) +@SET __MVNW_CMD__= +@SET __MVNW_ERROR__= +@SET __MVNW_PSMODULEP_SAVE=%PSModulePath% +@SET PSModulePath= +@FOR /F "usebackq tokens=1* delims==" %%A IN (`powershell -noprofile "& {$scriptDir='%~dp0'; $script='%__MVNW_ARG0_NAME__%'; icm -ScriptBlock ([Scriptblock]::Create((Get-Content -Raw '%~f0'))) -NoNewScope}"`) DO @( + IF "%%A"=="MVN_CMD" (set __MVNW_CMD__=%%B) ELSE IF "%%B"=="" (echo %%A) ELSE (echo %%A=%%B) +) +@SET PSModulePath=%__MVNW_PSMODULEP_SAVE% +@SET __MVNW_PSMODULEP_SAVE= +@SET __MVNW_ARG0_NAME__= +@SET MVNW_USERNAME= +@SET MVNW_PASSWORD= +@IF NOT "%__MVNW_CMD__%"=="" (%__MVNW_CMD__% %*) +@echo Cannot start maven from wrapper >&2 && exit /b 1 +@GOTO :EOF +: end batch / begin powershell #> + +$ErrorActionPreference = "Stop" +if ($env:MVNW_VERBOSE -eq "true") { + $VerbosePreference = "Continue" +} + +# calculate distributionUrl, requires .mvn/wrapper/maven-wrapper.properties +$distributionUrl = (Get-Content -Raw "$scriptDir/.mvn/wrapper/maven-wrapper.properties" | ConvertFrom-StringData).distributionUrl +if (!$distributionUrl) { + Write-Error "cannot read distributionUrl property in $scriptDir/.mvn/wrapper/maven-wrapper.properties" +} + +switch -wildcard -casesensitive ( $($distributionUrl -replace '^.*/','') ) { + "maven-mvnd-*" { + $USE_MVND = $true + $distributionUrl = $distributionUrl -replace '-bin\.[^.]*$',"-windows-amd64.zip" + $MVN_CMD = "mvnd.cmd" + break + } + default { + $USE_MVND = $false + $MVN_CMD = $script -replace '^mvnw','mvn' + break + } +} + +# apply MVNW_REPOURL and calculate MAVEN_HOME +# maven home pattern: ~/.m2/wrapper/dists/{apache-maven-,maven-mvnd--}/ +if ($env:MVNW_REPOURL) { + $MVNW_REPO_PATTERN = if ($USE_MVND) { "/org/apache/maven/" } else { "/maven/mvnd/" } + $distributionUrl = "$env:MVNW_REPOURL$MVNW_REPO_PATTERN$($distributionUrl -replace '^.*'+$MVNW_REPO_PATTERN,'')" +} +$distributionUrlName = $distributionUrl -replace '^.*/','' +$distributionUrlNameMain = $distributionUrlName -replace '\.[^.]*$','' -replace '-bin$','' +$MAVEN_HOME_PARENT = "$HOME/.m2/wrapper/dists/$distributionUrlNameMain" +if ($env:MAVEN_USER_HOME) { + $MAVEN_HOME_PARENT = "$env:MAVEN_USER_HOME/wrapper/dists/$distributionUrlNameMain" +} +$MAVEN_HOME_NAME = ([System.Security.Cryptography.MD5]::Create().ComputeHash([byte[]][char[]]$distributionUrl) | ForEach-Object {$_.ToString("x2")}) -join '' +$MAVEN_HOME = "$MAVEN_HOME_PARENT/$MAVEN_HOME_NAME" + +if (Test-Path -Path "$MAVEN_HOME" -PathType Container) { + Write-Verbose "found existing MAVEN_HOME at $MAVEN_HOME" + Write-Output "MVN_CMD=$MAVEN_HOME/bin/$MVN_CMD" + exit $? +} + +if (! $distributionUrlNameMain -or ($distributionUrlName -eq $distributionUrlNameMain)) { + Write-Error "distributionUrl is not valid, must end with *-bin.zip, but found $distributionUrl" +} + +# prepare tmp dir +$TMP_DOWNLOAD_DIR_HOLDER = New-TemporaryFile +$TMP_DOWNLOAD_DIR = New-Item -Itemtype Directory -Path "$TMP_DOWNLOAD_DIR_HOLDER.dir" +$TMP_DOWNLOAD_DIR_HOLDER.Delete() | Out-Null +trap { + if ($TMP_DOWNLOAD_DIR.Exists) { + try { Remove-Item $TMP_DOWNLOAD_DIR -Recurse -Force | Out-Null } + catch { Write-Warning "Cannot remove $TMP_DOWNLOAD_DIR" } + } +} + +New-Item -Itemtype Directory -Path "$MAVEN_HOME_PARENT" -Force | Out-Null + +# Download and Install Apache Maven +Write-Verbose "Couldn't find MAVEN_HOME, downloading and installing it ..." +Write-Verbose "Downloading from: $distributionUrl" +Write-Verbose "Downloading to: $TMP_DOWNLOAD_DIR/$distributionUrlName" + +$webclient = New-Object System.Net.WebClient +if ($env:MVNW_USERNAME -and $env:MVNW_PASSWORD) { + $webclient.Credentials = New-Object System.Net.NetworkCredential($env:MVNW_USERNAME, $env:MVNW_PASSWORD) +} +[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 +$webclient.DownloadFile($distributionUrl, "$TMP_DOWNLOAD_DIR/$distributionUrlName") | Out-Null + +# If specified, validate the SHA-256 sum of the Maven distribution zip file +$distributionSha256Sum = (Get-Content -Raw "$scriptDir/.mvn/wrapper/maven-wrapper.properties" | ConvertFrom-StringData).distributionSha256Sum +if ($distributionSha256Sum) { + if ($USE_MVND) { + Write-Error "Checksum validation is not supported for maven-mvnd. `nPlease disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties." + } + Import-Module $PSHOME\Modules\Microsoft.PowerShell.Utility -Function Get-FileHash + if ((Get-FileHash "$TMP_DOWNLOAD_DIR/$distributionUrlName" -Algorithm SHA256).Hash.ToLower() -ne $distributionSha256Sum) { + Write-Error "Error: Failed to validate Maven distribution SHA-256, your Maven distribution might be compromised. If you updated your Maven version, you need to update the specified distributionSha256Sum property." + } +} + +# unzip and move +Expand-Archive "$TMP_DOWNLOAD_DIR/$distributionUrlName" -DestinationPath "$TMP_DOWNLOAD_DIR" | Out-Null +Rename-Item -Path "$TMP_DOWNLOAD_DIR/$distributionUrlNameMain" -NewName $MAVEN_HOME_NAME | Out-Null +try { + Move-Item -Path "$TMP_DOWNLOAD_DIR/$MAVEN_HOME_NAME" -Destination $MAVEN_HOME_PARENT | Out-Null +} catch { + if (! (Test-Path -Path "$MAVEN_HOME" -PathType Container)) { + Write-Error "fail to move MAVEN_HOME" + } +} finally { + try { Remove-Item $TMP_DOWNLOAD_DIR -Recurse -Force | Out-Null } + catch { Write-Warning "Cannot remove $TMP_DOWNLOAD_DIR" } +} + +Write-Output "MVN_CMD=$MAVEN_HOME/bin/$MVN_CMD" diff --git a/pom.xml b/pom.xml index 0e7bb58c..75b313ce 100644 --- a/pom.xml +++ b/pom.xml @@ -267,26 +267,27 @@ 2.11.0 - 3.2.0 + 3.6.0 3.5.0 1.8 1.0.0 3.1.0 - 3.3.0 - 5.1.2 + 3.7.1 + 5.1.9 3.13.0 - 3.1.2 - 3.2.1 + 3.6.0 + 3.8.1 + 3.2.7 3.4.2 - 3.6.3 - 3.0.0-M4 - 3.2.0 - 1.11.2 - 3.9.1 - 3.2.0 - 3.0.0-M5 + 3.11.1 + 3.1.1 + 3.3.1 + 2.1.0 + 3.21.0 + 3.3.1 + 3.5.2 1.0-alpha-9 - 1.6.13 + 1.7.0 3.5.0 From da15858e7f23ea83c4f8c423f97c46213c0decba Mon Sep 17 00:00:00 2001 From: Frank Delporte Date: Tue, 28 Jan 2025 14:35:37 +0100 Subject: [PATCH 11/13] Cleanup --- .../main/java/com/pi4j/context/Context.java | 43 +-- .../main/java/com/pi4j/util/StringUtil.java | 248 +++++++++--------- pom.xml | 95 +++---- 3 files changed, 193 insertions(+), 193 deletions(-) diff --git a/pi4j-core/src/main/java/com/pi4j/context/Context.java b/pi4j-core/src/main/java/com/pi4j/context/Context.java index 7ee9b77a..0ea85561 100644 --- a/pi4j-core/src/main/java/com/pi4j/context/Context.java +++ b/pi4j-core/src/main/java/com/pi4j/context/Context.java @@ -107,7 +107,6 @@ public interface Context extends Describable, IOCreator, ProviderProvider, Initi * Submits the given task for async execution * * @param task the task to execute asynchronously - * * @return the task to cancel later */ Future submitTask(Runnable task); @@ -121,13 +120,11 @@ public interface Context extends Describable, IOCreator, ProviderProvider, Initi Context shutdown() throws ShutdownException; /** - * * @return {@link Future} of {@link Context} */ Future asyncShutdown(); /** - * * @return Flag indicating if the context has been shutdown */ boolean isShutdown(); @@ -215,7 +212,7 @@ default boolean hasPlatform(String id) throws PlatformNotFoundException { *

platform.

* * @param platformClass a P object. - * @param

the platform type + * @param

the platform type * @return a P object. * @throws PlatformNotFoundException if platform specified by {@code platformClass} is not found. */ @@ -227,7 +224,7 @@ default

P platform(Class

platformClass) throws PlatformN *

platform.

* * @param platformClass a P object. - * @param

the platform type + * @param

the platform type * @return a P object. * @throws PlatformNotFoundException if platform specified by {@code platformClass} is not found. */ @@ -239,7 +236,7 @@ default

P getPlatform(Class

platformClass) throws Platfo *

Has platforms.

* * @param platformClass a P object. - * @return {@link boolean} + * @return boolean * @throws PlatformNotFoundException if platform specified by {@code platformClass} is not found. */ default boolean hasPlatform(Class platformClass) throws PlatformNotFoundException { @@ -250,18 +247,24 @@ default boolean hasPlatform(Class platformClass) throws Plat // PROVIDER ACCESSOR METHODS // ------------------------------------------------------------------------ - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ default T provider(String providerId) throws ProviderNotFoundException { return (T) providers().get(providerId); } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ default T provider(String providerId, Class providerClass) throws ProviderNotFoundException { return (T) providers().get(providerId); } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ default boolean hasProvider(String providerId) { try { return providers().exists(providerId); @@ -270,17 +273,23 @@ default boolean hasProvider(String providerId) { } } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ default boolean hasProvider(IOType ioType) { return providers().exists(ioType); } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ default boolean hasProvider(Class providerClass) { return providers().exists(providerClass); } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ default T provider(Class providerClass) throws ProviderNotFoundException, ProviderInterfaceException { // return the default provider for this type from the default platform @@ -295,7 +304,9 @@ default T provider(Class providerClass) throw new ProviderNotFoundException(providerClass); } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ default T provider(IOType ioType) throws ProviderNotFoundException { // return the default provider for this type from the default platform if (platform() != null && platform().hasProvider(ioType)) @@ -389,7 +400,7 @@ default T create(String id) { if (provider == null) { // unable to resolve the IO type and thus unable to create I/O instance throw new IOException("This IO instance [" + id + - "] could not be created because it does not define one of the following: 'PLATFORM', 'PROVIDER', or 'I/O TYPE'."); + "] could not be created because it does not define one of the following: 'PLATFORM', 'PROVIDER', or 'I/O TYPE'."); } // create IO instance using the provided ID and resolved inherited properties @@ -423,8 +434,8 @@ default T create(String id, IOType ioType) { // validate IO type from resolved provider if (!ioType.isType(provider.type())) { throw new IOException("This IO instance [" + id + - "] could not be created because the resolved provider [" + providerId + - "] does not match the required I/O TYPE [" + ioType.name() + "]"); + "] could not be created because the resolved provider [" + providerId + + "] does not match the required I/O TYPE [" + ioType.name() + "]"); } } diff --git a/pi4j-core/src/main/java/com/pi4j/util/StringUtil.java b/pi4j-core/src/main/java/com/pi4j/util/StringUtil.java index 584c8b46..dc12a580 100644 --- a/pi4j-core/src/main/java/com/pi4j/util/StringUtil.java +++ b/pi4j-core/src/main/java/com/pi4j/util/StringUtil.java @@ -39,9 +39,13 @@ */ public class StringUtil { - /** Constant EMPTY="" */ + /** + * Constant EMPTY="" + */ public static final String EMPTY = ""; - /** Constant DEFAULT_PAD_CHAR=' ' */ + /** + * Constant DEFAULT_PAD_CHAR=' ' + */ public static final char DEFAULT_PAD_CHAR = ' '; /** @@ -51,13 +55,13 @@ public class StringUtil { * @param trim a boolean. * @return a boolean. */ - public static boolean isNullOrEmpty(String data, boolean trim){ - if(data == null) + public static boolean isNullOrEmpty(String data, boolean trim) { + if (data == null) return true; // trim if requested String test = data; - if(trim) + if (trim) test = data.trim(); return (test.length() <= 0); @@ -69,7 +73,7 @@ public static boolean isNullOrEmpty(String data, boolean trim){ * @param data a {@link java.lang.String} object. * @return a boolean. */ - public static boolean isNullOrEmpty(String data){ + public static boolean isNullOrEmpty(String data) { return isNullOrEmpty(data, false); } @@ -79,7 +83,7 @@ public static boolean isNullOrEmpty(String data){ * @param data a {@link java.lang.String} object. * @return a boolean. */ - public static boolean isNotNullOrEmpty(String data){ + public static boolean isNotNullOrEmpty(String data) { return isNotNullOrEmpty(data, false); } @@ -90,20 +94,20 @@ public static boolean isNotNullOrEmpty(String data){ * @param trim a boolean. * @return a boolean. */ - public static boolean isNotNullOrEmpty(String data, boolean trim){ + public static boolean isNotNullOrEmpty(String data, boolean trim) { return !(isNullOrEmpty(data, trim)); } /** *

setIfNullOrEmpty.

* - * @param data a {@link java.lang.String} object. + * @param data a {@link java.lang.String} object. * @param replacement a {@link java.lang.String} object. - * @param trim a boolean. + * @param trim a boolean. * @return a {@link java.lang.String} object. */ - public static String setIfNullOrEmpty(String data, String replacement, boolean trim){ - if(isNullOrEmpty(data, trim)) { + public static String setIfNullOrEmpty(String data, String replacement, boolean trim) { + if (isNullOrEmpty(data, trim)) { return replacement; } return data; @@ -112,11 +116,11 @@ public static String setIfNullOrEmpty(String data, String replacement, boolean t /** *

setIfNullOrEmpty.

* - * @param data a {@link java.lang.String} object. + * @param data a {@link java.lang.String} object. * @param replacement a {@link java.lang.String} object. * @return a {@link java.lang.String} object. */ - public static String setIfNullOrEmpty(String data, String replacement){ + public static String setIfNullOrEmpty(String data, String replacement) { return setIfNullOrEmpty(data, replacement, false); } @@ -127,20 +131,20 @@ public static String setIfNullOrEmpty(String data, String replacement){ * @param target a {@link java.lang.String} object. * @return a boolean. */ - public static boolean contains(String source, String target) { + public static boolean contains(String source, String target) { return (null != source && null != target && source.contains(target)); } /** *

contains.

* - * @param source a {@link java.lang.String} object. + * @param source a {@link java.lang.String} object. * @param targets an array of {@link java.lang.String} objects. * @return a boolean. */ - public static boolean contains(String source, String[] targets) { + public static boolean contains(String source, String[] targets) { if (null != source && null != targets) { - for(var target : targets) { + for (var target : targets) { if (source.contains(target)) { return true; } @@ -153,13 +157,13 @@ public static boolean contains(String source, String[] targets) { *

contains.

* * @param sources an array of {@link java.lang.String} objects. - * @param target a {@link java.lang.String} object. + * @param target a {@link java.lang.String} object. * @return a boolean. */ - public static boolean contains(String[] sources, String target) { + public static boolean contains(String[] sources, String target) { if (null != sources && null != target) { for (var source : sources) { - if(contains(source, target)) + if (contains(source, target)) return true; } } @@ -173,10 +177,10 @@ public static boolean contains(String[] sources, String target) { * @param targets an array of {@link java.lang.String} objects. * @return a boolean. */ - public static boolean contains(String[] sources, String[] targets) { + public static boolean contains(String[] sources, String[] targets) { if (null != sources && null != targets) { for (var source : sources) { - if(contains(source, targets)) + if (contains(source, targets)) return true; } } @@ -189,20 +193,20 @@ public static boolean contains(String[] sources, String[] targets) { * @param length a int. * @return a {@link java.lang.String} object. */ - public static String create(int length) { + public static String create(int length) { return create(DEFAULT_PAD_CHAR, length); } /** *

create.

* - * @param c a char. + * @param c a char. * @param length a int. * @return a {@link java.lang.String} object. */ - public static String create(char c, int length) { + public static String create(char c, int length) { StringBuilder sb = new StringBuilder(length); - for(var index = 0; index < length; index++) + for (var index = 0; index < length; index++) sb.append(c); return sb.toString(); } @@ -210,13 +214,13 @@ public static String create(char c, int length) { /** *

create.

* - * @param s a {@link java.lang.String} object. + * @param s a {@link java.lang.String} object. * @param length a int. * @return a {@link java.lang.String} object. */ - public static String create(String s, int length) { + public static String create(String s, int length) { StringBuilder sb = new StringBuilder(length * s.length()); - for(var index = 0; index < length; index++) + for (var index = 0; index < length; index++) sb.append(s); return sb.toString(); } @@ -224,47 +228,47 @@ public static String create(String s, int length) { /** *

repeat.

* - * @param c a char. + * @param c a char. * @param length a int. * @return a {@link java.lang.String} object. */ - public static String repeat(char c, int length) { + public static String repeat(char c, int length) { return create(c, length); } /** *

repeat.

* - * @param s a {@link java.lang.String} object. + * @param s a {@link java.lang.String} object. * @param length a int. * @return a {@link java.lang.String} object. */ - public static String repeat(String s, int length) { + public static String repeat(String s, int length) { return create(s, length); } /** *

padLeft.

* - * @param data a {@link java.lang.String} object. + * @param data a {@link java.lang.String} object. * @param length a int. * @return a {@link java.lang.String} object. */ - public static String padLeft(String data, int length) { + public static String padLeft(String data, int length) { return padLeft(data, DEFAULT_PAD_CHAR, length); } /** *

padLeft.

* - * @param data a {@link java.lang.String} object. - * @param pad a char. + * @param data a {@link java.lang.String} object. + * @param pad a char. * @param length a int. * @return a {@link java.lang.String} object. */ - public static String padLeft(String data, char pad, int length) { + public static String padLeft(String data, char pad, int length) { var sb = new StringBuilder(data.length() + length); - for(var index = 0; index < length; index++) + for (var index = 0; index < length; index++) sb.append(pad); sb.append(data); return sb.toString(); @@ -273,14 +277,14 @@ public static String padLeft(String data, char pad, int length) { /** *

padLeft.

* - * @param data a {@link java.lang.String} object. - * @param pad a {@link java.lang.String} object. + * @param data a {@link java.lang.String} object. + * @param pad a {@link java.lang.String} object. * @param length a int. * @return a {@link java.lang.String} object. */ - public static String padLeft(String data, String pad, int length) { + public static String padLeft(String data, String pad, int length) { var sb = new StringBuilder(data.length() + (length * pad.length())); - for(var index = 0; index < length; index++) + for (var index = 0; index < length; index++) sb.append(pad); sb.append(data); return sb.toString(); @@ -289,26 +293,26 @@ public static String padLeft(String data, String pad, int length) { /** *

padRight.

* - * @param data a {@link java.lang.String} object. + * @param data a {@link java.lang.String} object. * @param length a int. * @return a {@link java.lang.String} object. */ - public static String padRight(String data, int length) { + public static String padRight(String data, int length) { return padRight(data, DEFAULT_PAD_CHAR, length); } /** *

padRight.

* - * @param data a {@link java.lang.String} object. - * @param pad a char. + * @param data a {@link java.lang.String} object. + * @param pad a char. * @param length a int. * @return a {@link java.lang.String} object. */ - public static String padRight(String data, char pad, int length) { + public static String padRight(String data, char pad, int length) { var sb = new StringBuilder(data.length() + length); sb.append(data); - for(var index = 0; index < length; index++) + for (var index = 0; index < length; index++) sb.append(pad); return sb.toString(); } @@ -316,15 +320,15 @@ public static String padRight(String data, char pad, int length) { /** *

padRight.

* - * @param data a {@link java.lang.String} object. - * @param pad a {@link java.lang.String} object. + * @param data a {@link java.lang.String} object. + * @param pad a {@link java.lang.String} object. * @param length a int. * @return a {@link java.lang.String} object. */ - public static String padRight(String data, String pad, int length) { + public static String padRight(String data, String pad, int length) { var sb = new StringBuilder(data.length() + (length * pad.length())); sb.append(data); - for(var index = 0; index < length; index++) + for (var index = 0; index < length; index++) sb.append(pad); return sb.toString(); } @@ -332,42 +336,42 @@ public static String padRight(String data, String pad, int length) { /** *

pad.

* - * @param data a {@link java.lang.String} object. + * @param data a {@link java.lang.String} object. * @param length a int. * @return a {@link java.lang.String} object. */ - public static String pad(String data, int length) { + public static String pad(String data, int length) { return pad(data, DEFAULT_PAD_CHAR, length); } /** *

pad.

* - * @param data a {@link java.lang.String} object. - * @param pad a char. + * @param data a {@link java.lang.String} object. + * @param pad a char. * @param length a int. * @return a {@link java.lang.String} object. */ - public static String pad(String data, char pad, int length) { + public static String pad(String data, char pad, int length) { return create(pad, length) + data + create(pad, length); } /** *

pad.

* - * @param data a {@link java.lang.String} object. - * @param pad a {@link java.lang.String} object. + * @param data a {@link java.lang.String} object. + * @param pad a {@link java.lang.String} object. * @param length a int. * @return a {@link java.lang.String} object. */ - public static String pad(String data, String pad, int length) { + public static String pad(String data, String pad, int length) { return create(pad, length) + data + create(pad, length); } /** *

padCenter.

* - * @param data a {@link java.lang.String} object. + * @param data a {@link java.lang.String} object. * @param length a int. * @return a {@link java.lang.String} object. */ @@ -378,13 +382,13 @@ public static String padCenter(String data, int length) { /** *

padCenter.

* - * @param data a {@link java.lang.String} object. - * @param pad a char. + * @param data a {@link java.lang.String} object. + * @param pad a char. * @param length a int. * @return a {@link java.lang.String} object. */ public static String padCenter(String data, char pad, int length) { - if(data.length() < length) { + if (data.length() < length) { int needed = length - data.length(); int padNeeded = needed / 2; StringBuilder result = new StringBuilder(); @@ -404,7 +408,7 @@ public static String padCenter(String data, char pad, int length) { * @param data a {@link java.lang.String} object. * @return a {@link java.lang.String} object. */ - public static String trimLeft(String data) { + public static String trimLeft(String data) { return trimLeft(data, DEFAULT_PAD_CHAR); } @@ -415,9 +419,9 @@ public static String trimLeft(String data) { * @param trim a char. * @return a {@link java.lang.String} object. */ - public static String trimLeft(String data, char trim) { - for(var index = 0; index < data.length(); index++) - if(!(data.charAt(index) == trim)) + public static String trimLeft(String data, char trim) { + for (var index = 0; index < data.length(); index++) + if (!(data.charAt(index) == trim)) return data.substring(index); return EMPTY; } @@ -428,7 +432,7 @@ public static String trimLeft(String data, char trim) { * @param data a {@link java.lang.String} object. * @return a {@link java.lang.String} object. */ - public static String trimRight(String data) { + public static String trimRight(String data) { return trimRight(data, DEFAULT_PAD_CHAR); } @@ -439,10 +443,10 @@ public static String trimRight(String data) { * @param trim a char. * @return a {@link java.lang.String} object. */ - public static String trimRight(String data, char trim) { + public static String trimRight(String data, char trim) { int count = 0; - for(var index = data.length(); index > 0; index--) - if(data.charAt(index-1) == trim) + for (var index = data.length(); index > 0; index--) + if (data.charAt(index - 1) == trim) count++; else return data.substring(0, data.length() - count); @@ -455,7 +459,7 @@ public static String trimRight(String data, char trim) { * @param data a {@link java.lang.String} object. * @return a {@link java.lang.String} object. */ - public static String trim(String data) { + public static String trim(String data) { return trim(data, DEFAULT_PAD_CHAR); } @@ -466,7 +470,7 @@ public static String trim(String data) { * @param trim a char. * @return a {@link java.lang.String} object. */ - public static String trim(String data, char trim) { + public static String trim(String data, char trim) { var result = trimLeft(data, trim); return trimRight(result, trim); } @@ -474,14 +478,14 @@ public static String trim(String data, char trim) { /** *

center.

* - * @param text a {@link java.lang.String} object. + * @param text a {@link java.lang.String} object. * @param length a int. * @return a {@link java.lang.String} object. */ - public static String center(String text, int length){ - var out = String.format("%"+length+"s%s%"+length+"s", "",text,""); - var mid = (out.length()/2); - var start = mid - (length/2); + public static String center(String text, int length) { + var out = String.format("%" + length + "s%s%" + length + "s", "", text, ""); + var mid = (out.length() / 2); + var start = mid - (length / 2); var end = start + length; return out.substring((int) start, (int) end); } @@ -492,9 +496,9 @@ public static String center(String text, int length){ * @param data a {@link java.lang.String} object. * @return a {@link java.lang.String} object. */ - public static String concat(String ... data) { + public static String concat(String... data) { var sb = new StringBuilder(); - for(var d : data){ + for (var d : data) { sb.append(d); } return sb.toString(); @@ -504,9 +508,9 @@ public static String concat(String ... data) { *

appendHexString.

* * @param builder a {@link java.lang.StringBuilder} object. - * @param byt a byte. + * @param byt a byte. */ - public static void appendHexString(StringBuilder builder, byte byt){ + public static void appendHexString(StringBuilder builder, byte byt) { builder.append(String.format("%02X", byt)); } @@ -516,7 +520,7 @@ public static void appendHexString(StringBuilder builder, byte byt){ * @param byt a byte. * @return a {@link java.lang.String} object. */ - public static String toHexString(byte byt){ + public static String toHexString(byte byt) { return String.format("%02X", byt); } @@ -524,10 +528,10 @@ public static String toHexString(byte byt){ *

appendHexString.

* * @param builder a {@link java.lang.StringBuilder} object. - * @param byt a int. + * @param byt a int. */ - public static void appendHexString(StringBuilder builder, int byt){ - builder.append(String.format("%02X", (byte)byt)); + public static void appendHexString(StringBuilder builder, int byt) { + builder.append(String.format("%02X", (byte) byt)); } /** @@ -536,17 +540,17 @@ public static void appendHexString(StringBuilder builder, int byt){ * @param byt a int. * @return a {@link java.lang.String} object. */ - public static String toHexString(int byt){ - return String.format("%02X", (byte)byt); + public static String toHexString(int byt) { + return String.format("%02X", (byte) byt); } /** *

appendHexString.

* * @param builder a {@link java.lang.StringBuilder} object. - * @param bytes an array of {@link byte} objects. + * @param bytes an array of byte values. */ - public static void appendHexString(StringBuilder builder, byte[] bytes){ + public static void appendHexString(StringBuilder builder, byte[] bytes) { for (byte b : bytes) { builder.append(String.format("%02X ", b)); } @@ -558,7 +562,7 @@ public static void appendHexString(StringBuilder builder, byte[] bytes){ * @param data a {@link java.lang.CharSequence} object. * @return a {@link java.lang.String} object. */ - public static String toHexString(CharSequence data){ + public static String toHexString(CharSequence data) { StringBuilder sb = new StringBuilder(); appendHexString(sb, data); return sb.toString().trim(); @@ -568,20 +572,20 @@ public static String toHexString(CharSequence data){ *

appendHexString.

* * @param builder a {@link java.lang.StringBuilder} object. - * @param data a {@link java.lang.CharSequence} object. + * @param data a {@link java.lang.CharSequence} object. */ - public static void appendHexString(StringBuilder builder, CharSequence data){ + public static void appendHexString(StringBuilder builder, CharSequence data) { appendHexString(builder, data.toString().getBytes(StandardCharsets.US_ASCII)); } /** *

toHexString.

* - * @param data a {@link java.lang.CharSequence} object. + * @param data a {@link java.lang.CharSequence} object. * @param charset character set used to decode string to bytes * @return a {@link java.lang.String} object. */ - public static String toHexString(CharSequence data, Charset charset){ + public static String toHexString(CharSequence data, Charset charset) { StringBuilder sb = new StringBuilder(); appendHexString(sb, data, charset); return sb.toString().trim(); @@ -591,20 +595,20 @@ public static String toHexString(CharSequence data, Charset charset){ *

appendHexString.

* * @param builder a {@link java.lang.StringBuilder} object. - * @param data a {@link java.lang.CharSequence} object. + * @param data a {@link java.lang.CharSequence} object. * @param charset character set used to decode string to bytes */ - public static void appendHexString(StringBuilder builder, CharSequence data, Charset charset){ + public static void appendHexString(StringBuilder builder, CharSequence data, Charset charset) { appendHexString(builder, data.toString().getBytes(charset)); } /** *

toHexString.

* - * @param bytes an array of {@link byte} objects. + * @param bytes an array of byte values. * @return a {@link java.lang.String} object. */ - public static String toHexString(byte[] bytes){ + public static String toHexString(byte[] bytes) { StringBuilder sb = new StringBuilder(); appendHexString(sb, bytes); return sb.toString().trim(); @@ -614,9 +618,9 @@ public static String toHexString(byte[] bytes){ *

appendHexString.

* * @param builder a {@link java.lang.StringBuilder} object. - * @param buffer a {@link java.nio.ByteBuffer} object. + * @param buffer a {@link java.nio.ByteBuffer} object. */ - public static void appendHexString(StringBuilder builder, ByteBuffer buffer){ + public static void appendHexString(StringBuilder builder, ByteBuffer buffer) { appendHexString(builder, buffer.array()); } @@ -626,7 +630,7 @@ public static void appendHexString(StringBuilder builder, ByteBuffer buffer){ * @param buffer a {@link java.nio.ByteBuffer} object. * @return a {@link java.lang.String} object. */ - public static String toHexString(ByteBuffer buffer){ + public static String toHexString(ByteBuffer buffer) { StringBuilder sb = new StringBuilder(); appendHexString(sb, buffer); return sb.toString().trim(); @@ -636,23 +640,23 @@ public static String toHexString(ByteBuffer buffer){ *

appendHexString.

* * @param builder a {@link java.lang.StringBuilder} object. - * @param bytes an array of {@link byte} objects. - * @param offset a int. - * @param length a int. + * @param bytes an array of byte values. + * @param offset a int. + * @param length a int. */ - public static void appendHexString(StringBuilder builder, byte[] bytes, int offset, int length){ - appendHexString(builder, Arrays.copyOfRange(bytes, offset, offset+length)); + public static void appendHexString(StringBuilder builder, byte[] bytes, int offset, int length) { + appendHexString(builder, Arrays.copyOfRange(bytes, offset, offset + length)); } /** *

toHexString.

* - * @param bytes an array of {@link byte} objects. + * @param bytes an array of byte values. * @param offset a int. * @param length a int. * @return a {@link java.lang.String} object. */ - public static String toHexString(byte[] bytes, int offset, int length){ + public static String toHexString(byte[] bytes, int offset, int length) { StringBuilder sb = new StringBuilder(); appendHexString(sb, bytes, offset, length); return sb.toString().trim(); @@ -662,11 +666,11 @@ public static String toHexString(byte[] bytes, int offset, int length){ *

appendHexString.

* * @param builder a {@link java.lang.StringBuilder} object. - * @param buffer a {@link java.nio.ByteBuffer} object. - * @param offset a int. - * @param length a int. + * @param buffer a {@link java.nio.ByteBuffer} object. + * @param offset a int. + * @param length a int. */ - public static void appendHexString(StringBuilder builder, ByteBuffer buffer, int offset, int length){ + public static void appendHexString(StringBuilder builder, ByteBuffer buffer, int offset, int length) { appendHexString(builder, buffer.array(), offset, length); } @@ -678,7 +682,7 @@ public static void appendHexString(StringBuilder builder, ByteBuffer buffer, int * @param length a int. * @return a {@link java.lang.String} object. */ - public static String toHexString(ByteBuffer buffer, int offset, int length){ + public static String toHexString(ByteBuffer buffer, int offset, int length) { StringBuilder sb = new StringBuilder(); appendHexString(sb, buffer, offset, length); return sb.toString().trim(); @@ -694,7 +698,7 @@ public static boolean isNumeric(String str) { try { Double.parseDouble(str); return true; - } catch(NumberFormatException e){ + } catch (NumberFormatException e) { return false; } } @@ -702,7 +706,7 @@ public static boolean isNumeric(String str) { /** *

parseInteger.

* - * @param str a {@link java.lang.String} object. + * @param str a {@link java.lang.String} object. * @param defaultValue a {@link java.lang.Integer} object. * @return a int. */ @@ -710,7 +714,7 @@ public static int parseInteger(String str, Integer defaultValue) { try { Integer v = Integer.parseInt(str); return v.intValue(); - } catch(NumberFormatException e){ + } catch (NumberFormatException e) { return defaultValue; } } @@ -718,7 +722,7 @@ public static int parseInteger(String str, Integer defaultValue) { /** *

parseLong.

* - * @param str a {@link java.lang.String} object. + * @param str a {@link java.lang.String} object. * @param defaultValue a {@link java.lang.Long} object. * @return a int. */ @@ -726,7 +730,7 @@ public static long parseLong(String str, Long defaultValue) { try { Long v = Long.parseLong(str); return v.intValue(); - } catch(NumberFormatException e){ + } catch (NumberFormatException e) { return defaultValue; } } diff --git a/pom.xml b/pom.xml index 616f5133..d7b28a58 100644 --- a/pom.xml +++ b/pom.xml @@ -1,20 +1,20 @@ - 4.0.0 - com.pi4j - pi4j-parent - 3.0.0-SNAPSHOT - Pi4J :: Parent POM - Parent Maven POM for the Pi4J Project - https://pi4j.com - 2012 - pom - - - - Pi4J - https://pi4j.com - + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + 4.0.0 + com.pi4j + pi4j-parent + 3.0.0-SNAPSHOT + Pi4J :: Parent POM + Parent Maven POM for the Pi4J Project + https://pi4j.com + 2012 + pom + + + + Pi4J + https://pi4j.com + @@ -109,18 +109,18 @@ - - - scm:git:ssh://git@github.com/Pi4J/pi4j.git - scm:git:ssh://git@github.com/Pi4J/pi4j.git - https://github.com/Pi4J/pi4j.git - + + + scm:git:ssh://git@github.com/Pi4J/pi4j.git + scm:git:ssh://git@github.com/Pi4J/pi4j.git + https://github.com/Pi4J/pi4j.git + - - - https://github.com/Pi4J/pi4j/issues - github - + + + https://github.com/Pi4J/pi4j/issues + github + @@ -707,7 +707,7 @@ - + org.apache.maven.plugins @@ -724,20 +724,23 @@ [3.9,) + + ${java.version} + - - - org.apache.maven.plugins - maven-scm-plugin - - install - - + + + org.apache.maven.plugins + maven-scm-plugin + + install + + @@ -773,25 +776,7 @@ false - - org.apache.maven.plugins - maven-enforcer-plugin - - - enforce-java - - enforce - - - - - ${java.version} - - - - - - + org.apache.maven.plugins maven-checkstyle-plugin From bbe585985addc4d00d1298ca079a5bfbf4949a5a Mon Sep 17 00:00:00 2001 From: Frank Delporte Date: Tue, 28 Jan 2025 14:43:26 +0100 Subject: [PATCH 12/13] Add JNA dependency --- plugins/pi4j-plugin-linuxfs/pom.xml | 7 +++++++ pom.xml | 1 + 2 files changed, 8 insertions(+) diff --git a/plugins/pi4j-plugin-linuxfs/pom.xml b/plugins/pi4j-plugin-linuxfs/pom.xml index 5ab9f610..58376b52 100644 --- a/plugins/pi4j-plugin-linuxfs/pom.xml +++ b/plugins/pi4j-plugin-linuxfs/pom.xml @@ -15,6 +15,7 @@ Pi4J :: PLUGIN :: LinuxFS I/O Providers Pi4J Library Plugin for Linux File System I/O Providers jar + com.jcraft @@ -37,6 +38,12 @@ ${slf4j.version} test + + + net.java.dev.jna + jna + ${jna.version} + diff --git a/pom.xml b/pom.xml index d7b28a58..133677e0 100644 --- a/pom.xml +++ b/pom.xml @@ -261,6 +261,7 @@ --> 20020829 1.10.15 + 5.16.0 0.1.55 5.11.3 2.0.12 From 83771c2dd221230f31f05a73c08d4683d019488d Mon Sep 17 00:00:00 2001 From: Frank Delporte Date: Tue, 28 Jan 2025 15:21:27 +0100 Subject: [PATCH 13/13] Test commit (signed) --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 133677e0..4e517b56 100644 --- a/pom.xml +++ b/pom.xml @@ -255,7 +255,7 @@