Skip to content

Commit 92fae6c

Browse files
committed
Provide codenameone-cef stub for Linux ARM builds
1 parent 85b4ea0 commit 92fae6c

File tree

5 files changed

+148
-71
lines changed

5 files changed

+148
-71
lines changed

maven/codenameone-maven-plugin/pom.xml

Lines changed: 8 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,6 @@
2020
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
2121
<maven.compiler.source>1.7</maven.compiler.source>
2222
<maven.compiler.target>1.7</maven.compiler.target>
23-
<!--
24-
Codename One embeds Chromium via the codenameone-cef artifact which is
25-
only published for x86/x64 targets. Linux ARM runners cannot resolve
26-
this dependency, so allow scripts to disable it with
27-
-Dinclude.cef=false.
28-
-->
29-
<include.cef>true</include.cef>
3023
</properties>
3124

3225
<profiles>
@@ -38,23 +31,6 @@
3831
</file>
3932
</activation>
4033
</profile>
41-
<profile>
42-
<id>include-cef</id>
43-
<activation>
44-
<property>
45-
<name>include.cef</name>
46-
<value>true</value>
47-
</property>
48-
</activation>
49-
<dependencies>
50-
<dependency>
51-
<groupId>com.codenameone</groupId>
52-
<artifactId>codenameone-cef</artifactId>
53-
<version>84.4.1-M3</version>
54-
<type>pom</type>
55-
</dependency>
56-
</dependencies>
57-
</profile>
5834
</profiles>
5935

6036
<dependencies>
@@ -140,6 +116,14 @@
140116
<artifactId>proguard-base</artifactId>
141117
</dependency>
142118

119+
<dependency>
120+
<groupId>com.codenameone</groupId>
121+
<artifactId>codenameone-cef</artifactId>
122+
<version>84.4.1-M3</version>
123+
<type>pom</type>
124+
</dependency>
125+
126+
143127
<dependency>
144128
<groupId>org.junit.jupiter</groupId>
145129
<artifactId>junit-jupiter-api</artifactId>

scripts/build-android-app.sh

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -12,27 +12,23 @@ TMPDIR="${TMPDIR:-/tmp}"; TMPDIR="${TMPDIR%/}"
1212
DOWNLOAD_DIR="${TMPDIR%/}/codenameone-tools"
1313
ENV_DIR="$DOWNLOAD_DIR/tools"
1414
EXTRA_MVN_ARGS=("$@")
15-
1615
HOST_OS="$(uname -s)"
1716
HOST_ARCH="$(uname -m)"
18-
if [ "$HOST_OS" = "Linux" ]; then
19-
case "$HOST_ARCH" in
20-
arm64|aarch64)
21-
include_cef_arg_present=0
22-
for arg in "${EXTRA_MVN_ARGS[@]}"; do
23-
case "$arg" in
24-
-Dinclude.cef=*) include_cef_arg_present=1; break ;;
25-
esac
26-
done
27-
if [ "$include_cef_arg_present" -eq 0 ]; then
28-
ba_log "Linux ARM host detected; disabling codenameone-cef dependency"
29-
EXTRA_MVN_ARGS+=("-Dinclude.cef=false")
30-
else
31-
ba_log "Linux ARM host detected; using custom include.cef flag"
32-
fi
33-
;;
34-
esac
35-
fi
17+
18+
detect_local_repo() {
19+
local repo="${LOCAL_MAVEN_REPO:-}"
20+
for arg in "${EXTRA_MVN_ARGS[@]}"; do
21+
case "$arg" in
22+
-Dmaven.repo.local=*)
23+
repo="${arg#*=}"
24+
;;
25+
esac
26+
done
27+
if [ -z "$repo" ]; then
28+
repo="$HOME/.m2/repository"
29+
fi
30+
printf '%s' "${repo%/}"
31+
}
3632

3733
ENV_FILE="$ENV_DIR/env.sh"
3834
ba_log "Loading workspace environment from $ENV_FILE"
@@ -83,6 +79,11 @@ ba_log "Using JAVA17_HOME at $JAVA17_HOME"
8379
ba_log "Using Maven installation at $MAVEN_HOME"
8480
export PATH="$JAVA_HOME/bin:$MAVEN_HOME/bin:$PATH"
8581

82+
if [ "$HOST_OS" = "Linux" ] && { [ "$HOST_ARCH" = "arm64" ] || [ "$HOST_ARCH" = "aarch64" ]; }; then
83+
ba_log "Ensuring codenameone-cef stub artifact is installed for Linux ARM builds"
84+
MAVEN_BIN="$MAVEN_HOME/bin/mvn" LOCAL_MAVEN_REPO="$LOCAL_MAVEN_REPO" ./scripts/ensure-cef-stub.sh
85+
fi
86+
8687
ANDROID_SDK_ROOT="${ANDROID_SDK_ROOT:-${ANDROID_HOME:-}}"
8788
if [ -z "$ANDROID_SDK_ROOT" ]; then
8889
if [ -d "/usr/local/lib/android/sdk" ]; then ANDROID_SDK_ROOT="/usr/local/lib/android/sdk"
@@ -112,7 +113,7 @@ if [ ! -d "$SOURCE_PROJECT" ]; then
112113
fi
113114
ba_log "Using source project template at $SOURCE_PROJECT"
114115

