Skip to content

Commit 74fb665

Browse files
committed
Use temporary tool cache
1 parent 2d4242d commit 74fb665

File tree

4 files changed

+43
-39
lines changed

4 files changed

+43
-39
lines changed

BUILDING.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ This guide explains how to build Codename One from source using Maven. It provid
44

55
## Prerequisites
66

7-
- **JDK 8**
7+
- **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/jdk8u462-b08/OpenJDK8U-jdk_x64_linux_hotspot_8u462b08.tar.gz
21-
tar xf temurin8.tar.gz
22-
export JAVA_HOME=$PWD/jdk8u462-b08
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
@@ -40,11 +40,11 @@ cd CodenameOne
4040
source tools/env.sh
4141
```
4242

43-
The script runs `mvn install` in `maven/`, installs `cn1-maven-archetypes`, and ensures `~/.codenameone/CodeNameOneBuildClient.jar` is installed by invoking the `cn1:install-codenameone` Maven goal. If that goal fails, the script copies the jar from `maven/CodeNameOneBuildClient.jar`. After the script finishes, `tools/env.sh` contains environment variables for the provisioned JDKs and Maven.
43+
The script runs `mvn install` in `maven/`, installs `cn1-maven-archetypes`, and ensures `~/.codenameone/CodeNameOneBuildClient.jar` is installed by invoking the `cn1:install-codenameone` Maven goal. If that goal fails, the script copies the jar from `maven/CodeNameOneBuildClient.jar`. After the script finishes, `tools/env.sh` contains environment variables for the provisioned JDKs and Maven. Downloads are placed in a temporary directory outside the repository to keep the workspace clean.
4444

4545
## Building the Android port
4646

47-
The Android port uses JDK 17 for compilation while Maven runs with JDK 8. Javadoc generation is skipped to avoid known Maven report issues. Run the build script:
47+
The Android port uses JDK 17 for compilation while Maven runs with JDK 11. Javadoc generation is skipped to avoid known Maven report issues. 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 to a temporary directory, 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: 4 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,12 @@ else
1111
source "$ROOT/tools/env.sh"
1212
fi
1313

14-
if ! "${JAVA_HOME:-}/bin/java" -version 2>&1 | grep -q '1\.8\.0'; then
14+
if ! "${JAVA_HOME:-}/bin/java" -version 2>&1 | grep -q '11\.0'; then
1515
./scripts/setup-workspace.sh -q -DskipTests
1616
source "$ROOT/tools/env.sh"
1717
fi
18-
if ! "${JAVA_HOME:-}/bin/java" -version 2>&1 | grep -q '1\.8\.0'; then
19-
echo "Failed to provision JDK 8" >&2
18+
if ! "${JAVA_HOME:-}/bin/java" -version 2>&1 | grep -q '11\.0'; then
19+
echo "Failed to provision JDK 11" >&2
2020
exit 1
2121
fi
2222
if ! "${JAVA_HOME_17:-}/bin/java" -version 2>&1 | grep -q '17\.0'; then

scripts/build-ios-port.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ 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\.0'; then
20+
if ! "${JAVA_HOME:-}/bin/java" -version 2>&1 | grep -q '11\.0'; then
2121
./scripts/setup-workspace.sh -q -DskipTests
2222
source "$ROOT/tools/env.sh"
2323
fi
24-
if ! "${JAVA_HOME:-}/bin/java" -version 2>&1 | grep -q '1\.8\.0'; then
25-
echo "Failed to provision JDK 8" >&2
24+
if ! "${JAVA_HOME:-}/bin/java" -version 2>&1 | grep -q '11\.0'; then
25+
echo "Failed to provision JDK 11" >&2
2626
exit 1
2727
fi
2828
export PATH="$JAVA_HOME/bin:$MAVEN_HOME/bin:$PATH"

scripts/setup-workspace.sh

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env bash
22
###
3-
# Prepare Codename One workspace by installing Maven, provisioning JDK 8 and JDK 17,
3+
# Prepare Codename One workspace by installing Maven, provisioning JDK 11 and JDK 17,
44
# building core modules, and installing Maven archetypes.
55
###
66
set -euo pipefail
@@ -10,8 +10,12 @@ log() {
1010
}
1111

1212
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
13-
TOOLS="$ROOT/tools"
14-
mkdir -p "$TOOLS"
13+
ENV_DIR="$ROOT/tools"
14+
mkdir -p "$ENV_DIR"
15+
16+
# Place downloaded tools outside the repository so it isn't filled with binaries
17+
DOWNLOAD_DIR="${TMPDIR:-/tmp}/codenameone-tools"
18+
mkdir -p "$DOWNLOAD_DIR"
1519

1620
JAVA_HOME="${JAVA_HOME:-}"
1721
JAVA_HOME_17="${JAVA_HOME_17:-}"
@@ -32,36 +36,36 @@ case "$arch_name" in
3236
esac
3337

3438
# Determine platform-specific JDK download URLs
35-
arch_jdk8="$arch"
39+
arch_jdk11="$arch"
3640
if [ "$os" = "mac" ] && [ "$arch" = "aarch64" ]; then
37-
arch_jdk8="x64"
41+
arch_jdk11="x64"
3842
fi
39-
JDK8_URL="https://github.com/adoptium/temurin8-binaries/releases/download/jdk8u462-b08/OpenJDK8U-jdk_${arch_jdk8}_${os}_hotspot_8u462b08.tar.gz"
43+
JDK11_URL="https://github.com/adoptium/temurin11-binaries/releases/download/jdk-11.0.28%2B6/OpenJDK11U-jdk_${arch_jdk11}_${os}_hotspot_11.0.28_6.tar.gz"
4044
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"
4145
MAVEN_URL="https://archive.apache.org/dist/maven/maven-3/3.9.6/binaries/apache-maven-3.9.6-bin.tar.gz"
4246

4347
install_jdk() {
4448
local url="$1" dest_var="$2"
45-
local tmp="$TOOLS/jdk.tgz"
49+
local tmp="$DOWNLOAD_DIR/jdk.tgz"
4650
log "Downloading JDK from $url"
4751
curl -fL "$url" -o "$tmp"
4852
local top
4953
top=$(tar -tzf "$tmp" 2>/dev/null | head -1 | cut -d/ -f1 || true)
50-
tar -xzf "$tmp" -C "$TOOLS"
54+
tar -xzf "$tmp" -C "$DOWNLOAD_DIR"
5155
rm "$tmp"
52-
local home="$TOOLS/$top"
56+
local home="$DOWNLOAD_DIR/$top"
5357
if [ -d "$home/Contents/Home" ]; then
5458
home="$home/Contents/Home"
5559
fi
5660
eval "$dest_var=\"$home\""
5761
}
5862

59-
log "Ensuring JDK 8 is available"
60-
if [ ! -x "${JAVA_HOME:-}/bin/java" ] || ! "${JAVA_HOME:-}/bin/java" -version 2>&1 | grep -q '1\.8\.0'; then
61-
log "Provisioning JDK 8 (this may take a while)..."
62-
install_jdk "$JDK8_URL" JAVA_HOME
63+
log "Ensuring JDK 11 is available"
64+
if [ ! -x "${JAVA_HOME:-}/bin/java" ] || ! "${JAVA_HOME:-}/bin/java" -version 2>&1 | grep -q '11\.0'; then
65+
log "Provisioning JDK 11 (this may take a while)..."
66+
install_jdk "$JDK11_URL" JAVA_HOME
6367
else
64-
log "Using existing JDK 8 at $JAVA_HOME"
68+
log "Using existing JDK 11 at $JAVA_HOME"
6569
fi
6670

6771
log "Ensuring JDK 17 is available"
@@ -74,27 +78,27 @@ fi
7478

7579
log "Ensuring Maven is available"
7680
if ! [ -x "${MAVEN_HOME:-}/bin/mvn" ]; then
77-
tmp="$TOOLS/maven.tgz"
81+
tmp="$DOWNLOAD_DIR/maven.tgz"
7882
log "Downloading Maven from $MAVEN_URL"
7983
curl -fL "$MAVEN_URL" -o "$tmp"
80-
tar -xzf "$tmp" -C "$TOOLS"
84+
tar -xzf "$tmp" -C "$DOWNLOAD_DIR"
8185
rm "$tmp"
82-
MAVEN_HOME="$TOOLS/apache-maven-3.9.6"
86+
MAVEN_HOME="$DOWNLOAD_DIR/apache-maven-3.9.6"
8387
else
8488
log "Using existing Maven at $MAVEN_HOME"
8589
fi
8690

87-
log "Writing environment to $TOOLS/env.sh"
88-
cat > "$TOOLS/env.sh" <<ENV
91+
log "Writing environment to $ENV_DIR/env.sh"
92+
cat > "$ENV_DIR/env.sh" <<ENV
8993
export JAVA_HOME="$JAVA_HOME"
9094
export JAVA_HOME_17="$JAVA_HOME_17"
9195
export MAVEN_HOME="$MAVEN_HOME"
9296
export PATH="\$JAVA_HOME/bin:\$MAVEN_HOME/bin:\$PATH"
9397
ENV
9498

95-
source "$TOOLS/env.sh"
99+
source "$ENV_DIR/env.sh"
96100

97-
log "JDK 8 version:"; "$JAVA_HOME/bin/java" -version
101+
log "JDK 11 version:"; "$JAVA_HOME/bin/java" -version
98102
log "JDK 17 version:"; "$JAVA_HOME_17/bin/java" -version
99103
log "Maven version:"; "$MAVEN_HOME/bin/mvn" -version
100104

0 commit comments

Comments
 (0)