Skip to content

Commit 2060729

Browse files
committed
make local build scripts more robust
1 parent eb812cc commit 2060729

File tree

3 files changed

+31
-2
lines changed

3 files changed

+31
-2
lines changed

build_linux.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#!/bin/bash
2+
set -euxo pipefail
23

34
echo "Building cryptomator cli..."
45

@@ -14,6 +15,14 @@ if [ -z "$JAVA_HOME" ]; then
1415
exit 1
1516
fi
1617

18+
# Check Java version
19+
MIN_JAVA_VERSION=$(mvn help:evaluate "-Dexpression=jdk.version" -q -DforceStdout):w
20+
JAVA_VERSION=$("$JAVA_HOME/bin/java" -version | head -n1 | cut -d' ' -f2 | cut -d'.' -f1)
21+
if [ "$JAVA_VERSION" -lt "$MIN_JAVA_VERSION" ]; then
22+
echo "Java version $JAVA_VERSION is too old. Minimum required version is $MIN_JAVA_VERSION"
23+
exit 1
24+
fi
25+
1726
echo "Building java app with maven..."
1827
mvn -B clean package
1928
cp ./LICENSE.txt ./target/
@@ -44,6 +53,9 @@ if (echo "$_OS" | grep -q "Linux.*") ; then
4453
NATIVE_ACCESS_PACKAGE="org.cryptomator.jfuse.linux.amd64"
4554
elif [ "$_ARCH" = "aarch64" ]; then
4655
NATIVE_ACCESS_PACKAGE="org.cryptomator.jfuse.linux.aarch64"
56+
else
57+
echo "Warning: Unsupported Linux architecture for FUSE mounter: $_ARCH"
58+
echo "FUSE supported architectures: x86_64, aarch64"
4759
fi
4860
fi
4961

build_mac.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,14 @@ if [ -z "$JAVA_HOME" ]; then
1414
exit 1
1515
fi
1616

17+
# Check Java version
18+
MIN_JAVA_VERSION=$(mvn help:evaluate "-Dexpression=jdk.version" -q -DforceStdout)
19+
JAVA_VERSION=$("$JAVA_HOME/bin/java" -version | head -n1 | cut -d' ' -f2 | cut -d'.' -f1)
20+
if [ "$JAVA_VERSION" -lt "$MIN_JAVA_VERSION" ]; then
21+
echo "Java version $JAVA_VERSION is too old. Minimum required version is $MIN_JAVA_VERSION"
22+
exit 1
23+
fi
24+
1725
echo "Building java app with maven..."
1826
mvn -B clean package
1927
cp ./LICENSE.txt ./target/

build_win.ps1

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,27 @@
11
"Building cryptomator cli..."
22

3+
# Check if maven is installed
34
$commands = 'mvn'
45
foreach ($cmd in $commands) {
56
Invoke-Expression -Command "${cmd} --version" -ErrorAction Stop
67
}
78

9+
# Check if JAVA_HOME is set
810
if(-not $env:JAVA_HOME) {
911
throw "Environment variable JAVA_HOME not defined"
1012
}
1113

14+
# Check Java version
15+
$minJavaVersion=$(mvn help:evaluate "-Dexpression=jdk.version" -q -DforceStdout)
16+
$javaVersion = $(& "$env:JAVA_HOME\bin\java" --version) -split ' ' | Select-Object -Index 1
17+
if( ($javaVersion -split '.' | Select-Object -First 1) -ne "22") {
18+
throw "Java version $javaVersion is too old. Minimum required version is $minJavaVersion"
19+
}
20+
1221
Write-Host "Building java app with maven..."
1322
mvn -B clean package
14-
Copy-Item ./LICENSE.txt -Destination ./target
15-
Move-Item ./target/cryptomator-cli-*.jar ./target/mods
23+
Copy-Item ./LICENSE.txt -Destination ./target -ErrorAction Stop
24+
Move-Item ./target/cryptomator-cli-*.jar ./target/mods -ErrorAction Stop
1625

1726
Write-Host "Creating JRE with jlink..."
1827
& $env:JAVA_HOME/bin/jlink `

0 commit comments

Comments
 (0)