Skip to content

Feature: Use argument files #70

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Nov 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 10 additions & 29 deletions .github/workflows/build-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,36 +77,17 @@ jobs:
cp LICENSE.txt target
cp target/cryptomator-*.jar target/mods
- name: Run jlink
run: >
"${JAVA_HOME}/bin/jlink"
--verbose
--output target/runtime
--module-path "${JAVA_HOME}/jmods"
--add-modules java.base,java.compiler,java.naming,java.xml
--strip-native-commands
--no-header-files
--no-man-pages
--strip-debug
--compress zip-6
run: |
envsubst < dist/jlink.args > target/jlink.args
"${JAVA_HOME}/bin/jlink" '@./target/jlink.args'
- name: Run jpackage
run: >
"${JAVA_HOME}/bin/jpackage"
--verbose
--type app-image
--runtime-image target/runtime
--input target/libs
--module-path target/mods
--module org.cryptomator.cli/org.cryptomator.cli.CryptomatorCli
--dest target
--name cryptomator-cli
--vendor "Skymatic GmbH"
--copyright "(C) 2016 - 2024 Skymatic GmbH"
--app-version "${{ needs.prepare.outputs.semVerNum }}"
--java-options "-Dorg.cryptomator.cli.version=${{ needs.prepare.outputs.semVerStr }}"
--java-options "--enable-native-access=${{ matrix.native-access-lib }}"
--java-options "-Xss5m"
--java-options "-Xmx256m"
--java-options "-Dfile.encoding=\"utf-8\""
run: |
envsubst < dist/jpackage.args > target/jpackage.args
"${JAVA_HOME}/bin/jpackage" '@./target/jpackage.args'
env:
JP_APP_VERSION: ${{ needs.prepare.outputs.semVerNum }}
APP_VERSION: ${{ needs.prepare.outputs.semVerStr }}
NATIVE_ACCESS_PACKAGE: ${{ matrix.native-access-lib }}
- uses: actions/upload-artifact@v4
with:
name: cryptomator-cli-linux-${{ matrix.architecture }}
Expand Down
39 changes: 10 additions & 29 deletions .github/workflows/build-mac.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,36 +75,17 @@ jobs:
cp LICENSE.txt target
cp target/cryptomator-*.jar target/mods
- name: Run jlink
run: >
"${JAVA_HOME}/bin/jlink"
--verbose
--output target/runtime
--module-path "${JAVA_HOME}/jmods"
--add-modules java.base,java.compiler,java.naming,java.xml
--strip-native-commands
--no-header-files
--no-man-pages
--strip-debug
--compress zip-6
run: |
envsubst < dist/jlink.args > target/jlink.args
"${JAVA_HOME}/bin/jlink" '@./target/jlink.args'
- name: Run jpackage
run: >
"${JAVA_HOME}/bin/jpackage"
--verbose
--type app-image
--runtime-image target/runtime
--input target/libs
--module-path target/mods
--module org.cryptomator.cli/org.cryptomator.cli.CryptomatorCli
--dest target
--name cryptomator-cli
--vendor "Skymatic GmbH"
--copyright "(C) 2016 - 2024 Skymatic GmbH"
--app-version "${{ needs.prepare.outputs.semVerNum }}"
--java-options "-Dorg.cryptomator.cli.version=${{ needs.prepare.outputs.semVerStr }}"
--java-options "--enable-native-access=org.cryptomator.jfuse.mac"
--java-options "-Xss5m"
--java-options "-Xmx256m"
--java-options "-Dfile.encoding=\"utf-8\""
run: |
envsubst < dist/jpackage.args > target/jpackage.args
"${JAVA_HOME}/bin/jpackage" '@./target/jpackage.args'
env:
JP_APP_VERSION: ${{ needs.prepare.outputs.semVerNum }}
APP_VERSION: ${{ needs.prepare.outputs.semVerStr }}
NATIVE_ACCESS_PACKAGE: org.cryptomator.jfuse.mac
- uses: actions/upload-artifact@v4
with:
name: cryptomator-cli-mac-${{ matrix.architecture }}
Expand Down
40 changes: 10 additions & 30 deletions .github/workflows/build-win.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,37 +67,17 @@ jobs:
cp LICENSE.txt target
cp target/cryptomator-*.jar target/mods
- name: Run jlink
run: >
"${JAVA_HOME}/bin/jlink"
--verbose
--output target/runtime
--module-path "${JAVA_HOME}/jmods"
--add-modules java.base,java.compiler,java.naming,java.xml
--strip-native-commands
--no-header-files
--no-man-pages
--strip-debug
--compress zip-6
run: |
envsubst < dist/jlink.args > target/jlink.args
"${JAVA_HOME}/bin/jlink" '@./target/jlink.args'
- name: Run jpackage
run: >
"${JAVA_HOME}/bin/jpackage"
--verbose
--type app-image
--runtime-image target/runtime
--input target/libs
--module-path target/mods
--module org.cryptomator.cli/org.cryptomator.cli.CryptomatorCli
--dest target
--name cryptomator-cli
--vendor "Skymatic GmbH"
--copyright "(C) 2016 - 2024 Skymatic GmbH"
--app-version "${{ needs.prepare.outputs.semVerNum }}"
--java-options "-Dorg.cryptomator.cli.version=${{ needs.prepare.outputs.semVerStr }}"
--java-options "--enable-native-access=org.cryptomator.jfuse.win"
--java-options "-Xss5m"
--java-options "-Xmx256m"
--java-options "-Dfile.encoding=\"utf-8\""
--win-console
run: |
envsubst < dist/jpackage.args > target/jpackage.args
"${JAVA_HOME}/bin/jpackage" '@./target/jpackage.args' --win-console
env:
JP_APP_VERSION: ${{ needs.prepare.outputs.semVerNum }}
APP_VERSION: ${{ needs.prepare.outputs.semVerStr }}
NATIVE_ACCESS_PACKAGE: org.cryptomator.jfuse.win
- uses: actions/upload-artifact@v4
with:
name: cryptomator-cli-win-x64
Expand Down
38 changes: 9 additions & 29 deletions build_linux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ set -euxo pipefail