115-
LOCAL_MAVEN_REPO="${LOCAL_MAVEN_REPO:-$HOME/.m2/repository}"
116+
LOCAL_MAVEN_REPO="$(detect_local_repo)"
116117
ba_log "Using local Maven repository at $LOCAL_MAVEN_REPO"
117118
mkdir -p "$LOCAL_MAVEN_REPO"
118119
MAVEN_CMD=(

scripts/build-android-port.sh

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -20,24 +20,24 @@ ENV_FILE="$ENV_DIR/env.sh"
2020

2121
host_os="$(uname -s)"
2222
host_arch="$(uname -m)"
23-
if [ "$host_os" = "Linux" ]; then
24-
case "$host_arch" in
25-
arm64|aarch64)
26-
include_cef_arg_present=0
27-
for arg in "$@"; do
28-
case "$arg" in
29-
-Dinclude.cef=*) include_cef_arg_present=1; break ;;
30-
esac
31-
done
32-
if [ "$include_cef_arg_present" -eq 0 ]; then
33-
log "Linux ARM host detected; disabling codenameone-cef dependency"
34-
set -- "$@" "-Dinclude.cef=false"
35-
else
36-
log "Linux ARM host detected; using custom include.cef flag"
37-
fi
38-
;;
39-
esac
40-
fi
23+
24+
detect_local_repo() {
25+
local repo="${LOCAL_MAVEN_REPO:-}"
26+
for arg in "$@"; do
27+
case "$arg" in
28+
-Dmaven.repo.local=*)
29+
repo="${arg#*=}"
30+
;;
31+
esac
32+
done
33+
if [ -z "$repo" ]; then
34+
repo="$HOME/.m2/repository"
35+
fi
36+
printf '%s' "${repo%/}"
37+
}
38+
39+
LOCAL_REPO_PATH="$(detect_local_repo "$@")"
40+
mkdir -p "$LOCAL_REPO_PATH"
4141

4242
load_environment() {
4343
if [ ! -f "$ENV_FILE" ]; then
@@ -134,6 +134,11 @@ export PATH="$JAVA_HOME/bin:$MAVEN_HOME/bin:$PATH"
134134
"$JAVA17_HOME/bin/java" -version
135135
"$MAVEN_HOME/bin/mvn" -version
136136

137+
if [ "$host_os" = "Linux" ] && { [ "$host_arch" = "arm64" ] || [ "$host_arch" = "aarch64" ]; }; then
138+
log "Ensuring codenameone-cef stub artifact is installed for Linux ARM builds"
139+
MAVEN_BIN="$MAVEN_HOME/bin/mvn" LOCAL_MAVEN_REPO="$LOCAL_REPO_PATH" ./scripts/ensure-cef-stub.sh
140+
fi
141+
137142
run_maven() {
138143
xvfb-run -a "$MAVEN_HOME/bin/mvn" "$@"
139144
}

scripts/ensure-cef-stub.sh

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
#!/usr/bin/env bash
2+
# Ensure the codenameone-cef artifact is available in the local Maven repository on
3+
# platforms where the published binaries are unavailable (e.g., Linux ARM).
4+
set -euo pipefail
5+
[ "${DEBUG:-0}" = "1" ] && set -x
6+
7+
log() {
8+
echo "[ensure-cef-stub] $1"
9+
}
10+
11+
os_name="$(uname -s)"
12+
arch_name="$(uname -m)"
13+
if [ "$os_name" != "Linux" ] || { [ "$arch_name" != "arm64" ] && [ "$arch_name" != "aarch64" ]; }; then
14+
log "Host ${os_name}-${arch_name} does not require a CEF stub; skipping"
15+
exit 0
16+
fi
17+
18+
MAVEN_BIN="${MAVEN_BIN:-}"
19+
if [ -z "$MAVEN_BIN" ] && [ -n "${MAVEN_HOME:-}" ] && [ -x "$MAVEN_HOME/bin/mvn" ]; then
20+
MAVEN_BIN="$MAVEN_HOME/bin/mvn"
21+
fi
22+
if [ -z "$MAVEN_BIN" ] && command -v mvn >/dev/null 2>&1; then
23+
MAVEN_BIN="$(command -v mvn)"
24+
fi
25+
if [ -z "$MAVEN_BIN" ] || [ ! -x "$MAVEN_BIN" ]; then
26+
log "Maven executable not found. Set MAVEN_HOME, MAVEN_BIN, or ensure mvn is on PATH." >&2
27+
exit 1
28+
fi
29+
30+
LOCAL_MAVEN_REPO="${LOCAL_MAVEN_REPO:-$HOME/.m2/repository}"
31+
LOCAL_MAVEN_REPO="${LOCAL_MAVEN_REPO%/}"
32+
if [ -z "$LOCAL_MAVEN_REPO" ]; then
33+
log "LOCAL_MAVEN_REPO is empty" >&2
34+
exit 1
35+
fi
36+
mkdir -p "$LOCAL_MAVEN_REPO"
37+
38+
CEF_VERSION="84.4.1-M3"
39+
CEF_COORD="com.codenameone:codenameone-cef:$CEF_VERSION"
40+
CEF_REPO_PATH="$LOCAL_MAVEN_REPO/com/codenameone/codenameone-cef/$CEF_VERSION"
41+
CEF_POM="$CEF_REPO_PATH/codenameone-cef-$CEF_VERSION.pom"
42+
43+
if [ -s "$CEF_POM" ]; then
44+
log "codenameone-cef $CEF_VERSION already present in $LOCAL_MAVEN_REPO"
45+
exit 0
46+
fi
47+
48+
log "Installing stub codenameone-cef $CEF_VERSION artifact into $LOCAL_MAVEN_REPO"
49+
mkdir -p "$CEF_REPO_PATH"
50+
stub_pom="$(mktemp "${TMPDIR:-/tmp}/codenameone-cef-stub.XXXXXX.pom")"
51+
trap 'rm -f "$stub_pom"' EXIT
52+
53+
cat > "$stub_pom" <<'POM'
54+
<?xml version="1.0" encoding="UTF-8"?>
55+
<project xmlns="http://maven.apache.org/POM/4.0.0"
56+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
57+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
58+
<modelVersion>4.0.0</modelVersion>
59+
<groupId>com.codenameone</groupId>
60+
<artifactId>codenameone-cef</artifactId>
61+
<version>84.4.1-M3</version>
62+
<packaging>pom</packaging>
63+
<name>codenameone-cef stub</name>
64+
<description>Stub artifact to satisfy codenameone-cef dependency on platforms where CEF binaries are unavailable.</description>
65+
</project>
66+
POM
67+
68+
"$MAVEN_BIN" -B -ntp org.apache.maven.plugins:maven-install-plugin:3.1.2:install-file \
69+
-Dfile="$stub_pom" \
70+
-DgroupId=com.codenameone \
71+
-DartifactId=codenameone-cef \
72+
-Dversion="$CEF_VERSION" \
73+
-Dpackaging=pom \
74+
-DgeneratePom=false \
75+
-DcreateChecksum=true \
76+
-DlocalRepositoryPath="$LOCAL_MAVEN_REPO"
77+
78+
log "Stub $CEF_COORD installed"

scripts/setup-workspace.sh

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -60,20 +60,24 @@ case "$arch_name" in
6060
*) echo "Unsupported architecture: $arch_name" >&2; exit 1 ;;
6161
esac
6262

