From f2591f56d73162a0dae2b6dc83de62736ccf9d10 Mon Sep 17 00:00:00 2001 From: Shai Almog <67850168+shai-almog@users.noreply.github.com> Date: Sat, 30 Aug 2025 19:27:25 +0300 Subject: [PATCH 1/7] Skip archetype integration tests during workspace setup --- .github/workflows/pr.yml | 8 ++- .github/workflows/scripts-android.yml | 30 ++++++++ .github/workflows/scripts-ios.yml | 28 ++++++++ BUILDING.md | 76 ++++++++++++++++++++ scripts/build-android-port.sh | 43 ++++++++++++ scripts/build-ios-port.sh | 39 +++++++++++ scripts/setup-workspace.sh | 99 +++++++++++++++++++++++++++ 7 files changed, 322 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/scripts-android.yml create mode 100644 .github/workflows/scripts-ios.yml create mode 100644 BUILDING.md create mode 100755 scripts/build-android-port.sh create mode 100755 scripts/build-ios-port.sh create mode 100755 scripts/setup-workspace.sh diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 73be8315a4..3e9c8efec9 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -1,12 +1,18 @@ name: PR CI -on: +on: pull_request: branches: - master + paths-ignore: + - 'scripts/**' + - '**/*.md' push: branches: - master + paths-ignore: + - 'scripts/**' + - '**/*.md' jobs: build-linux-jdk8-fx: diff --git a/.github/workflows/scripts-android.yml b/.github/workflows/scripts-android.yml new file mode 100644 index 0000000000..b6f2ad8544 --- /dev/null +++ b/.github/workflows/scripts-android.yml @@ -0,0 +1,30 @@ +--- +name: Test Android build scripts + +'on': + pull_request: + paths: + - 'scripts/**' + - 'BUILDING.md' + push: + branches: + - master + paths: + - 'scripts/**' + - 'BUILDING.md' + +jobs: + build-android: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Setup workspace + run: ./scripts/setup-workspace.sh -q -DskipTests + - name: Build Android port + run: | + source tools/env.sh + echo "JAVA_HOME=$JAVA_HOME" + java -version + echo "JAVA_HOME_17=$JAVA_HOME_17" + "$JAVA_HOME_17/bin/java" -version + ./scripts/build-android-port.sh -q -DskipTests diff --git a/.github/workflows/scripts-ios.yml b/.github/workflows/scripts-ios.yml new file mode 100644 index 0000000000..ebc72c57a0 --- /dev/null +++ b/.github/workflows/scripts-ios.yml @@ -0,0 +1,28 @@ +--- +name: Test iOS build scripts + +'on': + pull_request: + paths: + - 'scripts/**' + - 'BUILDING.md' + push: + branches: + - master + paths: + - 'scripts/**' + - 'BUILDING.md' + +jobs: + build-ios: + runs-on: macos-latest + steps: + - uses: actions/checkout@v4 + - name: Setup workspace + run: ./scripts/setup-workspace.sh -q -DskipTests + - name: Build iOS port + run: | + source tools/env.sh + echo "JAVA_HOME=$JAVA_HOME" + java -version + ./scripts/build-ios-port.sh -q -DskipTests diff --git a/BUILDING.md b/BUILDING.md new file mode 100644 index 0000000000..002fd39f29 --- /dev/null +++ b/BUILDING.md @@ -0,0 +1,76 @@ +# Building Codename One + +This guide provides reproducible steps to build Codename One locally with Maven, including its Android and iOS ports. + +## Prerequisites + +- **JDK 8** +- **JDK 17** for building the Android port +- **Apache Maven 3.6+** +- macOS with Xcode (required only for the iOS port) + +The helper scripts in the `scripts/` directory download these dependencies when they are not already installed. On Apple Silicon +macOS machines, the scripts download the Intel JDK 8 and run it via Rosetta because an ARM build of JDK 8 is unavailable. + +### Installing JDKs on Linux + +Download binaries from [Adoptium](https://adoptium.net): + +```bash +# JDK 8 (Linux x64; adjust `_x64_linux_` for your platform) +curl -L -o temurin8.tar.gz https://github.com/adoptium/temurin8-binaries/releases/download/jdk8u462-b08/OpenJDK8U-jdk_x64_linux_hotspot_8u462b08.tar.gz +tar xf temurin8.tar.gz +export JAVA_HOME=$PWD/jdk8u462-b08 + +# JDK 17 (Linux x64; adjust `_x64_linux_` for your platform) +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 +tar xf temurin17.tar.gz +export JAVA_HOME_17=$PWD/jdk-17.0.16+8 + +export PATH="$JAVA_HOME/bin:$PATH" +``` + +## Preparing the workspace + +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. + +```bash +git clone https://github.com/codenameone/CodenameOne +cd CodenameOne +./scripts/setup-workspace.sh -DskipTests +source tools/env.sh +``` + +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. + +## Building the Android port + +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: + +```bash +./scripts/build-android-port.sh -DskipTests +``` + +Artifacts are placed in `maven/android/target`. + +## Building the iOS port + +The iOS port can only be built on macOS with Xcode installed. Run the iOS script: + +```bash +./scripts/build-ios-port.sh -DskipTests +``` + +Artifacts are produced in `maven/ios/target`. + +## Convenience scripts + +- `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`. +- `build-android-port.sh` – builds the Android port using JDK 8 for Maven and JDK 17 for compilation. +- `build-ios-port.sh` – builds the iOS port on macOS with JDK 8. + +## Further reading + +- Blog post: +- Maven developers guide: diff --git a/scripts/build-android-port.sh b/scripts/build-android-port.sh new file mode 100755 index 0000000000..81b0e83d21 --- /dev/null +++ b/scripts/build-android-port.sh @@ -0,0 +1,43 @@ +#!/usr/bin/env bash +# Build Codename One Android port using JDK 8 for Maven and JDK 17 for compilation +set -euo pipefail +ROOT="$(cd "$(dirname "$0")/.." && pwd)" +cd "$ROOT" + +if [ -f "$ROOT/tools/env.sh" ]; then + source "$ROOT/tools/env.sh" +else + ./scripts/setup-workspace.sh -q -DskipTests + source "$ROOT/tools/env.sh" +fi + +if ! "${JAVA_HOME:-}/bin/java" -version 2>&1 | grep -q '1\.8'; then + ./scripts/setup-workspace.sh -q -DskipTests + source "$ROOT/tools/env.sh" +fi +if ! "${JAVA_HOME:-}/bin/java" -version 2>&1 | grep -q '1\.8'; then + echo "Failed to provision JDK 8" >&2 + exit 1 +fi +if ! "${JAVA_HOME_17:-}/bin/java" -version 2>&1 | grep -q '17\.0'; then + ./scripts/setup-workspace.sh -q -DskipTests + source "$ROOT/tools/env.sh" +fi +if ! "${JAVA_HOME_17:-}/bin/java" -version 2>&1 | grep -q '17\.0'; then + echo "Failed to provision JDK 17" >&2 + exit 1 +fi + +export PATH="$JAVA_HOME/bin:$MAVEN_HOME/bin:$PATH" +"$JAVA_HOME/bin/java" -version +"$JAVA_HOME_17/bin/java" -version +"$MAVEN_HOME/bin/mvn" -version + +BUILD_CLIENT="$HOME/.codenameone/CodeNameOneBuildClient.jar" +if [ ! -f "$BUILD_CLIENT" ]; then + if ! "$MAVEN_HOME/bin/mvn" -q -f maven/pom.xml cn1:install-codenameone "$@"; then + [ -f maven/CodeNameOneBuildClient.jar ] && cp maven/CodeNameOneBuildClient.jar "$BUILD_CLIENT" || true + fi +fi + +"$MAVEN_HOME/bin/mvn" -q -f maven/pom.xml -pl android -am -Dmaven.javadoc.skip=true clean install "$@" diff --git a/scripts/build-ios-port.sh b/scripts/build-ios-port.sh new file mode 100755 index 0000000000..8f1116c7c1 --- /dev/null +++ b/scripts/build-ios-port.sh @@ -0,0 +1,39 @@ +#!/usr/bin/env bash +# Build Codename One iOS port (macOS only) +set -euo pipefail +if [[ "$(uname)" != "Darwin" ]]; then + echo "The iOS port can only be built on macOS with Xcode installed." >&2 + exit 1 +fi +if ! command -v xcodebuild >/dev/null; then + echo "Xcode command-line tools not found." >&2 + exit 1 +fi +ROOT="$(cd "$(dirname "$0")/.." && pwd)" +cd "$ROOT" +if [ -f "$ROOT/tools/env.sh" ]; then + source "$ROOT/tools/env.sh" +else + ./scripts/setup-workspace.sh -q -DskipTests + source "$ROOT/tools/env.sh" +fi +if ! "${JAVA_HOME:-}/bin/java" -version 2>&1 | grep -q '1\.8'; then + ./scripts/setup-workspace.sh -q -DskipTests + source "$ROOT/tools/env.sh" +fi +if ! "${JAVA_HOME:-}/bin/java" -version 2>&1 | grep -q '1\.8'; then + echo "Failed to provision JDK 8" >&2 + exit 1 +fi +export PATH="$JAVA_HOME/bin:$MAVEN_HOME/bin:$PATH" +"$JAVA_HOME/bin/java" -version +"$MAVEN_HOME/bin/mvn" -version + +BUILD_CLIENT="$HOME/.codenameone/CodeNameOneBuildClient.jar" +if [ ! -f "$BUILD_CLIENT" ]; then + if ! "$MAVEN_HOME/bin/mvn" -q -f maven/pom.xml cn1:install-codenameone "$@"; then + [ -f maven/CodeNameOneBuildClient.jar ] && cp maven/CodeNameOneBuildClient.jar "$BUILD_CLIENT" || true + fi +fi + +"$MAVEN_HOME/bin/mvn" -q -f maven/pom.xml -pl ios -am clean install "$@" diff --git a/scripts/setup-workspace.sh b/scripts/setup-workspace.sh new file mode 100755 index 0000000000..558da46287 --- /dev/null +++ b/scripts/setup-workspace.sh @@ -0,0 +1,99 @@ +#!/usr/bin/env bash +# Prepare Codename One workspace by installing Maven, provisioning JDK 8 and JDK 17, +# building core modules, and installing Maven archetypes. +set -euo pipefail +ROOT="$(cd "$(dirname "$0")/.." && pwd)" +TOOLS="$ROOT/tools" +mkdir -p "$TOOLS" + +JAVA_HOME="${JAVA_HOME:-}" +JAVA_HOME_17="${JAVA_HOME_17:-}" +MAVEN_HOME="${MAVEN_HOME:-}" + +os_name=$(uname -s) +arch_name=$(uname -m) +case "$os_name" in + Linux) os="linux" ;; + Darwin) os="mac" ;; + *) echo "Unsupported OS: $os_name" >&2; exit 1 ;; + esac +case "$arch_name" in + x86_64|amd64) arch="x64" ;; + arm64|aarch64) arch="aarch64" ;; + *) echo "Unsupported architecture: $arch_name" >&2; exit 1 ;; +esac + +# JDK 8 is not available for Apple Silicon. Use the Intel build when running on macOS ARM. +jdk8_arch="$arch" +jdk17_arch="$arch" +if [ "$os" = "mac" ] && [ "$arch" = "aarch64" ]; then + jdk8_arch="x64" +fi + +JDK8_URL="https://github.com/adoptium/temurin8-binaries/releases/download/jdk8u462-b08/OpenJDK8U-jdk_${jdk8_arch}_${os}_hotspot_8u462b08.tar.gz" +JDK17_URL="https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.16%2B8/OpenJDK17U-jdk_${jdk17_arch}_${os}_hotspot_17.0.16_8.tar.gz" +MAVEN_URL="https://archive.apache.org/dist/maven/maven-3/3.9.6/binaries/apache-maven-3.9.6-bin.tar.gz" + +install_jdk() { + local url="$1" dest_var="$2" + local tmp="$TOOLS/jdk.tgz" + echo "Downloading JDK from $url" + curl -fL "$url" -o "$tmp" + local top + top=$(tar -tzf "$tmp" 2>/dev/null | head -1 | cut -d/ -f1 || true) + tar -xzf "$tmp" -C "$TOOLS" + rm "$tmp" + local home="$TOOLS/$top" + if [ -d "$home/Contents/Home" ]; then + home="$home/Contents/Home" + fi + eval "$dest_var=\"$home\"" +} + +if [ ! -x "${JAVA_HOME:-}/bin/java" ] || ! "${JAVA_HOME:-}/bin/java" -version 2>&1 | grep -q '1\.8'; then + echo "Provisioning JDK 8 (this may take a while)..." + install_jdk "$JDK8_URL" JAVA_HOME +fi + +if [ ! -x "${JAVA_HOME_17:-}/bin/java" ] || ! "${JAVA_HOME_17:-}/bin/java" -version 2>&1 | grep -q '17\.0'; then + echo "Provisioning JDK 17 (this may take a while)..." + install_jdk "$JDK17_URL" JAVA_HOME_17 +fi + +if ! [ -x "${MAVEN_HOME:-}/bin/mvn" ]; then + echo "Downloading Maven from $MAVEN_URL" + tmp="$TOOLS/maven.tgz" + curl -fL "$MAVEN_URL" -o "$tmp" + tar -xzf "$tmp" -C "$TOOLS" + rm "$tmp" + MAVEN_HOME="$TOOLS/apache-maven-3.9.6" +fi + +cat > "$TOOLS/env.sh" < Date: Sat, 30 Aug 2025 21:29:26 +0300 Subject: [PATCH 2/7] chore: add debug logging to workspace setup --- scripts/setup-workspace.sh | 45 ++++++++++++++++++++++++++++---------- 1 file changed, 34 insertions(+), 11 deletions(-) diff --git a/scripts/setup-workspace.sh b/scripts/setup-workspace.sh index 558da46287..8de5d91979 100755 --- a/scripts/setup-workspace.sh +++ b/scripts/setup-workspace.sh @@ -1,7 +1,14 @@ #!/usr/bin/env bash +### # Prepare Codename One workspace by installing Maven, provisioning JDK 8 and JDK 17, # building core modules, and installing Maven archetypes. +### set -euo pipefail + +log() { + echo "[setup-workspace] $1" +} + ROOT="$(cd "$(dirname "$0")/.." && pwd)" TOOLS="$ROOT/tools" mkdir -p "$TOOLS" @@ -10,13 +17,14 @@ JAVA_HOME="${JAVA_HOME:-}" JAVA_HOME_17="${JAVA_HOME_17:-}" MAVEN_HOME="${MAVEN_HOME:-}" +log "Detecting host platform" os_name=$(uname -s) arch_name=$(uname -m) case "$os_name" in Linux) os="linux" ;; Darwin) os="mac" ;; *) echo "Unsupported OS: $os_name" >&2; exit 1 ;; - esac +esac case "$arch_name" in x86_64|amd64) arch="x64" ;; arm64|aarch64) arch="aarch64" ;; @@ -37,7 +45,7 @@ MAVEN_URL="https://archive.apache.org/dist/maven/maven-3/3.9.6/binaries/apache-m install_jdk() { local url="$1" dest_var="$2" local tmp="$TOOLS/jdk.tgz" - echo "Downloading JDK from $url" + log "Downloading JDK from $url" curl -fL "$url" -o "$tmp" local top top=$(tar -tzf "$tmp" 2>/dev/null | head -1 | cut -d/ -f1 || true) @@ -50,25 +58,35 @@ install_jdk() { eval "$dest_var=\"$home\"" } +log "Ensuring JDK 8 is available" if [ ! -x "${JAVA_HOME:-}/bin/java" ] || ! "${JAVA_HOME:-}/bin/java" -version 2>&1 | grep -q '1\.8'; then - echo "Provisioning JDK 8 (this may take a while)..." + log "Provisioning JDK 8 (this may take a while)..." install_jdk "$JDK8_URL" JAVA_HOME +else + log "Using existing JDK 8 at $JAVA_HOME" fi +log "Ensuring JDK 17 is available" if [ ! -x "${JAVA_HOME_17:-}/bin/java" ] || ! "${JAVA_HOME_17:-}/bin/java" -version 2>&1 | grep -q '17\.0'; then - echo "Provisioning JDK 17 (this may take a while)..." + log "Provisioning JDK 17 (this may take a while)..." install_jdk "$JDK17_URL" JAVA_HOME_17 +else + log "Using existing JDK 17 at $JAVA_HOME_17" fi +log "Ensuring Maven is available" if ! [ -x "${MAVEN_HOME:-}/bin/mvn" ]; then - echo "Downloading Maven from $MAVEN_URL" tmp="$TOOLS/maven.tgz" + log "Downloading Maven from $MAVEN_URL" curl -fL "$MAVEN_URL" -o "$tmp" tar -xzf "$tmp" -C "$TOOLS" rm "$tmp" MAVEN_HOME="$TOOLS/apache-maven-3.9.6" +else + log "Using existing Maven at $MAVEN_HOME" fi +log "Writing environment to $TOOLS/env.sh" cat > "$TOOLS/env.sh" < Date: Sun, 31 Aug 2025 04:05:24 +0300 Subject: [PATCH 3/7] Use JDK 11 for core builds and quiet port scripts --- BUILDING.md | 26 ++++++++++++-------------- scripts/build-android-port.sh | 10 +++++----- scripts/build-ios-port.sh | 8 ++++---- scripts/setup-workspace.sh | 30 ++++++++++++------------------ 4 files changed, 33 insertions(+), 41 deletions(-) diff --git a/BUILDING.md b/BUILDING.md index 002fd39f29..8541f89127 100644 --- a/BUILDING.md +++ b/BUILDING.md @@ -1,26 +1,25 @@ # Building Codename One -This guide provides reproducible steps to build Codename One locally with Maven, including its Android and iOS ports. +This guide explains how to build Codename One from source with Maven. It covers the core framework and the Android and iOS ports. ## Prerequisites -- **JDK 8** +- **JDK 11** - **JDK 17** for building the Android port - **Apache Maven 3.6+** - macOS with Xcode (required only for the iOS port) -The helper scripts in the `scripts/` directory download these dependencies when they are not already installed. On Apple Silicon -macOS machines, the scripts download the Intel JDK 8 and run it via Rosetta because an ARM build of JDK 8 is unavailable. +The helper scripts in the `scripts/` directory download these dependencies when they are not already installed. ### Installing JDKs on Linux Download binaries from [Adoptium](https://adoptium.net): ```bash -# JDK 8 (Linux x64; adjust `_x64_linux_` for your platform) -curl -L -o temurin8.tar.gz https://github.com/adoptium/temurin8-binaries/releases/download/jdk8u462-b08/OpenJDK8U-jdk_x64_linux_hotspot_8u462b08.tar.gz -tar xf temurin8.tar.gz -export JAVA_HOME=$PWD/jdk8u462-b08 +# JDK 11 (Linux x64; adjust `_x64_linux_` for your platform) +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 +tar xf temurin11.tar.gz +export JAVA_HOME=$PWD/jdk-11.0.28+6 # JDK 17 (Linux x64; adjust `_x64_linux_` for your platform) 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 @@ -32,7 +31,7 @@ export PATH="$JAVA_HOME/bin:$PATH" ## Preparing the workspace -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. +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. ```bash git clone https://github.com/codenameone/CodenameOne @@ -45,8 +44,7 @@ The script runs `mvn install` in `maven/`, installs `cn1-maven-archetypes`, and ## Building the Android port -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: +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: ```bash ./scripts/build-android-port.sh -DskipTests @@ -66,9 +64,9 @@ Artifacts are produced in `maven/ios/target`. ## Convenience scripts -- `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`. -- `build-android-port.sh` – builds the Android port using JDK 8 for Maven and JDK 17 for compilation. -- `build-ios-port.sh` – builds the iOS port on macOS with JDK 8. +- `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`. +- `build-android-port.sh` – builds the Android port using JDK 11 for Maven and JDK 17 for compilation. +- `build-ios-port.sh` – builds the iOS port on macOS with JDK 11. ## Further reading diff --git a/scripts/build-android-port.sh b/scripts/build-android-port.sh index 81b0e83d21..c12a88648c 100755 --- a/scripts/build-android-port.sh +++ b/scripts/build-android-port.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -# Build Codename One Android port using JDK 8 for Maven and JDK 17 for compilation +# Build Codename One Android port using JDK 11 for Maven and JDK 17 for compilation set -euo pipefail ROOT="$(cd "$(dirname "$0")/.." && pwd)" cd "$ROOT" @@ -11,12 +11,12 @@ else source "$ROOT/tools/env.sh" fi -if ! "${JAVA_HOME:-}/bin/java" -version 2>&1 | grep -q '1\.8'; then +if ! "${JAVA_HOME:-}/bin/java" -version 2>&1 | grep -q '11\.0'; then ./scripts/setup-workspace.sh -q -DskipTests source "$ROOT/tools/env.sh" fi -if ! "${JAVA_HOME:-}/bin/java" -version 2>&1 | grep -q '1\.8'; then - echo "Failed to provision JDK 8" >&2 +if ! "${JAVA_HOME:-}/bin/java" -version 2>&1 | grep -q '11\.0'; then + echo "Failed to provision JDK 11" >&2 exit 1 fi if ! "${JAVA_HOME_17:-}/bin/java" -version 2>&1 | grep -q '17\.0'; then @@ -40,4 +40,4 @@ if [ ! -f "$BUILD_CLIENT" ]; then fi fi -"$MAVEN_HOME/bin/mvn" -q -f maven/pom.xml -pl android -am -Dmaven.javadoc.skip=true clean install "$@" +"$MAVEN_HOME/bin/mvn" -q -f maven/pom.xml -pl android -am -Dmaven.javadoc.skip=true -Djava.awt.headless=true clean install "$@" diff --git a/scripts/build-ios-port.sh b/scripts/build-ios-port.sh index 8f1116c7c1..ded6e43fa6 100755 --- a/scripts/build-ios-port.sh +++ b/scripts/build-ios-port.sh @@ -17,12 +17,12 @@ else ./scripts/setup-workspace.sh -q -DskipTests source "$ROOT/tools/env.sh" fi -if ! "${JAVA_HOME:-}/bin/java" -version 2>&1 | grep -q '1\.8'; then +if ! "${JAVA_HOME:-}/bin/java" -version 2>&1 | grep -q '11\.0'; then ./scripts/setup-workspace.sh -q -DskipTests source "$ROOT/tools/env.sh" fi -if ! "${JAVA_HOME:-}/bin/java" -version 2>&1 | grep -q '1\.8'; then - echo "Failed to provision JDK 8" >&2 +if ! "${JAVA_HOME:-}/bin/java" -version 2>&1 | grep -q '11\.0'; then + echo "Failed to provision JDK 11" >&2 exit 1 fi export PATH="$JAVA_HOME/bin:$MAVEN_HOME/bin:$PATH" @@ -36,4 +36,4 @@ if [ ! -f "$BUILD_CLIENT" ]; then fi fi -"$MAVEN_HOME/bin/mvn" -q -f maven/pom.xml -pl ios -am clean install "$@" +"$MAVEN_HOME/bin/mvn" -q -f maven/pom.xml -pl ios -am -Djava.awt.headless=true clean install "$@" diff --git a/scripts/setup-workspace.sh b/scripts/setup-workspace.sh index 8de5d91979..e00683ec9d 100755 --- a/scripts/setup-workspace.sh +++ b/scripts/setup-workspace.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash ### -# Prepare Codename One workspace by installing Maven, provisioning JDK 8 and JDK 17, +# Prepare Codename One workspace by installing Maven, provisioning JDK 11 and JDK 17, # building core modules, and installing Maven archetypes. ### set -euo pipefail @@ -31,15 +31,9 @@ case "$arch_name" in *) echo "Unsupported architecture: $arch_name" >&2; exit 1 ;; esac -# JDK 8 is not available for Apple Silicon. Use the Intel build when running on macOS ARM. -jdk8_arch="$arch" -jdk17_arch="$arch" -if [ "$os" = "mac" ] && [ "$arch" = "aarch64" ]; then - jdk8_arch="x64" -fi - -JDK8_URL="https://github.com/adoptium/temurin8-binaries/releases/download/jdk8u462-b08/OpenJDK8U-jdk_${jdk8_arch}_${os}_hotspot_8u462b08.tar.gz" -JDK17_URL="https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.16%2B8/OpenJDK17U-jdk_${jdk17_arch}_${os}_hotspot_17.0.16_8.tar.gz" +# Determine platform-specific JDK download URLs +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" +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" MAVEN_URL="https://archive.apache.org/dist/maven/maven-3/3.9.6/binaries/apache-maven-3.9.6-bin.tar.gz" install_jdk() { @@ -58,12 +52,12 @@ install_jdk() { eval "$dest_var=\"$home\"" } -log "Ensuring JDK 8 is available" -if [ ! -x "${JAVA_HOME:-}/bin/java" ] || ! "${JAVA_HOME:-}/bin/java" -version 2>&1 | grep -q '1\.8'; then - log "Provisioning JDK 8 (this may take a while)..." - install_jdk "$JDK8_URL" JAVA_HOME +log "Ensuring JDK 11 is available" +if [ ! -x "${JAVA_HOME:-}/bin/java" ] || ! "${JAVA_HOME:-}/bin/java" -version 2>&1 | grep -q '11\.0'; then + log "Provisioning JDK 11 (this may take a while)..." + install_jdk "$JDK11_URL" JAVA_HOME else - log "Using existing JDK 8 at $JAVA_HOME" + log "Using existing JDK 11 at $JAVA_HOME" fi log "Ensuring JDK 17 is available" @@ -96,14 +90,14 @@ ENV source "$TOOLS/env.sh" -log "JDK 8 version:"; "$JAVA_HOME/bin/java" -version +log "JDK 11 version:"; "$JAVA_HOME/bin/java" -version log "JDK 17 version:"; "$JAVA_HOME_17/bin/java" -version log "Maven version:"; "$MAVEN_HOME/bin/mvn" -version PATH="$JAVA_HOME/bin:$MAVEN_HOME/bin:$PATH" log "Building Codename One core modules" -"$MAVEN_HOME/bin/mvn" -f maven/pom.xml -DskipTests install "$@" +"$MAVEN_HOME/bin/mvn" -q -f maven/pom.xml -DskipTests -Djava.awt.headless=true install "$@" BUILD_CLIENT="$HOME/.codenameone/CodeNameOneBuildClient.jar" log "Ensuring CodeNameOneBuildClient.jar is installed" @@ -119,4 +113,4 @@ log "Installing cn1-maven-archetypes" if [ ! -d cn1-maven-archetypes ]; then git clone https://github.com/shannah/cn1-maven-archetypes fi -(cd cn1-maven-archetypes && "$MAVEN_HOME/bin/mvn" -DskipTests -Dinvoker.skip=true install) +(cd cn1-maven-archetypes && "$MAVEN_HOME/bin/mvn" -q -DskipTests -DskipITs=true -Dinvoker.skip=true install) From 2d4242d350b37f9c65518c49dded482c728d4ad2 Mon Sep 17 00:00:00 2001 From: Shai Almog <67850168+shai-almog@users.noreply.github.com> Date: Sun, 31 Aug 2025 04:16:01 +0300 Subject: [PATCH 4/7] Use JDK 8 for core builds --- BUILDING.md | 22 +++++++++++----------- scripts/build-android-port.sh | 8 ++++---- scripts/build-ios-port.sh | 6 +++--- scripts/setup-workspace.sh | 20 ++++++++++++-------- 4 files changed, 30 insertions(+), 26 deletions(-) diff --git a/BUILDING.md b/BUILDING.md index 8541f89127..5ae0f33d7f 100644 --- a/BUILDING.md +++ b/BUILDING.md @@ -1,10 +1,10 @@ # Building Codename One -This guide explains how to build Codename One from source with Maven. It covers the core framework and the Android and iOS ports. +This guide explains how to build Codename One from source using Maven. It provides reproducible steps to compile the core framework and its Android and iOS ports. ## Prerequisites -- **JDK 11** +- **JDK 8** - **JDK 17** for building the Android port - **Apache Maven 3.6+** - macOS with Xcode (required only for the iOS port) @@ -16,10 +16,10 @@ The helper scripts in the `scripts/` directory download these dependencies when Download binaries from [Adoptium](https://adoptium.net): ```bash -# JDK 11 (Linux x64; adjust `_x64_linux_` for your platform) -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 -tar xf temurin11.tar.gz -export JAVA_HOME=$PWD/jdk-11.0.28+6 +# JDK 8 (Linux x64; adjust `_x64_linux_` for your platform) +curl -L -o temurin8.tar.gz https://github.com/adoptium/temurin8-binaries/releases/download/jdk8u462-b08/OpenJDK8U-jdk_x64_linux_hotspot_8u462b08.tar.gz +tar xf temurin8.tar.gz +export JAVA_HOME=$PWD/jdk8u462-b08 # JDK 17 (Linux x64; adjust `_x64_linux_` for your platform) 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" ## Preparing the workspace -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. +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. ```bash git clone https://github.com/codenameone/CodenameOne @@ -44,7 +44,7 @@ The script runs `mvn install` in `maven/`, installs `cn1-maven-archetypes`, and ## Building the Android port -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: +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: ```bash ./scripts/build-android-port.sh -DskipTests @@ -64,9 +64,9 @@ Artifacts are produced in `maven/ios/target`. ## Convenience scripts -- `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`. -- `build-android-port.sh` – builds the Android port using JDK 11 for Maven and JDK 17 for compilation. -- `build-ios-port.sh` – builds the iOS port on macOS with JDK 11. +- `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`. +- `build-android-port.sh` – builds the Android port using JDK 8 for Maven and JDK 17 for compilation. +- `build-ios-port.sh` – builds the iOS port on macOS with JDK 8. ## Further reading diff --git a/scripts/build-android-port.sh b/scripts/build-android-port.sh index c12a88648c..919886d098 100755 --- a/scripts/build-android-port.sh +++ b/scripts/build-android-port.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -# Build Codename One Android port using JDK 11 for Maven and JDK 17 for compilation +# Build Codename One Android port using JDK 8 for Maven and JDK 17 for compilation set -euo pipefail ROOT="$(cd "$(dirname "$0")/.." && pwd)" cd "$ROOT" @@ -11,12 +11,12 @@ else source "$ROOT/tools/env.sh" fi -if ! "${JAVA_HOME:-}/bin/java" -version 2>&1 | grep -q '11\.0'; then +if ! "${JAVA_HOME:-}/bin/java" -version 2>&1 | grep -q '1\.8\.0'; then ./scripts/setup-workspace.sh -q -DskipTests source "$ROOT/tools/env.sh" fi -if ! "${JAVA_HOME:-}/bin/java" -version 2>&1 | grep -q '11\.0'; then - echo "Failed to provision JDK 11" >&2 +if ! "${JAVA_HOME:-}/bin/java" -version 2>&1 | grep -q '1\.8\.0'; then + echo "Failed to provision JDK 8" >&2 exit 1 fi if ! "${JAVA_HOME_17:-}/bin/java" -version 2>&1 | grep -q '17\.0'; then diff --git a/scripts/build-ios-port.sh b/scripts/build-ios-port.sh index ded6e43fa6..f25744c6f6 100755 --- a/scripts/build-ios-port.sh +++ b/scripts/build-ios-port.sh @@ -17,12 +17,12 @@ else ./scripts/setup-workspace.sh -q -DskipTests source "$ROOT/tools/env.sh" fi -if ! "${JAVA_HOME:-}/bin/java" -version 2>&1 | grep -q '11\.0'; then +if ! "${JAVA_HOME:-}/bin/java" -version 2>&1 | grep -q '1\.8\.0'; then ./scripts/setup-workspace.sh -q -DskipTests source "$ROOT/tools/env.sh" fi -if ! "${JAVA_HOME:-}/bin/java" -version 2>&1 | grep -q '11\.0'; then - echo "Failed to provision JDK 11" >&2 +if ! "${JAVA_HOME:-}/bin/java" -version 2>&1 | grep -q '1\.8\.0'; then + echo "Failed to provision JDK 8" >&2 exit 1 fi export PATH="$JAVA_HOME/bin:$MAVEN_HOME/bin:$PATH" diff --git a/scripts/setup-workspace.sh b/scripts/setup-workspace.sh index e00683ec9d..5b6b973861 100755 --- a/scripts/setup-workspace.sh +++ b/scripts/setup-workspace.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash ### -# Prepare Codename One workspace by installing Maven, provisioning JDK 11 and JDK 17, +# Prepare Codename One workspace by installing Maven, provisioning JDK 8 and JDK 17, # building core modules, and installing Maven archetypes. ### set -euo pipefail @@ -32,7 +32,11 @@ case "$arch_name" in esac # Determine platform-specific JDK download URLs -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" +arch_jdk8="$arch" +if [ "$os" = "mac" ] && [ "$arch" = "aarch64" ]; then + arch_jdk8="x64" +fi +JDK8_URL="https://github.com/adoptium/temurin8-binaries/releases/download/jdk8u462-b08/OpenJDK8U-jdk_${arch_jdk8}_${os}_hotspot_8u462b08.tar.gz" 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" MAVEN_URL="https://archive.apache.org/dist/maven/maven-3/3.9.6/binaries/apache-maven-3.9.6-bin.tar.gz" @@ -52,12 +56,12 @@ install_jdk() { eval "$dest_var=\"$home\"" } -log "Ensuring JDK 11 is available" -if [ ! -x "${JAVA_HOME:-}/bin/java" ] || ! "${JAVA_HOME:-}/bin/java" -version 2>&1 | grep -q '11\.0'; then - log "Provisioning JDK 11 (this may take a while)..." - install_jdk "$JDK11_URL" JAVA_HOME +log "Ensuring JDK 8 is available" +if [ ! -x "${JAVA_HOME:-}/bin/java" ] || ! "${JAVA_HOME:-}/bin/java" -version 2>&1 | grep -q '1\.8\.0'; then + log "Provisioning JDK 8 (this may take a while)..." + install_jdk "$JDK8_URL" JAVA_HOME else - log "Using existing JDK 11 at $JAVA_HOME" + log "Using existing JDK 8 at $JAVA_HOME" fi log "Ensuring JDK 17 is available" @@ -90,7 +94,7 @@ ENV source "$TOOLS/env.sh" -log "JDK 11 version:"; "$JAVA_HOME/bin/java" -version +log "JDK 8 version:"; "$JAVA_HOME/bin/java" -version log "JDK 17 version:"; "$JAVA_HOME_17/bin/java" -version log "Maven version:"; "$MAVEN_HOME/bin/mvn" -version From 74fb665aa7a8342bec290ffffdb652b3e7eadf86 Mon Sep 17 00:00:00 2001 From: Shai Almog <67850168+shai-almog@users.noreply.github.com> Date: Sun, 31 Aug 2025 04:35:31 +0300 Subject: [PATCH 5/7] Use temporary tool cache --- BUILDING.md | 22 ++++++++--------- scripts/build-android-port.sh | 8 +++--- scripts/build-ios-port.sh | 6 ++--- scripts/setup-workspace.sh | 46 +++++++++++++++++++---------------- 4 files changed, 43 insertions(+), 39 deletions(-) diff --git a/BUILDING.md b/BUILDING.md index 5ae0f33d7f..1e504c91fd 100644 --- a/BUILDING.md +++ b/BUILDING.md @@ -4,7 +4,7 @@ This guide explains how to build Codename One from source using Maven. It provid ## Prerequisites -- **JDK 8** +- **JDK 11** - **JDK 17** for building the Android port - **Apache Maven 3.6+** - macOS with Xcode (required only for the iOS port) @@ -16,10 +16,10 @@ The helper scripts in the `scripts/` directory download these dependencies when Download binaries from [Adoptium](https://adoptium.net): ```bash -# JDK 8 (Linux x64; adjust `_x64_linux_` for your platform) -curl -L -o temurin8.tar.gz https://github.com/adoptium/temurin8-binaries/releases/download/jdk8u462-b08/OpenJDK8U-jdk_x64_linux_hotspot_8u462b08.tar.gz -tar xf temurin8.tar.gz -export JAVA_HOME=$PWD/jdk8u462-b08 +# JDK 11 (Linux x64; adjust `_x64_linux_` for your platform) +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 +tar xf temurin11.tar.gz +export JAVA_HOME=$PWD/jdk-11.0.28+6 # JDK 17 (Linux x64; adjust `_x64_linux_` for your platform) 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" ## Preparing the workspace -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. +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. ```bash git clone https://github.com/codenameone/CodenameOne @@ -40,11 +40,11 @@ cd CodenameOne source tools/env.sh ``` -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. +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. ## Building the Android port -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: +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: ```bash ./scripts/build-android-port.sh -DskipTests @@ -64,9 +64,9 @@ Artifacts are produced in `maven/ios/target`. ## Convenience scripts -- `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`. -- `build-android-port.sh` – builds the Android port using JDK 8 for Maven and JDK 17 for compilation. -- `build-ios-port.sh` – builds the iOS port on macOS with JDK 8. +- `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`. +- `build-android-port.sh` – builds the Android port using JDK 11 for Maven and JDK 17 for compilation. +- `build-ios-port.sh` – builds the iOS port on macOS with JDK 11. ## Further reading diff --git a/scripts/build-android-port.sh b/scripts/build-android-port.sh index 919886d098..c12a88648c 100755 --- a/scripts/build-android-port.sh +++ b/scripts/build-android-port.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -# Build Codename One Android port using JDK 8 for Maven and JDK 17 for compilation +# Build Codename One Android port using JDK 11 for Maven and JDK 17 for compilation set -euo pipefail ROOT="$(cd "$(dirname "$0")/.." && pwd)" cd "$ROOT" @@ -11,12 +11,12 @@ else source "$ROOT/tools/env.sh" fi -if ! "${JAVA_HOME:-}/bin/java" -version 2>&1 | grep -q '1\.8\.0'; then +if ! "${JAVA_HOME:-}/bin/java" -version 2>&1 | grep -q '11\.0'; then ./scripts/setup-workspace.sh -q -DskipTests source "$ROOT/tools/env.sh" fi -if ! "${JAVA_HOME:-}/bin/java" -version 2>&1 | grep -q '1\.8\.0'; then - echo "Failed to provision JDK 8" >&2 +if ! "${JAVA_HOME:-}/bin/java" -version 2>&1 | grep -q '11\.0'; then + echo "Failed to provision JDK 11" >&2 exit 1 fi if ! "${JAVA_HOME_17:-}/bin/java" -version 2>&1 | grep -q '17\.0'; then diff --git a/scripts/build-ios-port.sh b/scripts/build-ios-port.sh index f25744c6f6..ded6e43fa6 100755 --- a/scripts/build-ios-port.sh +++ b/scripts/build-ios-port.sh @@ -17,12 +17,12 @@ else ./scripts/setup-workspace.sh -q -DskipTests source "$ROOT/tools/env.sh" fi -if ! "${JAVA_HOME:-}/bin/java" -version 2>&1 | grep -q '1\.8\.0'; then +if ! "${JAVA_HOME:-}/bin/java" -version 2>&1 | grep -q '11\.0'; then ./scripts/setup-workspace.sh -q -DskipTests source "$ROOT/tools/env.sh" fi -if ! "${JAVA_HOME:-}/bin/java" -version 2>&1 | grep -q '1\.8\.0'; then - echo "Failed to provision JDK 8" >&2 +if ! "${JAVA_HOME:-}/bin/java" -version 2>&1 | grep -q '11\.0'; then + echo "Failed to provision JDK 11" >&2 exit 1 fi export PATH="$JAVA_HOME/bin:$MAVEN_HOME/bin:$PATH" diff --git a/scripts/setup-workspace.sh b/scripts/setup-workspace.sh index 5b6b973861..0c180b2ff6 100755 --- a/scripts/setup-workspace.sh +++ b/scripts/setup-workspace.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash ### -# Prepare Codename One workspace by installing Maven, provisioning JDK 8 and JDK 17, +# Prepare Codename One workspace by installing Maven, provisioning JDK 11 and JDK 17, # building core modules, and installing Maven archetypes. ### set -euo pipefail @@ -10,8 +10,12 @@ log() { } ROOT="$(cd "$(dirname "$0")/.." && pwd)" -TOOLS="$ROOT/tools" -mkdir -p "$TOOLS" +ENV_DIR="$ROOT/tools" +mkdir -p "$ENV_DIR" + +# Place downloaded tools outside the repository so it isn't filled with binaries +DOWNLOAD_DIR="${TMPDIR:-/tmp}/codenameone-tools" +mkdir -p "$DOWNLOAD_DIR" JAVA_HOME="${JAVA_HOME:-}" JAVA_HOME_17="${JAVA_HOME_17:-}" @@ -32,36 +36,36 @@ case "$arch_name" in esac # Determine platform-specific JDK download URLs -arch_jdk8="$arch" +arch_jdk11="$arch" if [ "$os" = "mac" ] && [ "$arch" = "aarch64" ]; then - arch_jdk8="x64" + arch_jdk11="x64" fi -JDK8_URL="https://github.com/adoptium/temurin8-binaries/releases/download/jdk8u462-b08/OpenJDK8U-jdk_${arch_jdk8}_${os}_hotspot_8u462b08.tar.gz" +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" 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" MAVEN_URL="https://archive.apache.org/dist/maven/maven-3/3.9.6/binaries/apache-maven-3.9.6-bin.tar.gz" install_jdk() { local url="$1" dest_var="$2" - local tmp="$TOOLS/jdk.tgz" + local tmp="$DOWNLOAD_DIR/jdk.tgz" log "Downloading JDK from $url" curl -fL "$url" -o "$tmp" local top top=$(tar -tzf "$tmp" 2>/dev/null | head -1 | cut -d/ -f1 || true) - tar -xzf "$tmp" -C "$TOOLS" + tar -xzf "$tmp" -C "$DOWNLOAD_DIR" rm "$tmp" - local home="$TOOLS/$top" + local home="$DOWNLOAD_DIR/$top" if [ -d "$home/Contents/Home" ]; then home="$home/Contents/Home" fi eval "$dest_var=\"$home\"" } -log "Ensuring JDK 8 is available" -if [ ! -x "${JAVA_HOME:-}/bin/java" ] || ! "${JAVA_HOME:-}/bin/java" -version 2>&1 | grep -q '1\.8\.0'; then - log "Provisioning JDK 8 (this may take a while)..." - install_jdk "$JDK8_URL" JAVA_HOME +log "Ensuring JDK 11 is available" +if [ ! -x "${JAVA_HOME:-}/bin/java" ] || ! "${JAVA_HOME:-}/bin/java" -version 2>&1 | grep -q '11\.0'; then + log "Provisioning JDK 11 (this may take a while)..." + install_jdk "$JDK11_URL" JAVA_HOME else - log "Using existing JDK 8 at $JAVA_HOME" + log "Using existing JDK 11 at $JAVA_HOME" fi log "Ensuring JDK 17 is available" @@ -74,27 +78,27 @@ fi log "Ensuring Maven is available" if ! [ -x "${MAVEN_HOME:-}/bin/mvn" ]; then - tmp="$TOOLS/maven.tgz" + tmp="$DOWNLOAD_DIR/maven.tgz" log "Downloading Maven from $MAVEN_URL" curl -fL "$MAVEN_URL" -o "$tmp" - tar -xzf "$tmp" -C "$TOOLS" + tar -xzf "$tmp" -C "$DOWNLOAD_DIR" rm "$tmp" - MAVEN_HOME="$TOOLS/apache-maven-3.9.6" + MAVEN_HOME="$DOWNLOAD_DIR/apache-maven-3.9.6" else log "Using existing Maven at $MAVEN_HOME" fi -log "Writing environment to $TOOLS/env.sh" -cat > "$TOOLS/env.sh" < "$ENV_DIR/env.sh" < Date: Sun, 31 Aug 2025 04:47:53 +0300 Subject: [PATCH 6/7] chore: ignore tools artifacts --- .gitignore | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 651ab100ba..a78f5bd1de 100644 --- a/.gitignore +++ b/.gitignore @@ -69,4 +69,6 @@ target pom.xml.versionsBackup pom.xml.releaseBackup pom.xml.tag -!maven/**/*.zip \ No newline at end of file +!maven/**/*.zip +/tools/ +tools.sh From 4d096f88087346e75c79f8ad89edc605bd37771e Mon Sep 17 00:00:00 2001 From: Shai Almog <67850168+shai-almog@users.noreply.github.com> Date: Mon, 1 Sep 2025 08:02:15 +0300 Subject: [PATCH 7/7] Fixed CI build to use JDK 8 and compilation nuances --- scripts/setup-workspace.sh | 21 ++++++++++--------- .../src/java/io/ByteArrayOutputStream.java | 8 ++++++- .../src/java/text/SimpleDateFormat.java | 6 +++--- 3 files changed, 21 insertions(+), 14 deletions(-) diff --git a/scripts/setup-workspace.sh b/scripts/setup-workspace.sh index 0c180b2ff6..30779f0ec8 100755 --- a/scripts/setup-workspace.sh +++ b/scripts/setup-workspace.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash ### -# Prepare Codename One workspace by installing Maven, provisioning JDK 11 and JDK 17, +# Prepare Codename One workspace by installing Maven, provisioning JDK 8 and JDK 17, # building core modules, and installing Maven archetypes. ### set -euo pipefail @@ -36,11 +36,12 @@ case "$arch_name" in esac # Determine platform-specific JDK download URLs -arch_jdk11="$arch" +arch_jdk8="$arch" if [ "$os" = "mac" ] && [ "$arch" = "aarch64" ]; then - arch_jdk11="x64" + arch_jdk8="x64" fi -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" + +JDK8_URL="https://github.com/adoptium/temurin8-binaries/releases/download/jdk8u462-b08/OpenJDK8U-jdk_${arch_jdk8}_${os}_hotspot_8u462b08.tar.gz" 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" MAVEN_URL="https://archive.apache.org/dist/maven/maven-3/3.9.6/binaries/apache-maven-3.9.6-bin.tar.gz" @@ -60,12 +61,12 @@ install_jdk() { eval "$dest_var=\"$home\"" } -log "Ensuring JDK 11 is available" -if [ ! -x "${JAVA_HOME:-}/bin/java" ] || ! "${JAVA_HOME:-}/bin/java" -version 2>&1 | grep -q '11\.0'; then - log "Provisioning JDK 11 (this may take a while)..." - install_jdk "$JDK11_URL" JAVA_HOME +log "Ensuring JDK 8 is available" +if [ ! -x "${JAVA_HOME:-}/bin/java" ] || ! "${JAVA_HOME:-}/bin/java" -version 2>&1 | grep -q '8\.0'; then + log "Provisioning JDK 8 (this may take a while)..." + install_jdk "$JDK8_URL" JAVA_HOME else - log "Using existing JDK 11 at $JAVA_HOME" + log "Using existing JDK 8 at $JAVA_HOME" fi log "Ensuring JDK 17 is available" @@ -98,7 +99,7 @@ ENV source "$ENV_DIR/env.sh" -log "JDK 11 version:"; "$JAVA_HOME/bin/java" -version +log "JDK 8 version:"; "$JAVA_HOME/bin/java" -version log "JDK 17 version:"; "$JAVA_HOME_17/bin/java" -version log "Maven version:"; "$MAVEN_HOME/bin/mvn" -version diff --git a/vm/JavaAPI/src/java/io/ByteArrayOutputStream.java b/vm/JavaAPI/src/java/io/ByteArrayOutputStream.java index a2dd041308..df13365ba3 100644 --- a/vm/JavaAPI/src/java/io/ByteArrayOutputStream.java +++ b/vm/JavaAPI/src/java/io/ByteArrayOutputStream.java @@ -192,7 +192,7 @@ public String toString(String charsetName) throws UnsupportedEncodingException { */ @Override public synchronized void write(byte[] buffer, int offset, int len) { - Arrays.checkOffsetAndCount(buffer.length, offset, len); + checkOffsetAndCount(buffer.length, offset, len); if (len == 0) { return; } @@ -201,6 +201,12 @@ public synchronized void write(byte[] buffer, int offset, int len) { this.count += len; } + static void checkOffsetAndCount(int arrayLength, int offset, int count) { + if ((offset | count) < 0 || offset > arrayLength || arrayLength - offset < count) { + throw new ArrayIndexOutOfBoundsException(offset); + } + } + /** * Writes the specified byte {@code oneByte} to the OutputStream. Only the * low order byte of {@code oneByte} is written. diff --git a/vm/JavaAPI/src/java/text/SimpleDateFormat.java b/vm/JavaAPI/src/java/text/SimpleDateFormat.java index 46e9c519a4..49f9b69cca 100644 --- a/vm/JavaAPI/src/java/text/SimpleDateFormat.java +++ b/vm/JavaAPI/src/java/text/SimpleDateFormat.java @@ -315,7 +315,7 @@ String format(Date source, StringBuffer toAppendTo) { if (names == null) { toAppendTo.append(calendar.getTimeZone().getID()); } else { - toAppendTo.append(names[DateFormatSymbols.ZONE_SHORTNAME]); + toAppendTo.append(names[2 /*DateFormatSymbols.ZONE_SHORTNAME */]); } break; case TIMEZONE822_LETTER : @@ -398,7 +398,7 @@ String format(Date source, StringBuffer toAppendTo) { private String[] getTimeZoneDisplayNames(String id) { for (String zoneStrings[] : getDateFormatSymbols().getZoneStrings()) { - if (zoneStrings[DateFormatSymbols.ZONE_ID].equalsIgnoreCase(id)) { + if (zoneStrings[0 /*DateFormatSymbols.ZONE_ID*/].equalsIgnoreCase(id)) { return zoneStrings; } } @@ -926,7 +926,7 @@ int parseTimeZone(String source, int ofs) throws ParseException { for (String timezone[] : getDateFormatSymbols().getZoneStrings()) { for (String z : timezone) { if (z.equalsIgnoreCase(source)) { - TimeZone tz = TimeZone.getTimeZone(timezone[DateFormatSymbols.ZONE_ID]); + TimeZone tz = TimeZone.getTimeZone(timezone[0 /*DateFormatSymbols.ZONE_ID*/]); return -(tz.getRawOffset() / MILLIS_TO_MINUTES); } }