echo "Building cryptomator cli..."

export APP_VERSION='0.1.0-local'

# Check if Maven is installed
if ! command -v mvn &> /dev/null; then
echo "Maven is not installed. Please install Maven to proceed."
Expand All @@ -29,23 +31,15 @@ cp ./LICENSE.txt ./target/
mv ./target/cryptomator-cli-*.jar ./target/mods

echo "Creating JRE with jlink..."
"$JAVA_HOME/bin/jlink" \
--verbose \
--output target/runtime \
--module-path "${JAVA_HOME}/jmods" \
--add-modules java.base,java.compiler,java.naming,java.xml \
--strip-native-commands \
--no-header-files \
--no-man-pages \
--strip-debug \
--compress zip-0
envsubst < dist/jlink.args > target/jlink.args
"$JAVA_HOME/bin/jlink" '@./target/jlink.args'

if [ $? -ne 0 ] || [ ! -d ./target/runtime ]; then
echo "JRE creation with jlink failed."
exit 1
fi

NATIVE_ACCESS_PACKAGE="no.native.access.available"
export NATIVE_ACCESS_PACKAGE="no.native.access.available"
_OS=$(uname -s)
if (echo "$_OS" | grep -q "Linux.*") ; then
_ARCH=$(uname -m)
Expand All @@ -59,25 +53,11 @@ if (echo "$_OS" | grep -q "Linux.*") ; then
fi
fi

export JP_APP_VERSION='99.9.9'
envsubst < dist/jpackage.args > target/jpackage.args