63-
if [ "$os" = "linux" ] && [ "$arch" = "aarch64" ]; then
64-
include_cef_arg_present=0
63+
detect_local_repo() {
64+
local repo="${LOCAL_MAVEN_REPO:-}"
6565
for arg in "$@"; do
6666
case "$arg" in
67-
-Dinclude.cef=*) include_cef_arg_present=1; break ;;
67+
-Dmaven.repo.local=*)
68+
repo="${arg#*=}"
69+
;;
6870
esac
6971
done
70-
if [ "$include_cef_arg_present" -eq 0 ]; then
71-
log "Linux ARM host detected; disabling codenameone-cef dependency"
72-
set -- "$@" "-Dinclude.cef=false"
73-
else
74-
log "Linux ARM host detected; using custom include.cef flag"
72+
if [ -z "$repo" ]; then
73+
repo="$HOME/.m2/repository"
7574
fi
76-
fi
75+
printf '%s' "${repo%/}"
76+
}
77+
78+
LOCAL_MAVEN_REPO="$(detect_local_repo "$@")"
79+
log "Using local Maven repository at $LOCAL_MAVEN_REPO"
80+
mkdir -p "$LOCAL_MAVEN_REPO"
7781

7882
# Determine platform-specific JDK download URLs
7983
arch_jdk8="$arch"
@@ -163,6 +167,11 @@ else
163167
log "Using existing Maven at $MAVEN_HOME"
164168
fi
165169

170+
if [ "$os" = "linux" ] && [ "$arch" = "aarch64" ]; then
171+
log "Ensuring codenameone-cef stub artifact is installed for Linux ARM builds"
172+
MAVEN_BIN="$MAVEN_HOME/bin/mvn" LOCAL_MAVEN_REPO="$LOCAL_MAVEN_REPO" ./scripts/ensure-cef-stub.sh
173+
fi
174+
166175
ARCHETYPE_PLUGIN_COORD="org.apache.maven.plugins:maven-archetype-plugin:3.2.1"
167176
log "Preloading Maven archetype plugin ($ARCHETYPE_PLUGIN_COORD) for offline project generation"
168177
if "$MAVEN_HOME/bin/mvn" -B -N "$ARCHETYPE_PLUGIN_COORD:help" -Ddetail -Dgoal=generate >/dev/null 2>&1; then

0 commit comments

Comments
 (0)