Skip to content

Commit f2591f5

Browse files
committed
Skip archetype integration tests during workspace setup
1 parent 6ce1275 commit f2591f5

File tree

7 files changed

+322
-1
lines changed

7 files changed

+322
-1
lines changed

.github/workflows/pr.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
11
name: PR CI
22

3-
on:
3+
on:
44
pull_request:
55
branches:
66
- master
7+
paths-ignore:
8+
- 'scripts/**'
9+
- '**/*.md'
710
push:
811
branches:
912
- master
13+
paths-ignore:
14+
- 'scripts/**'
15+
- '**/*.md'
1016

1117
jobs:
1218
build-linux-jdk8-fx:
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
---
2+
name: Test Android build scripts
3+
4+
'on':
5+
pull_request:
6+
paths:
7+
- 'scripts/**'
8+
- 'BUILDING.md'
9+
push:
10+
branches:
11+
- master
12+
paths:
13+
- 'scripts/**'
14+
- 'BUILDING.md'
15+
16+
jobs:
17+
build-android:
18+
runs-on: ubuntu-latest
19+
steps:
20+
- uses: actions/checkout@v4
21+
- name: Setup workspace
22+
run: ./scripts/setup-workspace.sh -q -DskipTests
23+
- name: Build Android port
24+
run: |
25+
source tools/env.sh
26+
echo "JAVA_HOME=$JAVA_HOME"
27+
java -version
28+
echo "JAVA_HOME_17=$JAVA_HOME_17"
29+
"$JAVA_HOME_17/bin/java" -version
30+
./scripts/build-android-port.sh -q -DskipTests

.github/workflows/scripts-ios.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
---
2+
name: Test iOS build scripts
3+
4+
'on':
5+
pull_request:
6+
paths:
7+
- 'scripts/**'
8+
- 'BUILDING.md'
9+
push:
10+
branches:
11+
- master
12+
paths:
13+
- 'scripts/**'
14+
- 'BUILDING.md'
15+
16+
jobs:
17+
build-ios:
18+
runs-on: macos-latest
19+
steps:
20+
- uses: actions/checkout@v4
21+
- name: Setup workspace
22+
run: ./scripts/setup-workspace.sh -q -DskipTests
23+
- name: Build iOS port
24+
run: |
25+
source tools/env.sh
26+
echo "JAVA_HOME=$JAVA_HOME"
27+
java -version
28+
./scripts/build-ios-port.sh -q -DskipTests