echo "Creating app binary with jpackage..."
"$JAVA_HOME/bin/jpackage" \
--verbose \
--type app-image \
--runtime-image target/runtime \
--input target/libs \
--module-path target/mods \
--module org.cryptomator.cli/org.cryptomator.cli.CryptomatorCli \
--dest target \
--name cryptomator-cli \
--vendor "Skymatic GmbH" \
--copyright "(C) 2016 - 2024 Skymatic GmbH" \
--app-version "0.0.1.0" \
--java-options "-Dorg.cryptomator.cli.version=0.0.1-local" \
--java-options "--enable-preview" \
--java-options "--enable-native-access=${NATIVE_ACCESS_PACKAGE}" \
--java-options "-Xss5m" \
--java-options "-Xmx256m" \
--java-options "-Dfile.encoding=utf-8" \
"$JAVA_HOME/bin/jpackage" '@./target/jpackage.args'

if [ $? -ne 0 ] || [ ! -d ./target/cryptomator-cli ]; then
echo "Binary creation with jpackage failed."
Expand Down
37 changes: 9 additions & 28 deletions build_mac.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

echo "Building cryptomator cli..."

export APP_VERSION='0.1.0-local'

# Check if Maven is installed
if ! command -v mvn &> /dev/null; then
echo "Maven is not installed. Please install Maven to proceed."
Expand All @@ -28,41 +30,20 @@ cp ./LICENSE.txt ./target/
mv ./target/cryptomator-cli-*.jar ./target/mods

echo "Creating JRE with jlink..."
"$JAVA_HOME/bin/jlink" \
--verbose \
--output target/runtime \
--module-path "${JAVA_HOME}/jmods" \
--add-modules java.base,java.compiler,java.naming,java.xml \
--strip-native-commands \
--no-header-files \
--no-man-pages \
--strip-debug \
--compress zip-0
envsubst < dist/jlink.args > target/jlink.args
"$JAVA_HOME/bin/jlink" '@./target/jlink.args'

if [ $? -ne 0 ] || [ ! -d ./target/runtime ]; then
echo "JRE creation with jlink failed."
exit 1
fi

export JP_APP_VERSION='99.9.9'
export NATIVE_ACCESS_PACKAGE="org.cryptomator.jfuse.mac"
envsubst < dist/jpackage.args > target/jpackage.args

echo "Creating app binary with jpackage..."
"$JAVA_HOME/bin/jpackage" \
--verbose \
--type app-image \
--runtime-image target/runtime \
--input target/libs \
--module-path target/mods \
--module org.cryptomator.cli/org.cryptomator.cli.CryptomatorCli \
--dest target \
--name cryptomator-cli \
--vendor "Skymatic GmbH" \
--copyright "(C) 2016 - 2024 Skymatic GmbH" \
--app-version "99.9.9" \
--java-options "-Dorg.cryptomator.cli.version=0.0.1-local" \
--java-options "--enable-preview" \
--java-options "--enable-native-access=org.cryptomator.jfuse.mac" \
--java-options "-Xss5m" \
--java-options "-Xmx256m" \
--java-options "-Dfile.encoding=utf-8" \
"$JAVA_HOME/bin/jpackage" '@./target/jpackage.args'

if [ $? -ne 0 ] || [ ! -d ./target/cryptomator-cli.app ]; then
echo "Binary creation with jpackage failed."
Expand Down
46 changes: 15 additions & 31 deletions build_win.ps1
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
"Building cryptomator cli..."

$appVersion='0.1.0-local'

