Skip to content

Commit be05f6d

Browse files
authored
Feature: Use argument files (#70)
1 parent 2a05bb8 commit be05f6d

File tree

8 files changed

+92
-176
lines changed

8 files changed

+92
-176
lines changed

.github/workflows/build-linux.yml

+10-29
Original file line numberDiff line numberDiff line change
@@ -77,36 +77,17 @@ jobs:
7777
cp LICENSE.txt target
7878
cp target/cryptomator-*.jar target/mods
7979
- name: Run jlink
80-
run: >
81-
"${JAVA_HOME}/bin/jlink"
82-
--verbose
83-
--output target/runtime
84-
--module-path "${JAVA_HOME}/jmods"
85-
--add-modules java.base,java.compiler,java.naming,java.xml
86-
--strip-native-commands
87-
--no-header-files
88-
--no-man-pages
89-
--strip-debug
90-
--compress zip-6
80+
run: |
81+
envsubst < dist/jlink.args > target/jlink.args
82+
"${JAVA_HOME}/bin/jlink" '@./target/jlink.args'
9183
- name: Run jpackage
92-
run: >
93-
"${JAVA_HOME}/bin/jpackage"
94-
--verbose
95-
--type app-image
96-
--runtime-image target/runtime
97-
--input target/libs
98-
--module-path target/mods
99-
--module org.cryptomator.cli/org.cryptomator.cli.CryptomatorCli
100-
--dest target
101-
--name cryptomator-cli
102-
--vendor "Skymatic GmbH"
103-
--copyright "(C) 2016 - 2024 Skymatic GmbH"
104-
--app-version "${{ needs.prepare.outputs.semVerNum }}"
105-
--java-options "-Dorg.cryptomator.cli.version=${{ needs.prepare.outputs.semVerStr }}"
106-
--java-options "--enable-native-access=${{ matrix.native-access-lib }}"
107-
--java-options "-Xss5m"
108-
--java-options "-Xmx256m"
109-
--java-options "-Dfile.encoding=\"utf-8\""
84+
run: |
85+
envsubst < dist/jpackage.args > target/jpackage.args
86+
"${JAVA_HOME}/bin/jpackage" '@./target/jpackage.args'
87+
env:
88+
JP_APP_VERSION: ${{ needs.prepare.outputs.semVerNum }}
89+
APP_VERSION: ${{ needs.prepare.outputs.semVerStr }}
90+
NATIVE_ACCESS_PACKAGE: ${{ matrix.native-access-lib }}
11091
- uses: actions/upload-artifact@v4
11192
with:
11293
name: cryptomator-cli-linux-${{ matrix.architecture }}

.github/workflows/build-mac.yml

+10-29
Original file line numberDiff line numberDiff line change
@@ -75,36 +75,17 @@ jobs:
7575
cp LICENSE.txt target
7676
cp target/cryptomator-*.jar target/mods
7777
- name: Run jlink
78-
run: >
79-
"${JAVA_HOME}/bin/jlink"
80-
--verbose
81-
--output target/runtime
82-
--module-path "${JAVA_HOME}/jmods"
83-
--add-modules java.base,java.compiler,java.naming,java.xml
84-
--strip-native-commands
85-
--no-header-files
86-
--no-man-pages
87-
--strip-debug
88-
--compress zip-6
78+
run: |
79+
envsubst < dist/jlink.args > target/jlink.args
80+
"${JAVA_HOME}/bin/jlink" '@./target/jlink.args'
8981
- name: Run jpackage
90-
run: >
91-
"${JAVA_HOME}/bin/jpackage"
92-
--verbose
93-
--type app-image
94-
--runtime-image target/runtime
95-
--input target/libs
96-
--module-path target/mods
97-
--module org.cryptomator.cli/org.cryptomator.cli.CryptomatorCli
98-
--dest target
99-
--name cryptomator-cli
100-
--vendor "Skymatic GmbH"
101-
--copyright "(C) 2016 - 2024 Skymatic GmbH"
102-
--app-version "${{ needs.prepare.outputs.semVerNum }}"
103-
--java-options "-Dorg.cryptomator.cli.version=${{ needs.prepare.outputs.semVerStr }}"
104-
--java-options "--enable-native-access=org.cryptomator.jfuse.mac"
105-
--java-options "-Xss5m"
106-
--java-options "-Xmx256m"
107-
--java-options "-Dfile.encoding=\"utf-8\""
82+
run: |
83+
envsubst < dist/jpackage.args > target/jpackage.args
84+
"${JAVA_HOME}/bin/jpackage" '@./target/jpackage.args'
85+
env:
86+
JP_APP_VERSION: ${{ needs.prepare.outputs.semVerNum }}
87+
APP_VERSION: ${{ needs.prepare.outputs.semVerStr }}
88+
NATIVE_ACCESS_PACKAGE: org.cryptomator.jfuse.mac
10889
- uses: actions/upload-artifact@v4
10990
with:
11091
name: cryptomator-cli-mac-${{ matrix.architecture }}

.github/workflows/build-win.yml

+10-30
Original file line numberDiff line numberDiff line change
@@ -67,37 +67,17 @@ jobs:
6767
cp LICENSE.txt target
6868
cp target/cryptomator-*.jar target/mods
6969
- name: Run jlink
70-
run: >
71-
"${JAVA_HOME}/bin/jlink"
72-
--verbose
73-
--output target/runtime
74-
--module-path "${JAVA_HOME}/jmods"
75-
--add-modules java.base,java.compiler,java.naming,java.xml
76-
--strip-native-commands
77-
--no-header-files
78-
--no-man-pages
79-
--strip-debug
80-
--compress zip-6
70+
run: |
71+
envsubst < dist/jlink.args > target/jlink.args
72+
"${JAVA_HOME}/bin/jlink" '@./target/jlink.args'
8173
- name: Run jpackage
82-
run: >
83-
"${JAVA_HOME}/bin/jpackage"
84-
--verbose
85-
--type app-image
86-
--runtime-image target/runtime
87-
--input target/libs
88-
--module-path target/mods
89-
--module org.cryptomator.cli/org.cryptomator.cli.CryptomatorCli
90-
--dest target
91-
--name cryptomator-cli
92-
--vendor "Skymatic GmbH"
93-
--copyright "(C) 2016 - 2024 Skymatic GmbH"
94-
--app-version "${{ needs.prepare.outputs.semVerNum }}"
95-
--java-options "-Dorg.cryptomator.cli.version=${{ needs.prepare.outputs.semVerStr }}"
96-
--java-options "--enable-native-access=org.cryptomator.jfuse.win"
97-
--java-options "-Xss5m"
98-
--java-options "-Xmx256m"
99-
--java-options "-Dfile.encoding=\"utf-8\""
100-
--win-console
74+
run: |
75+
envsubst < dist/jpackage.args > target/jpackage.args
76+
"${JAVA_HOME}/bin/jpackage" '@./target/jpackage.args' --win-console
77+
env:
78+
JP_APP_VERSION: ${{ needs.prepare.outputs.semVerNum }}
79+
APP_VERSION: ${{ needs.prepare.outputs.semVerStr }}
80+
NATIVE_ACCESS_PACKAGE: org.cryptomator.jfuse.win
10181
- uses: actions/upload-artifact@v4
10282
with:
10383
name: cryptomator-cli-win-x64

build_linux.sh

+9-29
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ set -euxo pipefail
33

44
echo "Building cryptomator cli..."
55

6+
export APP_VERSION='0.1.0-local'
7+
68
# Check if Maven is installed
79
if ! command -v mvn &> /dev/null; then
810
echo "Maven is not installed. Please install Maven to proceed."
@@ -29,23 +31,15 @@ cp ./LICENSE.txt ./target/
2931
mv ./target/cryptomator-cli-*.jar ./target/mods
3032

3133
echo "Creating JRE with jlink..."
32-
"$JAVA_HOME/bin/jlink" \
33-
--verbose \
34-
--output target/runtime \
35-
--module-path "${JAVA_HOME}/jmods" \
36-
--add-modules java.base,java.compiler,java.naming,java.xml \
37-
--strip-native-commands \
38-
--no-header-files \
39-
--no-man-pages \
40-
--strip-debug \
41-
--compress zip-0
34+
envsubst < dist/jlink.args > target/jlink.args
35+
"$JAVA_HOME/bin/jlink" '@./target/jlink.args'
4236

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

48-
NATIVE_ACCESS_PACKAGE="no.native.access.available"
42+
export NATIVE_ACCESS_PACKAGE="no.native.access.available"
4943
_OS=$(uname -s)
5044
if (echo "$_OS" | grep -q "Linux.*") ; then
5145
_ARCH=$(uname -m)
@@ -59,25 +53,11 @@ if (echo "$_OS" | grep -q "Linux.*") ; then
5953
fi
6054
fi
6155

56+
export JP_APP_VERSION='99.9.9'
57+
envsubst < dist/jpackage.args > target/jpackage.args
58+
6259
echo "Creating app binary with jpackage..."
63-
"$JAVA_HOME/bin/jpackage" \
64-
--verbose \
65-
--type app-image \
66-
--runtime-image target/runtime \
67-
--input target/libs \
68-
--module-path target/mods \
69-
--module org.cryptomator.cli/org.cryptomator.cli.CryptomatorCli \
70-
--dest target \
71-
--name cryptomator-cli \
72-
--vendor "Skymatic GmbH" \
73-
--copyright "(C) 2016 - 2024 Skymatic GmbH" \
74-
--app-version "0.0.1.0" \
75-
--java-options "-Dorg.cryptomator.cli.version=0.0.1-local" \
76-
--java-options "--enable-preview" \
77-
--java-options "--enable-native-access=${NATIVE_ACCESS_PACKAGE}" \
78-
--java-options "-Xss5m" \
79-
--java-options "-Xmx256m" \
80-
--java-options "-Dfile.encoding=utf-8" \
60+
"$JAVA_HOME/bin/jpackage" '@./target/jpackage.args'
8161

8262
if [ $? -ne 0 ] || [ ! -d ./target/cryptomator-cli ]; then
8363
echo "Binary creation with jpackage failed."

build_mac.sh

+9-28
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
echo "Building cryptomator cli..."
44

5+
export APP_VERSION='0.1.0-local'
6+
57
# Check if Maven is installed
68
if ! command -v mvn &> /dev/null; then
79
echo "Maven is not installed. Please install Maven to proceed."
@@ -28,41 +30,20 @@ cp ./LICENSE.txt ./target/
2830
mv ./target/cryptomator-cli-*.jar ./target/mods
2931

3032
echo "Creating JRE with jlink..."
31-
"$JAVA_HOME/bin/jlink" \
32-
--verbose \
33-
--output target/runtime \
34-
--module-path "${JAVA_HOME}/jmods" \
35-
--add-modules java.base,java.compiler,java.naming,java.xml \
36-
--strip-native-commands \
37-
--no-header-files \
38-
--no-man-pages \
39-
--strip-debug \
40-
--compress zip-0
33+
envsubst < dist/jlink.args > target/jlink.args
34+
"$JAVA_HOME/bin/jlink" '@./target/jlink.args'
4135

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

41+
export JP_APP_VERSION='99.9.9'
42+
export NATIVE_ACCESS_PACKAGE="org.cryptomator.jfuse.mac"
43+
envsubst < dist/jpackage.args > target/jpackage.args
44+
4745
echo "Creating app binary with jpackage..."
48-
"$JAVA_HOME/bin/jpackage" \
49-
--verbose \
50-
--type app-image \
51-
--runtime-image target/runtime \
52-
--input target/libs \
53-
--module-path target/mods \
54-
--module org.cryptomator.cli/org.cryptomator.cli.CryptomatorCli \
55-
--dest target \
56-
--name cryptomator-cli \
57-
--vendor "Skymatic GmbH" \
58-
--copyright "(C) 2016 - 2024 Skymatic GmbH" \
59-
--app-version "99.9.9" \
60-
--java-options "-Dorg.cryptomator.cli.version=0.0.1-local" \
61-
--java-options "--enable-preview" \
62-
--java-options "--enable-native-access=org.cryptomator.jfuse.mac" \
63-
--java-options "-Xss5m" \
64-
--java-options "-Xmx256m" \
65-
--java-options "-Dfile.encoding=utf-8" \
46+
"$JAVA_HOME/bin/jpackage" '@./target/jpackage.args'
6647

6748
if [ $? -ne 0 ] || [ ! -d ./target/cryptomator-cli.app ]; then
6849
echo "Binary creation with jpackage failed."

build_win.ps1

+15-31
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
"Building cryptomator cli..."
22

3+
$appVersion='0.1.0-local'
4+
35
# Check if maven is installed
46
$commands = 'mvn'
57
foreach ($cmd in $commands) {
@@ -14,7 +16,7 @@ if(-not $env:JAVA_HOME) {
1416
# Check Java version
1517
$minJavaVersion=$(mvn help:evaluate "-Dexpression=jdk.version" -q -DforceStdout)
1618
$javaVersion = $(& "$env:JAVA_HOME\bin\java" --version) -split ' ' | Select-Object -Index 1
17-
if( ($javaVersion -split '.' | Select-Object -First 1) -ne "22") {
19+
if( ($javaVersion.Split('.') | Select-Object -First 1) -ne "22") {
1820
throw "Java version $javaVersion is too old. Minimum required version is $minJavaVersion"
1921
}
2022

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

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

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

36+
## powershell does not have envsubst
37+
$jpAppVersion='99.9.9'
38+
Get-Content -Path './dist/jpackage.args' | ForEach-Object {
39+
$_.Replace('${APP_VERSION}', $appVersion).
40+
Replace('${JP_APP_VERSION}', $jpAppVersion).
41+
Replace('${NATIVE_ACCESS_PACKAGE}', 'org.cryptomator.jfuse.win')
42+
} | Out-File -FilePath './target/jpackage.args'
43+
4244
# jpackage
4345
# app-version is hard coded, since the script is only for local test builds
4446
Write-Host "Creating app binary with jpackage..."
45-
& $env:JAVA_HOME/bin/jpackage `
46-
--verbose `
47-
--type app-image `
48-
--runtime-image target/runtime `
49-
--input target/libs `
50-
--module-path target/mods `
51-
--module org.cryptomator.cli/org.cryptomator.cli.CryptomatorCli `
52-
--dest target `
53-
--name cryptomator-cli `
54-
--vendor "Skymatic GmbH" `
55-
--copyright "(C) 2016 - 2024 Skymatic GmbH" `
56-
--app-version "0.0.1.0" `
57-
--java-options "-Dorg.cryptomator.cli.version=0.0.1-local" `
58-
--java-options "--enable-preview" `
59-
--java-options "--enable-native-access=org.cryptomator.jfuse.win" `
60-
--java-options "-Xss5m" `
61-
--java-options "-Xmx256m" `
62-
--java-options '-Dfile.encoding="utf-8"' `
63-
--win-console
47+
& $env:JAVA_HOME/bin/jpackage `@./target/jpackage.args --win-console
6448

6549
if ( ($LASTEXITCODE -ne 0) -or (-not (Test-Path ./target/cryptomator-cli))) {
6650
throw "Binary creation with jpackage failed with exit code $LASTEXITCODE."

dist/jlink.args

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
--verbose
2+
--module-path "${JAVA_HOME}/jmods"
3+
--output target/runtime
4+
--add-modules java.base,java.compiler,java.naming,java.xml
5+
--strip-native-commands
6+
--no-header-files
7+
--no-man-pages
8+
--strip-debug
9+
--compress zip-6

dist/jpackage.args

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Contains three env vars:
2+
# JP_APP_VERSION: The version needed for jpackage. This version _must_ follow the scheme Y.X.X, where Y >= 1 and X >=0
3+
# APP_VERSION: The actual, semantic version displayed in the cli app
4+
# NATIVE_ACCESS_PACKAGE: The java package containing the fuse bindings for the system
5+
--verbose
6+
--type app-image
7+
--runtime-image target/runtime
8+
--input target/libs
9+
--module-path target/mods
10+
--module org.cryptomator.cli/org.cryptomator.cli.CryptomatorCli
11+
--dest target
12+
--name cryptomator-cli
13+
--vendor "Skymatic GmbH"
14+
--copyright "(C) 2016 - 2024 Skymatic GmbH"
15+
--app-version "${JP_APP_VERSION}"
16+
--java-options "-Dorg.cryptomator.cli.version=${APP_VERSION}"
17+
--java-options "--enable-native-access=${NATIVE_ACCESS_PACKAGE}"
18+
--java-options "-Xss5m"
19+
--java-options "-Xmx256m"
20+
--java-options "-Dfile.encoding=\"utf-8\""

0 commit comments

Comments
 (0)