Skip to content

Commit 9e6e1d2

Browse files
committed
Improve JDK provisioning and build scripts
1 parent 945a847 commit 9e6e1d2

File tree

4 files changed

+42
-25
lines changed

4 files changed

+42
-25
lines changed

BUILDING.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# Building Codename One
22

3-
This guide explains how to build Codename One and its Android and iOS ports locally using Maven.
3+
This guide explains how to build Codename One and its Android and iOS ports locally with Maven.
44

55
## Prerequisites
66

7-
- **JDK 8** (Codename One also builds with JDK 11, but these steps use JDK 8)
7+
- **JDK 11** (Codename One also builds with JDK 8, but these steps use JDK 11)
88
- **JDK 17** for building the Android port
99
- **Apache Maven 3.6+**
1010
- macOS with Xcode (required only for the iOS port)
@@ -16,10 +16,10 @@ The helper scripts in the `scripts/` directory download these dependencies when
1616
Download binaries from [Adoptium](https://adoptium.net):
1717

1818
```bash
19-
# JDK 8 (Linux x64; adjust `_x64_linux_` for your platform)
20-
curl -L -o temurin8.tar.gz https://github.com/adoptium/temurin8-binaries/releases/download/jdk8u442-b06/OpenJDK8U-jdk_x64_linux_hotspot_8u442b06.tar.gz
21-
tar xf temurin8.tar.gz
22-
export JAVA_HOME=$PWD/jdk8u442-b06
19+
# JDK 11 (Linux x64; adjust `_x64_linux_` for your platform)
20+
curl -L -o temurin11.tar.gz https://github.com/adoptium/temurin11-binaries/releases/download/jdk-11.0.28%2B6/OpenJDK11U-jdk_x64_linux_hotspot_11.0.28_6.tar.gz
21+
tar xf temurin11.tar.gz
22+
export JAVA_HOME=$PWD/jdk-11.0.28+6
2323

2424
# JDK 17 (Linux x64; adjust `_x64_linux_` for your platform)
2525
curl -L -o temurin17.tar.gz https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.16%2B8/OpenJDK17U-jdk_x64_linux_hotspot_17.0.16_8.tar.gz
@@ -31,7 +31,7 @@ export PATH="$JAVA_HOME/bin:$PATH"
3131

3232
## Preparing the workspace
3333

34-
Clone the repository and run the setup script to download JDK 8 and JDK 17, install Maven, build the core modules, and install the Maven archetypes. This step must be performed before building any ports.
34+
Clone the repository and run the setup script to download JDK 11 and JDK 17, install Maven, build the core modules, and install the Maven archetypes. This step must be performed before building any ports.
3535

3636
```bash
3737
git clone https://github.com/codenameone/CodenameOne
@@ -44,7 +44,7 @@ The script runs `mvn install` in `maven/`, installs `cn1-maven-archetypes`, and
4444

4545
## Building the Android port
4646

47-
The Android port uses JDK 17 for compilation while Maven runs with JDK 8. Run the build script:
47+
The Android port uses JDK 17 for compilation while Maven runs with JDK 11. Run the build script:
4848

4949
```bash
5050
./scripts/build-android-port.sh -DskipTests
@@ -64,9 +64,9 @@ Artifacts are produced in `maven/ios/target`.
6464

6565
## Convenience scripts
6666

67-
- `setup-workspace.sh` – installs Maven, downloads JDK 8 and JDK 17, builds the core modules, installs Maven archetypes, provisions the Codename One build client, and writes `tools/env.sh`.
68-
- `build-android-port.sh` – builds the Android port using JDK 8 for Maven and JDK 17 for compilation.
69-
- `build-ios-port.sh` – builds the iOS port on macOS with JDK 8.
67+
- `setup-workspace.sh` – installs Maven, downloads JDK 11 and JDK 17, builds the core modules, installs Maven archetypes, provisions the Codename One build client, and writes `tools/env.sh`.
68+
- `build-android-port.sh` – builds the Android port using JDK 11 for Maven and JDK 17 for compilation.
69+
- `build-ios-port.sh` – builds the iOS port on macOS with JDK 11.
7070

7171
## Further reading
7272

scripts/build-android-port.sh

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/usr/bin/env bash
2-
# Build Codename One Android port using JDK 8 for Maven and JDK 17 for compilation
2+
# Build Codename One Android port using JDK 11 for Maven and JDK 17 for compilation
33
set -euo pipefail
44
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
55
cd "$ROOT"
@@ -11,12 +11,22 @@ else
1111
source "$ROOT/tools/env.sh"
1212
fi
1313

14-
if ! "$JAVA_HOME/bin/java" -version 2>&1 | grep -q '1\.8'; then
15-
echo "JAVA_HOME must point to JDK 8" >&2
14+
if ! "$JAVA_HOME/bin/java" -version 2>&1 | grep -q '11\.0'; then
15+
echo "JAVA_HOME is not JDK 11; running setup-workspace.sh" >&2
16+
./scripts/setup-workspace.sh -q -DskipTests
17+
source "$ROOT/tools/env.sh"
18+
fi
19+
if ! "$JAVA_HOME/bin/java" -version 2>&1 | grep -q '11\.0'; then
20+
echo "Failed to provision JDK 11" >&2
1621
exit 1
1722
fi
1823
if ! "$JAVA_HOME_17/bin/java" -version 2>&1 | grep -q '17\.0'; then
19-
echo "JAVA_HOME_17 must point to JDK 17" >&2
24+
echo "JAVA_HOME_17 is not JDK 17; running setup-workspace.sh" >&2
25+
./scripts/setup-workspace.sh -q -DskipTests
26+
source "$ROOT/tools/env.sh"
27+
fi
28+
if ! "$JAVA_HOME_17/bin/java" -version 2>&1 | grep -q '17\.0'; then
29+
echo "Failed to provision JDK 17" >&2
2030
exit 1
2131
fi
2232

scripts/build-ios-port.sh

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,13 @@ else
1717
./scripts/setup-workspace.sh -q -DskipTests
1818
source "$ROOT/tools/env.sh"
1919
fi
20-
if ! "$JAVA_HOME/bin/java" -version 2>&1 | grep -q '1\.8'; then
21-
echo "JAVA_HOME must point to JDK 8" >&2
20+
if ! "$JAVA_HOME/bin/java" -version 2>&1 | grep -q '11\.0'; then
21+
echo "JAVA_HOME is not JDK 11; running setup-workspace.sh" >&2
22+
./scripts/setup-workspace.sh -q -DskipTests
23+
source "$ROOT/tools/env.sh"
24+
fi
25+
if ! "$JAVA_HOME/bin/java" -version 2>&1 | grep -q '11\.0'; then
26+
echo "Failed to provision JDK 11" >&2
2227
exit 1
2328
fi
2429
export PATH="$JAVA_HOME/bin:$MAVEN_HOME/bin:$PATH"

scripts/setup-workspace.sh

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/usr/bin/env bash
2-
# Prepare Codename One workspace by installing Maven, provisioning JDK 8 and JDK 17,
2+
# Prepare Codename One workspace by installing Maven, provisioning JDK 11 and JDK 17,
33
# building core modules, and installing Maven archetypes.
44
set -euo pipefail
55
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
@@ -19,15 +19,17 @@ case "$arch_name" in
1919
*) echo "Unsupported architecture: $arch_name" >&2; exit 1 ;;
2020
esac
2121

22-
JDK8_URL="https://github.com/adoptium/temurin8-binaries/releases/download/jdk8u442-b06/OpenJDK8U-jdk_${arch}_${os}_hotspot_8u442b06.tar.gz"
22+
JDK11_URL="https://github.com/adoptium/temurin11-binaries/releases/download/jdk-11.0.28%2B6/OpenJDK11U-jdk_${arch}_${os}_hotspot_11.0.28_6.tar.gz"
2323
JDK17_URL="https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.16%2B8/OpenJDK17U-jdk_${arch}_${os}_hotspot_17.0.16_8.tar.gz"
2424
MAVEN_URL="https://archive.apache.org/dist/maven/maven-3/3.9.6/binaries/apache-maven-3.9.6-bin.tar.gz"
2525

2626
install_jdk() {
2727
local url="$1" dest_var="$2"
2828
local tmp="$TOOLS/jdk.tgz"
29+
echo "Downloading JDK from $url"
2930
curl -fL "$url" -o "$tmp"
30-
local top=$(tar -tzf "$tmp" | head -1 | cut -d/ -f1)
31+
local top
32+
top=$(tar -tzf "$tmp" 2>/dev/null | head -1 | cut -d/ -f1 || true)
3133
tar -xzf "$tmp" -C "$TOOLS"
3234
rm "$tmp"
3335
local home="$TOOLS/$top"
@@ -37,18 +39,18 @@ install_jdk() {
3739
eval "$dest_var=\"$home\""
3840
}
3941

40-
if ! [ -x "${JAVA_HOME:-}/bin/java" ] || ! "$JAVA_HOME/bin/java" -version 2>&1 | grep -q '1\.8'; then
41-
echo "Downloading JDK 8 (this may take a while)..."
42-
install_jdk "$JDK8_URL" JAVA_HOME
42+
if ! [ -x "${JAVA_HOME:-}/bin/java" ] || ! "$JAVA_HOME/bin/java" -version 2>&1 | grep -q '11\.0'; then
43+
echo "Provisioning JDK 11 (this may take a while)..."
44+
install_jdk "$JDK11_URL" JAVA_HOME
4345
fi
4446

4547
if ! [ -x "${JAVA_HOME_17:-}/bin/java" ] || ! "$JAVA_HOME_17/bin/java" -version 2>&1 | grep -q '17\.0'; then
46-
echo "Downloading JDK 17 (this may take a while)..."
48+
echo "Provisioning JDK 17 (this may take a while)..."
4749
install_jdk "$JDK17_URL" JAVA_HOME_17
4850
fi
4951

5052
if ! [ -x "${MAVEN_HOME:-}/bin/mvn" ]; then
51-
echo "Downloading Maven..."
53+
echo "Downloading Maven from $MAVEN_URL"
5254
tmp="$TOOLS/maven.tgz"
5355
curl -fL "$MAVEN_URL" -o "$tmp"
5456
tar -xzf "$tmp" -C "$TOOLS"

0 commit comments

Comments
 (0)