BUILDING.md

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# Building Codename One
2+
3+
This guide provides reproducible steps to build Codename One locally with Maven, including its Android and iOS ports.
4+
5+
## Prerequisites
6+
7+
- **JDK 8**
8+
- **JDK 17** for building the Android port
9+
- **Apache Maven 3.6+**
10+
- macOS with Xcode (required only for the iOS port)
11+
12+
The helper scripts in the `scripts/` directory download these dependencies when they are not already installed. On Apple Silicon
13+
macOS machines, the scripts download the Intel JDK 8 and run it via Rosetta because an ARM build of JDK 8 is unavailable.
14+
15+
### Installing JDKs on Linux
16+
17+
Download binaries from [Adoptium](https://adoptium.net):
18+
19+
```bash
20+
# JDK 8 (Linux x64; adjust `_x64_linux_` for your platform)
21+
curl -L -o temurin8.tar.gz https://github.com/adoptium/temurin8-binaries/releases/download/jdk8u462-b08/OpenJDK8U-jdk_x64_linux_hotspot_8u462b08.tar.gz
22+
tar xf temurin8.tar.gz
23+
export JAVA_HOME=$PWD/jdk8u462-b08
24+
25+
# JDK 17 (Linux x64; adjust `_x64_linux_` for your platform)
26+
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
27+
tar xf temurin17.tar.gz
28+
export JAVA_HOME_17=$PWD/jdk-17.0.16+8
29+
30+
export PATH="$JAVA_HOME/bin:$PATH"
31+
```
32+
33+
## Preparing the workspace
34+
35+
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.
36+
37+
```bash
38+
git clone https://github.com/codenameone/CodenameOne
39+
cd CodenameOne
40+
./scripts/setup-workspace.sh -DskipTests
41+
source tools/env.sh
42+
```
43+
44+
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.
45+
46+
## Building the Android port
47+
48+
The Android port uses JDK 17 for compilation while Maven runs with JDK 8. Javadoc generation is skipped to avoid known Maven
49+
report issues. Run the build script:
50+
51+
```bash
52+
./scripts/build-android-port.sh -DskipTests
53+
```
54+
55+
Artifacts are placed in `maven/android/target`.
56+
57+
## Building the iOS port
58+
59+
The iOS port can only be built on macOS with Xcode installed. Run the iOS script:
60+
61+
```bash
62+
./scripts/build-ios-port.sh -DskipTests
63+
```
64+
65+
Artifacts are produced in `maven/ios/target`.
66+
67+
## Convenience scripts
68+
69+
- `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`.
70+
- `build-android-port.sh` – builds the Android port using JDK 8 for Maven and JDK 17 for compilation.
71+
- `build-ios-port.sh` – builds the iOS port on macOS with JDK 8.
72+
73+
## Further reading
74+
75+
- Blog post: <https://www.codenameone.com/blog/building-codename-one-from-source-maven-edition.html>
76+
- Maven developers guide: <https://shannah.github.io/codenameone-maven-manual/>

scripts/build-android-port.sh

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#!/usr/bin/env bash
2+
# Build Codename One Android port using JDK 8 for Maven and JDK 17 for compilation
3+
set -euo pipefail
4+
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
5+
cd "$ROOT"
6+
7+
if [ -f "$ROOT/tools/env.sh" ]; then
8+
source "$ROOT/tools/env.sh"
9+
else
10+
./scripts/setup-workspace.sh -q -DskipTests
11+
source "$ROOT/tools/env.sh"
12+
fi
13+
14+
if ! "${JAVA_HOME:-}/bin/java" -version 2>&1 | grep -q '1\.8'; then
15+
./scripts/setup-workspace.sh -q -DskipTests
16+
source "$ROOT/tools/env.sh"
17+
fi
18+
if ! "${JAVA_HOME:-}/bin/java" -version 2>&1 | grep -q '1\.8'; then
19+
echo "Failed to provision JDK 8" >&2
20+
exit 1
21+
fi
22+
if ! "${JAVA_HOME_17:-}/bin/java" -version 2>&1 | grep -q '17\.0'; then
23+
./scripts/setup-workspace.sh -q -DskipTests
24+
source "$ROOT/tools/env.sh"
25+
fi
26+
if ! "${JAVA_HOME_17:-}/bin/java" -version 2>&1 | grep -q '17\.0'; then
27+
echo "Failed to provision JDK 17" >&2
28+
exit 1
29+
fi
30+
31+
export PATH="$JAVA_HOME/bin:$MAVEN_HOME/bin:$PATH"
32+
"$JAVA_HOME/bin/java" -version
33+
"$JAVA_HOME_17/bin/java" -version
34+
"$MAVEN_HOME/bin/mvn" -version
35+
36+
BUILD_CLIENT="$HOME/.codenameone/CodeNameOneBuildClient.jar"
37+
if [ ! -f "$BUILD_CLIENT" ]; then
38+
if ! "$MAVEN_HOME/bin/mvn" -q -f maven/pom.xml cn1:install-codenameone "$@"; then
39+
[ -f maven/CodeNameOneBuildClient.jar ] && cp maven/CodeNameOneBuildClient.jar "$BUILD_CLIENT" || true
40+
fi
41+
fi
42+
43+
"$MAVEN_HOME/bin/mvn" -q -f maven/pom.xml -pl android -am -Dmaven.javadoc.skip=true clean install "$@"

scripts/build-ios-port.sh

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#!/usr/bin/env bash
2+
# Build Codename One iOS port (macOS only)
3+
set -euo pipefail
4+
if [[ "$(uname)" != "Darwin" ]]; then
5+
echo "The iOS port can only be built on macOS with Xcode installed." >&2
6+
exit 1
7+
fi
8+
if ! command -v xcodebuild >/dev/null; then
9+
echo "Xcode command-line tools not found." >&2
10+
exit 1
11+
fi
12+
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
13+
cd "$ROOT"
14+
if [ -f "$ROOT/tools/env.sh" ]; then
15+
source "$ROOT/tools/env.sh"
16+
else
17+
./scripts/setup-workspace.sh -q -DskipTests
18+
source "$ROOT/tools/env.sh"
19+
fi
20+
if ! "${JAVA_HOME:-}/bin/java" -version 2>&1 | grep -q '1\.8'; then
21+
./scripts/setup-workspace.sh -q -DskipTests
22+
source "$ROOT/tools/env.sh"
23+
fi
24+
if ! "${JAVA_HOME:-}/bin/java" -version 2>&1 | grep -q '1\.8'; then
25+
echo "Failed to provision JDK 8" >&2
26+
exit 1
27+
fi
28+
export PATH="$JAVA_HOME/bin:$MAVEN_HOME/bin:$PATH"
29+
"$JAVA_HOME/bin/java" -version
30+
"$MAVEN_HOME/bin/mvn" -version
31+
32+
BUILD_CLIENT="$HOME/.codenameone/CodeNameOneBuildClient.jar"
33+
if [ ! -f "$BUILD_CLIENT" ]; then
34+
if ! "$MAVEN_HOME/bin/mvn" -q -f maven/pom.xml cn1:install-codenameone "$@"; then
35+
[ -f maven/CodeNameOneBuildClient.jar ] && cp maven/CodeNameOneBuildClient.jar "$BUILD_CLIENT" || true
36+
fi
37+
fi
38+
39+
"$MAVEN_HOME/bin/mvn" -q -f maven/pom.xml -pl ios -am clean install "$@"

scripts/setup-workspace.sh

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
#!/usr/bin/env bash
2+
# Prepare Codename One workspace by installing Maven, provisioning JDK 8 and JDK 17,
3+
# building core modules, and installing Maven archetypes.
4+
set -euo pipefail
5+
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
6+
TOOLS="$ROOT/tools"
7+
mkdir -p "$TOOLS"
8+
9+
JAVA_HOME="${JAVA_HOME:-}"
10+
JAVA_HOME_17="${JAVA_HOME_17:-}"
11+
MAVEN_HOME="${MAVEN_HOME:-}"
12+
13+
os_name=$(uname -s)
14+
arch_name=$(uname -m)
15+
case "$os_name" in
16+
Linux) os="linux" ;;
17+
Darwin) os="mac" ;;
18+
*) echo "Unsupported OS: $os_name" >&2; exit 1 ;;
19+
esac
20+
case "$arch_name" in
21+
x86_64|amd64) arch="x64" ;;
22+
arm64|aarch64) arch="aarch64" ;;
23+
*) echo "Unsupported architecture: $arch_name" >&2; exit 1 ;;
24+
esac
25+
26+
# JDK 8 is not available for Apple Silicon. Use the Intel build when running on macOS ARM.
27+
jdk8_arch="$arch"
28+
jdk17_arch="$arch"
29+
if [ "$os" = "mac" ] && [ "$arch" = "aarch64" ]; then
30+
jdk8_arch="x64"
31+
fi
32+
33+
JDK8_URL="https://github.com/adoptium/temurin8-binaries/releases/download/jdk8u462-b08/OpenJDK8U-jdk_${jdk8_arch}_${os}_hotspot_8u462b08.tar.gz"
34+
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"
35+
MAVEN_URL="https://archive.apache.org/dist/maven/maven-3/3.9.6/binaries/apache-maven-3.9.6-bin.tar.gz"
36+
37+
install_jdk() {
38+
local url="$1" dest_var="$2"
39+
local tmp="$TOOLS/jdk.tgz"
40+
echo "Downloading JDK from $url"
41+
curl -fL "$url" -o "$tmp"
42+
local top
43+
top=$(tar -tzf "$tmp" 2>/dev/null | head -1 | cut -d/ -f1 || true)
44+
tar -xzf "$tmp" -C "$TOOLS"
45+
rm "$tmp"
46+
local home="$TOOLS/$top"
47+
if [ -d "$home/Contents/Home" ]; then
48+
home="$home/Contents/Home"
49+
fi
50+
eval "$dest_var=\"$home\""
51+
}
52+
53+
if [ ! -x "${JAVA_HOME:-}/bin/java" ] || ! "${JAVA_HOME:-}/bin/java" -version 2>&1 | grep -q '1\.8'; then
54+
echo "Provisioning JDK 8 (this may take a while)..."
55+
install_jdk "$JDK8_URL" JAVA_HOME
56+
fi
57+
58+
if [ ! -x "${JAVA_HOME_17:-}/bin/java" ] || ! "${JAVA_HOME_17:-}/bin/java" -version 2>&1 | grep -q '17\.0'; then
59+
echo "Provisioning JDK 17 (this may take a while)..."
60+
install_jdk "$JDK17_URL" JAVA_HOME_17
61+
fi
62+
63+
if ! [ -x "${MAVEN_HOME:-}/bin/mvn" ]; then
64+
echo "Downloading Maven from $MAVEN_URL"
65+
tmp="$TOOLS/maven.tgz"
66+
curl -fL "$MAVEN_URL" -o "$tmp"
67+
tar -xzf "$tmp" -C "$TOOLS"
68+
rm "$tmp"
69+
MAVEN_HOME="$TOOLS/apache-maven-3.9.6"
70+
fi
71+
72+
cat > "$TOOLS/env.sh" <<ENV
73+
export JAVA_HOME="$JAVA_HOME"
74+
export JAVA_HOME_17="$JAVA_HOME_17"
75+
export MAVEN_HOME="$MAVEN_HOME"
76+
export PATH="\$JAVA_HOME/bin:\$MAVEN_HOME/bin:\$PATH"
77+
ENV
78+
79+
source "$TOOLS/env.sh"
80+
81+
"$JAVA_HOME/bin/java" -version
82+
"$JAVA_HOME_17/bin/java" -version
83+
"$MAVEN_HOME/bin/mvn" -version
84+
85+
PATH="$JAVA_HOME/bin:$MAVEN_HOME/bin:$PATH"
86+
("$MAVEN_HOME/bin/mvn" -q -f maven/pom.xml install "$@")
87+
88+
BUILD_CLIENT="$HOME/.codenameone/CodeNameOneBuildClient.jar"
89+
if [ ! -f "$BUILD_CLIENT" ]; then
90+
if ! "$MAVEN_HOME/bin/mvn" -q -f maven/pom.xml cn1:install-codenameone "$@"; then
91+
mkdir -p "$(dirname "$BUILD_CLIENT")"
92+
cp maven/CodeNameOneBuildClient.jar "$BUILD_CLIENT" || true
93+
fi
94+
fi
95+
96+
if [ ! -d cn1-maven-archetypes ]; then
97+
git clone https://github.com/shannah/cn1-maven-archetypes
98+
fi
99+
(cd cn1-maven-archetypes && "$MAVEN_HOME/bin/mvn" -q -DskipTests -DskipITs install)

0 commit comments

Comments
 (0)