# Check if maven is installed
$commands = 'mvn'
foreach ($cmd in $commands) {
Expand All @@ -14,7 +16,7 @@ if(-not $env:JAVA_HOME) {
# Check Java version
$minJavaVersion=$(mvn help:evaluate "-Dexpression=jdk.version" -q -DforceStdout)
$javaVersion = $(& "$env:JAVA_HOME\bin\java" --version) -split ' ' | Select-Object -Index 1
if( ($javaVersion -split '.' | Select-Object -First 1) -ne "22") {
if( ($javaVersion.Split('.') | Select-Object -First 1) -ne "22") {
throw "Java version $javaVersion is too old. Minimum required version is $minJavaVersion"
}

Expand All @@ -24,43 +26,25 @@ Copy-Item ./LICENSE.txt -Destination ./target -ErrorAction Stop
Move-Item ./target/cryptomator-cli-*.jar ./target/mods -ErrorAction Stop

Write-Host "Creating JRE with jlink..."
& $env:JAVA_HOME/bin/jlink `
--verbose `
--output target/runtime `
--module-path "${env:JAVA_HOME}/jmods" `
--add-modules java.base,java.compiler,java.naming,java.xml `
--strip-native-commands `
--no-header-files `
--no-man-pages `
--strip-debug `
--compress zip-0
Get-Content -Path './dist/jlink.args' | ForEach-Object { $_.Replace('${JAVA_HOME}', "$env:JAVA_HOME")} | Out-File -FilePath './target/jlink.args'
& $env:JAVA_HOME/bin/jlink `@./target/jlink.args

if ( ($LASTEXITCODE -ne 0) -or (-not (Test-Path ./target/runtime))) {
throw "JRE creation with jLink failed with exit code $LASTEXITCODE."
throw "JRE creation with jLink failed with exit code $LASTEXITCODE."
}

## powershell does not have envsubst
$jpAppVersion='99.9.9'
Get-Content -Path './dist/jpackage.args' | ForEach-Object {
$_.Replace('${APP_VERSION}', $appVersion).
Replace('${JP_APP_VERSION}', $jpAppVersion).
Replace('${NATIVE_ACCESS_PACKAGE}', 'org.cryptomator.jfuse.win')
} | Out-File -FilePath './target/jpackage.args'

# jpackage
# app-version is hard coded, since the script is only for local test builds
Write-Host "Creating app binary with jpackage..."
& $env:JAVA_HOME/bin/jpackage `
--verbose `
--type app-image `
--runtime-image target/runtime `
--input target/libs `
--module-path target/mods `
--module org.cryptomator.cli/org.cryptomator.cli.CryptomatorCli `
--dest target `
--name cryptomator-cli `
--vendor "Skymatic GmbH" `
--copyright "(C) 2016 - 2024 Skymatic GmbH" `
--app-version "0.0.1.0" `
--java-options "-Dorg.cryptomator.cli.version=0.0.1-local" `
--java-options "--enable-preview" `
--java-options "--enable-native-access=org.cryptomator.jfuse.win" `
--java-options "-Xss5m" `
--java-options "-Xmx256m" `
--java-options '-Dfile.encoding="utf-8"' `
--win-console
& $env:JAVA_HOME/bin/jpackage `@./target/jpackage.args --win-console

if ( ($LASTEXITCODE -ne 0) -or (-not (Test-Path ./target/cryptomator-cli))) {
throw "Binary creation with jpackage failed with exit code $LASTEXITCODE."
Expand Down
9 changes: 9 additions & 0 deletions dist/jlink.args
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
--verbose
--module-path "${JAVA_HOME}/jmods"
--output target/runtime
--add-modules java.base,java.compiler,java.naming,java.xml
--strip-native-commands
--no-header-files
--no-man-pages
--strip-debug
--compress zip-6
20 changes: 20 additions & 0 deletions dist/jpackage.args
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Contains three env vars:
# JP_APP_VERSION: The version needed for jpackage. This version _must_ follow the scheme Y.X.X, where Y >= 1 and X >=0
# APP_VERSION: The actual, semantic version displayed in the cli app
# NATIVE_ACCESS_PACKAGE: The java package containing the fuse bindings for the system
--verbose
--type app-image
--runtime-image target/runtime
--input target/libs
--module-path target/mods
--module org.cryptomator.cli/org.cryptomator.cli.CryptomatorCli
--dest target
--name cryptomator-cli
--vendor "Skymatic GmbH"
--copyright "(C) 2016 - 2024 Skymatic GmbH"
--app-version "${JP_APP_VERSION}"
--java-options "-Dorg.cryptomator.cli.version=${APP_VERSION}"
--java-options "--enable-native-access=${NATIVE_ACCESS_PACKAGE}"
--java-options "-Xss5m"
--java-options "-Xmx256m"
--java-options "-Dfile.encoding=\"utf-8\""