GITHUB PROJECT: https://github.com/Pi4J/pi4j-example-minimal
The Pi4J V.2 project itself uses Maven and most example projects also use this build tool. But if you prefer to use Gradle, you can start with a copy of the “Minimal example application” which includes all the required files to build with Gradle.
Use Gradle version 6.6 (or later) and Java 11 OpenJDK (or later). The Gradle wrapper is used as described on docs.gradle.org. The Gradle configuration file build.gradle-file is included in the sources.
On Linux:
./gradlew build
On Windows:
gradlew.bat build
Once the build is complete and was successful, you can find the compiled build
(Gradle) folder. Specifically
all dependency modules (JARs) and a simple run.sh
bash script will be located in the build/distribution
(Gradle) folder.
These are all the required files needed to distribute (copy) to your Raspberry Pi to run this project. If you are using
the native bindings running locally on the Raspberry Pi, then you make have to run the program using sudo
to gain the necessary access permissions to the hardware I/O.
This is the list of files created by the build process of this example application:
Make the run script executable and start it like this:
$ chmod +x run.sh
$ sudo ./run.sh