Skip to content

Commit 2bbef0e

Browse files
committed
Attempt to fix build issue
1 parent 29f4e0a commit 2bbef0e

File tree

4 files changed

+89
-20
lines changed

4 files changed

+89
-20
lines changed

maven/codenameone-maven-plugin/src/main/java/com/codename1/builders/IPhoneBuilder.java

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1193,8 +1193,9 @@ public void usesClassMethod(String cls, String method) {
11931193
if (!new File(javacPath).exists()) {
11941194
javacPath = "javac";
11951195
}
1196+
String[] stubSourceTarget = getStubCompileSourceTarget(javacPath);
11961197
try {
1197-
if (!execWithFiles(stubSource, stubSource, ".java", javacPath, "-source", "1.6", "-target", "1.6", "-classpath",
1198+
if (!execWithFiles(stubSource, stubSource, ".java", javacPath, "-source", stubSourceTarget[0], "-target", stubSourceTarget[1], "-classpath",
11981199
classesDir.getAbsolutePath(),
11991200
"-d", classesDir.getAbsolutePath())) {
12001201
return false;
@@ -2595,7 +2596,7 @@ public boolean accept(File file, String string) {
25952596
*/
25962597
private int getXcodeVersion(String xcodeBuild) {
25972598
try {
2598-
String result = execString(tmpFile, xcodeBuild, "-version");
2599+
String result = execString(new File("."), xcodeBuild, "-version");
25992600
debug("Result is "+result);
26002601

26012602
Scanner scanner = new Scanner(result);
@@ -2637,7 +2638,37 @@ private int getMajorVersionInt(String versionStr, int defaultVal) {
26372638
return defaultVal;
26382639
}
26392640

2641+
private String[] getStubCompileSourceTarget(String javacPath) {
2642+
String source = "1.6";
2643+
String target = "1.6";
2644+
try {
2645+
String versionOutput = execString(tmpFile != null ? tmpFile : new File("."), javacPath, "-version");
2646+
if (versionOutput != null && versionOutput.trim().length() > 0) {
2647+
String[] parts = versionOutput.trim().split("\\s+");
2648+
String version = parts[parts.length - 1];
2649+
int major = getMajorVersionInt(version, -1);
2650+
if (major >= 9) {
2651+
source = "8";
2652+
target = "8";
2653+
log("JDK " + version + " does not support -source/-target 1.6. Compiling iOS stubs with -source/-target 8.");
2654+
}
2655+
}
2656+
} catch (Exception ex) {
2657+
debug("Failed to resolve javac version for iOS stub compile: " + ex.getMessage());
2658+
}
2659+
return new String[]{source, target};
2660+
}
2661+
26402662
private String resolveXcodebuild() {
2663+
String explicitXcodebuild = System.getenv("XCODEBUILD");
2664+
if (explicitXcodebuild != null && explicitXcodebuild.length() > 0) {
2665+
File candidate = new File(explicitXcodebuild);
2666+
if (candidate.exists()) {
2667+
log("Using xcodebuild from XCODEBUILD: " + candidate.getAbsolutePath());
2668+
return candidate.getAbsolutePath();
2669+
}
2670+
}
2671+
26412672
String developerDir = System.getenv("DEVELOPER_DIR");
26422673
if (developerDir != null && developerDir.length() > 0) {
26432674
File candidate = new File(developerDir, "usr/bin/xcodebuild");

maven/codenameone-maven-plugin/src/main/java/com/codename1/maven/CN1BuildMojo.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1016,6 +1016,10 @@ private void doIOSLocalBuild(File tmpProjectDir, Properties props, File distJar)
10161016
try {
10171017
boolean result = e.build(distJar, request);
10181018
if (!result) {
1019+
String builderLog = e.getErrorMessage();
1020+
if (builderLog != null && builderLog.trim().length() > 0) {
1021+
getLog().error("iOS builder log:\n" + builderLog);
1022+
}
10191023
throw new MojoExecutionException("iOS build failed");
10201024
}
10211025

@@ -1039,6 +1043,10 @@ private void doIOSLocalBuild(File tmpProjectDir, Properties props, File distJar)
10391043

10401044

10411045
} catch (BuildException ex) {
1046+
String builderLog = e.getErrorMessage();
1047+
if (builderLog != null && builderLog.trim().length() > 0) {
1048+
getLog().error("iOS builder log:\n" + builderLog);
1049+
}
10421050
throw new MojoExecutionException("Failed to build ios app", ex);
10431051
} finally {
10441052

scripts/build-ios-app.sh

Lines changed: 39 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,19 @@ set -euo pipefail
44

55
bia_log() { echo "[build-ios-app] $1"; }
66

7-
# Pin Xcode so CN1’s Java subprocess sees xcodebuild
8-
XCODE_APP="${XCODE_APP:-/Applications/Xcode_26.0.1.app}"
9-
if [ ! -d "$XCODE_APP" ]; then
10-
bia_log "Xcode 26 not found at $XCODE_APP. Set XCODE_APP to the Xcode 26 app bundle path." >&2
7+
# Pin Xcode 26 for CI validation.
8+
if [ -z "${XCODE_APP:-}" ]; then
9+
XCODE_APP="$(ls -d /Applications/Xcode_26*.app 2>/dev/null | sort -V | tail -n 1 || true)"
10+
fi
11+
if [ ! -x "$XCODE_APP/Contents/Developer/usr/bin/xcodebuild" ]; then
12+
bia_log "Xcode 26 not found. Set XCODE_APP to an installed Xcode 26 app bundle path." >&2
1113
exit 1
1214
fi
1315
export DEVELOPER_DIR="$XCODE_APP/Contents/Developer"
16+
export XCODEBUILD="$DEVELOPER_DIR/usr/bin/xcodebuild"
1417
export PATH="$DEVELOPER_DIR/usr/bin:$PATH"
18+
bia_log "Using DEVELOPER_DIR=$DEVELOPER_DIR"
19+
bia_log "Using XCODEBUILD=$XCODEBUILD"
1520

1621
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
1722
REPO_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
@@ -56,12 +61,13 @@ fi
5661

5762
ORIGINAL_JAVA_HOME="$JAVA_HOME"
5863
export PATH="$JAVA_HOME/bin:$MAVEN_HOME/bin:$PATH"
64+
BASE_PATH="$PATH"
5965

6066
bia_log "Using JAVA_HOME at $JAVA_HOME"
6167
bia_log "Using JAVA17_HOME at $JAVA17_HOME"
6268
bia_log "Using Maven installation at $MAVEN_HOME"
6369
bia_log "Using CocoaPods version $(pod --version 2>/dev/null || echo '<unknown>')"
64-
bia_log "Java version for Maven process:"
70+
bia_log "Java version for baseline toolchain:"
6571
"$JAVA_HOME/bin/java" -version
6672
bia_log "Using JAVAC from JAVA17_HOME for demo compilation:"
6773
"$JAVA17_HOME/bin/javac" -version
@@ -81,15 +87,34 @@ mkdir -p "$ARTIFACTS_DIR"
8187

8288
export CN1_BUILD_STATS_FILE="$ARTIFACTS_DIR/iphone-builder-stats.txt"
8389

84-
./mvnw package \
85-
-DskipTests \
86-
-Dcodename1.platform=ios \
87-
-Dcodename1.buildTarget=ios-source \
88-
-Dmaven.compiler.fork=true \
89-
-Dmaven.compiler.executable="$JAVA17_HOME/bin/javac" \
90-
-Dcodename1.arg.ios.uiscene="${IOS_UISCENE}" \
91-
-Dopen=false \
92-
-U -e
90+
bia_log "Running HelloCodenameOne Maven build with JAVA_HOME=$JAVA17_HOME"
91+
(
92+
export JAVA_HOME="$JAVA17_HOME"
93+
export PATH="$JAVA_HOME/bin:$MAVEN_HOME/bin:$BASE_PATH"
94+
MVN_IOS_LOG="$ARTIFACTS_DIR/hellocn1-ios-build.log"
95+
set +e
96+
./mvnw package \
97+
-DskipTests \
98+
-Dcodename1.platform=ios \
99+
-Dcodename1.buildTarget=ios-source \
100+
-Dmaven.compiler.fork=true \
101+
-Dmaven.compiler.executable="$JAVA17_HOME/bin/javac" \
102+
-Dcodename1.arg.ios.uiscene="${IOS_UISCENE}" \
103+
-Dopen=false \
104+
-U -e -X > "$MVN_IOS_LOG" 2>&1
105+
RC=$?
106+
set -e
107+
if [ $RC -ne 0 ]; then
108+
bia_log "Maven iOS build failed (exit=$RC). Log: $MVN_IOS_LOG"
109+
bia_log "Key failure lines:"
110+
if command -v rg >/dev/null 2>&1; then
111+
rg -n "(iOS builder log:|Caused by:|BuildException|Cannot run program|UnsupportedClassVersionError|error:|\\[ERROR\\])" "$MVN_IOS_LOG" | tail -n 200 || true
112+
else
113+
grep -nE "(iOS builder log:|Caused by:|BuildException|Cannot run program|UnsupportedClassVersionError|error:|\\[ERROR\\])" "$MVN_IOS_LOG" | tail -n 200 || true
114+
fi
115+
exit $RC
116+
fi
117+
)
93118
VM_END=$(date +%s)
94119
VM_TIME=$((VM_END - VM_START))
95120
cd ../..

scripts/run-ios-ui-tests.sh

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,19 @@ ri_log "Loading workspace environment from $ENV_FILE"
5353
# shellcheck disable=SC1090
5454
source "$ENV_FILE"
5555

56-
# Use the same Xcode as the build step
57-
XCODE_APP="${XCODE_APP:-/Applications/Xcode_26.0.1.app}"
58-
if [ ! -d "$XCODE_APP" ]; then
59-
ri_log "Xcode 26 not found at $XCODE_APP. Set XCODE_APP to the Xcode 26 app bundle path." >&2
56+
# Pin Xcode 26 for CI validation.
57+
if [ -z "${XCODE_APP:-}" ]; then
58+
XCODE_APP="$(ls -d /Applications/Xcode_26*.app 2>/dev/null | sort -V | tail -n 1 || true)"
59+
fi
60+
if [ ! -x "$XCODE_APP/Contents/Developer/usr/bin/xcodebuild" ]; then
61+
ri_log "Xcode 26 not found. Set XCODE_APP to an installed Xcode 26 app bundle path." >&2
6062
exit 3
6163
fi
6264
export DEVELOPER_DIR="$XCODE_APP/Contents/Developer"
65+
export XCODEBUILD="$DEVELOPER_DIR/usr/bin/xcodebuild"
6366
export PATH="$DEVELOPER_DIR/usr/bin:$PATH"
67+
ri_log "Using DEVELOPER_DIR=$DEVELOPER_DIR"
68+
ri_log "Using XCODEBUILD=$XCODEBUILD"
6469

6570
if [ -z "${JAVA17_HOME:-}" ] || [ ! -x "$JAVA17_HOME/bin/java" ]; then
6671
ri_log "JAVA17_HOME not set correctly" >&2

0 commit comments

Comments
 (0)