-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from Pi4J/feature/download-openjfx
Added downloading of openjfx on mvn package
- Loading branch information
Showing
9 changed files
with
217 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
/.idea/ | ||
/target/ | ||
/*.iml | ||
download/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,29 +26,47 @@ dependency comes pre-installed on recent Raspbian images. However, you can also | |
download and install it yourself using the instructions found | ||
[here](http://abyz.me.uk/rpi/pigpio/download.html). | ||
|
||
As this application has a JavaFX user interface, the project requires the OpenJFX runtime. When the package is build, | ||
then the runtime is downloaded and added to the distribution directory. | ||
|
||
## BUILD DEPENDENCIES & INSTRUCTIONS | ||
|
||
This project can be built with [Apache Maven](https://maven.apache.org/) 3.6 | ||
(or later) and Java 11 OpenJDK (or later). These prerequisites must be installed | ||
prior to building this project. The following command can be used to download | ||
all project dependencies and compile the Java module. You can build this | ||
project directly on a Raspberry Pi with Java 11+. | ||
This project can be built with [Apache Maven](https://maven.apache.org/) 3.6 (or later) and Java 17 OpenJDK (or later). | ||
These prerequisites must be installed prior to building this project. The following command can be used to download all | ||
project dependencies and compile the Java module. You can build this project directly on a Raspberry Pi with Java 17+. | ||
|
||
``` | ||
```bash | ||
mvn clean package | ||
``` | ||
|
||
### Compiled application to run on the Raspberry Pi | ||
|
||
Once the build is complete and was successful, you can find the compiled | ||
artifacts in the `target` folder. Specifically | ||
all dependency modules (JARs) and a simple `run.sh` bash script will be located in the | ||
`target/distribution`. | ||
Once the build is complete and was successful, you can find the compiled artifacts in the `target` folder. Specifically | ||
all dependency modules (JARs) and a simple `run.sh` bash script will be located in the `target/distribution` folder. | ||
This folder contains all the required files needed to distribute (copy) to your Raspberry Pi to run this project. | ||
|
||
For your convenience, this `distribution` folder is zipped up, and is also located in the `target/` folder. Copy this | ||
file to your Raspberry Pi, for example with the following command: | ||
|
||
```bash | ||
rsync target/pi4j-example-fxgl-0.0.1.zip [email protected]:. | ||
``` | ||
|
||
Then on the Raspberry Pi unzip the file with the following command: | ||
|
||
```bash | ||
unzip pi4j-example-fxgl-0.0.1.zip | ||
``` | ||
|
||
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. | ||
Now the example can be started with the following command: | ||
|
||
```bash | ||
cd pi4j-example-fxgl-0.0.1/ | ||
./run.sh | ||
``` | ||
|
||
*Note:* If you are using the native bindings running locally on the Raspberry Pi, then you may 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: | ||
|
||
|
@@ -59,15 +77,10 @@ This is the list of files created by the build process of this example applicati | |
* pi4j-plugin-raspberrypi | ||
* slf4j-api | ||
* slf4j-simple | ||
* javafx-* | ||
* and additional dependencies required for JavaFX and FXGL | ||
* run.sh --> this is the actual start file which will run pi4j-example-javafx | ||
|
||
Make the run script executable and start it like this: | ||
|
||
``` | ||
chmod +x run.sh | ||
sudo ./run.sh | ||
``` | ||
|
||
## LICENSE | ||
|
||
Pi4J Version 2.0 and later is licensed under the Apache License, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,16 @@ | ||
#!/usr/bin/env bash | ||
/sbin/init 3 | ||
export ENABLE_GLUON_COMMERCIAL_EXTENSIONS=true | ||
declare SCRIPT_DIR="$(cd "${0%/*}" ; pwd)" | ||
java \ | ||
-Degl.displayid=/dev/dri/card0 \ | ||
-Dmonocle.egl.lib=/opt/javafx-sdk-17/lib/libgluon_drm-1.1.3.so \ | ||
-Djava.library.path=/opt/javafx-sdk-17/lib \ | ||
-Djava.library.path="${SCRIPT_DIR}/openjfx/lib" \ | ||
-Dmonocle.platform.traceConfig=false \ | ||
-Dprism.verbose=false \ | ||
-Djavafx.verbose=false \ | ||
-Dmonocle.platform=EGL \ | ||
--module-path .:/opt/javafx-sdk-17/lib \ | ||
--module-path ".:${SCRIPT_DIR}/openjfx/lib" \ | ||
--add-modules javafx.controls \ | ||
--module com.pi4j.example/com.pi4j.example.JavaFxExample $@ | ||
/sbin/init 5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,11 @@ | ||
#!/usr/bin/env bash | ||
declare SCRIPT_DIR="$(cd "${0%/*}" ; pwd)" | ||
java \ | ||
-Dglass.platform=gtk \ | ||
-Djava.library.path=/opt/javafx-sdk-17/lib \ | ||
-Djava.library.path="${SCRIPT_DIR}/openjfx/lib" \ | ||
-Dmonocle.platform.traceConfig=false \ | ||
-Dprism.verbose=false \ | ||
-Djavafx.verbose=false \ | ||
--module-path .:/opt/javafx-sdk-17/lib \ | ||
--module-path ".:${SCRIPT_DIR}/openjfx/lib" \ | ||
--add-modules javafx.controls \ | ||
--module com.pi4j.example/com.pi4j.example.JavaFxExample $@ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
@echo off | ||
|
||
REM Variables | ||
set URL="https://download2.gluonhq.com/openjfx/22/openjfx-22_linux-aarch64_bin-sdk.zip" | ||
set SHA_URL="https://download2.gluonhq.com/openjfx/22/openjfx-22_linux-aarch64_bin-sdk.zip.sha256" | ||
set TARGET_DIR="target\openjfx" | ||
set SUBDIR="extracted_files" | ||
set TEMP_DIR="%TEMP%\openjfx_temp" | ||
|
||
REM Function to calculate SHA256 sum | ||
:calculate_sha256 | ||
certutil -hashfile "%1" SHA256 | findstr /R "[0-9a-fA-F]*" | ||
|
||
REM Create target directory | ||
rmdir /s /q "%TARGET_DIR%\%SUBDIR%" | ||
mkdir "%TARGET_DIR%\%SUBDIR%" 2>nul | ||
|
||
REM Download the file if not already downloaded | ||
if not exist "%TARGET_DIR%\%~n0" ( | ||
echo Downloading %URL%... | ||
bitsadmin.exe /transfer myDownloadJob /download /priority normal %URL% "%TARGET_DIR%\%~n0" | ||
) else ( | ||
echo File already exists. Skipping download. | ||
) | ||
|
||
REM Download the SHA256 file if not already downloaded | ||
if not exist "%TARGET_DIR%\%~n1" ( | ||
echo Downloading SHA256 checksum file... | ||
bitsadmin.exe /transfer mySHA256Job /download /priority normal %SHA_URL% "%TARGET_DIR%\%~n1" | ||
) | ||
|
||
REM Verify the SHA256 sum | ||
echo Verifying SHA256 sum... | ||
for /f "tokens=*" %%a in ('type "%TARGET_DIR%\%~n1"') do set "sha256sum=%%a" | ||
for /f "tokens=*" %%b in ('call :calculate_sha256 "%TARGET_DIR%\%~n0"') do ( | ||
if "%%b"=="%sha256sum%" ( | ||
echo SHA256 sum verified successfully. | ||
) else ( | ||
echo SHA256 sum verification failed. | ||
rmdir /s /q "%TEMP_DIR%" | ||
exit /b 1 | ||
) | ||
) | ||
|
||
REM Extract the zip file | ||
echo Extracting the zip file... | ||
powershell -noprofile -command "& {Add-Type -A 'System.IO.Compression.FileSystem'; [System.IO.Compression.ZipFile]::ExtractToDirectory('%TARGET_DIR%\%~n0', '%TARGET_DIR%\%SUBDIR%')}" | ||
|
||
rem Find the folder and rename it | ||
for /f "delims=" %%D in ('dir /b /ad "%TARGET_DIR%\%SUBDIR%"') do ( | ||
set "folder=%%~fD" | ||
goto :rename | ||
) | ||
:rename | ||
if defined folder ( | ||
ren "%folder%" new_name | ||
echo Folder renamed successfully. | ||
) else ( | ||
echo Folder not found. | ||
) | ||
|
||
echo Extraction completed. Files are located in: %TARGET_DIR%\%SUBDIR% |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
#!/bin/bash | ||
|
||
# Variables | ||
URL="https://download2.gluonhq.com/openjfx/22/openjfx-22_linux-aarch64_bin-sdk.zip" | ||
SHA_URL="https://download2.gluonhq.com/openjfx/22/openjfx-22_linux-aarch64_bin-sdk.zip.sha256" | ||
TARGET_DIR="download/openjfx" | ||
SUBDIR="extracted_files" | ||
TEMP_DIR=$(mktemp -d) | ||
|
||
# Function to calculate SHA256 sum | ||
calculate_sha256() { | ||
sha256sum "$1" | awk '{print $1}' | ||
} | ||
|
||
# Create target directory if it doesn't exist | ||
rm -rf "${TARGET_DIR:?}/$SUBDIR" | ||
mkdir -p "$TARGET_DIR/$SUBDIR" | ||
|
||
# Download the file if not already downloaded | ||
if [ ! -f "$TARGET_DIR/$(basename "$URL")" ]; then | ||
echo "Downloading $URL..." | ||
wget -q --show-progress -O "$TARGET_DIR/$(basename "$URL")" "$URL" | ||
else | ||
echo "File already exists. Skipping download." | ||
fi | ||
|
||
# Download the SHA256 file if not already downloaded | ||
if [ ! -f "$TARGET_DIR/$(basename "$SHA_URL")" ]; then | ||
echo "Downloading SHA256 checksum file..." | ||
wget -q -O "$TARGET_DIR/$(basename "$SHA_URL")" "$SHA_URL" | ||
fi | ||
|
||
# Verify the SHA256 sum | ||
echo "Verifying SHA256 sum..." | ||
if [ "$(calculate_sha256 "$TARGET_DIR/$(basename "$URL")")" == "$(cut -d ' ' -f1 "$TARGET_DIR/$(basename "$SHA_URL")")" ]; then | ||
echo "SHA256 sum verified successfully." | ||
else | ||
echo "SHA256 sum verification failed." | ||
rm -rf "$TEMP_DIR" | ||
exit 1 | ||
fi | ||
|
||
# Extract the zip file | ||
echo "Extracting the zip file..." | ||
unzip -q "$TARGET_DIR/$(basename "$URL")" -d "$TARGET_DIR/$SUBDIR" | ||
|
||
# Find the folder and rename it | ||
folder=$(find "$TARGET_DIR/$SUBDIR" -maxdepth 1 -mindepth 1 -type d -exec echo {} \;) | ||
if [ -n "$folder" ]; then | ||
mv "$folder" "$TARGET_DIR/$SUBDIR/openjfx" | ||
fi | ||
|
||
echo "Extraction completed. Files are located in: $TARGET_DIR/$SUBDIR" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3 http://maven.apache.org/xsd/assembly-1.1.3.xsd"> | ||
<id>bin</id> | ||
<formats> | ||
<format>zip</format> | ||
</formats> | ||
|
||
<fileSets> | ||
<fileSet> | ||
<directory>${project.build.directory}/distribution</directory> | ||
<outputDirectory/> | ||
<filtered>false</filtered> | ||
</fileSet> | ||
</fileSets> | ||
|
||
</assembly> |