Skip to content

Commit 550d74c

Browse files
Optimize CI workflows by utilizing a dedicated Docker container (ghcr.io/codenameone/codenameone/ci-container) with pre-installed build dependencies (OpenJFX 8, OpenJDK 11/17/21/25, Android SDK/NDK, Ant, Maven).
- Refactor `pr.yml`, `ant.yml`, and `scripts-android.yml` to execute within the container environment, removing redundant setup steps. - Introduce `.github/workflows/build-container.yml` to automate container image builds. - Enhance `scripts/setup-workspace.sh` to respect container-provided `CN1_BINARIES` and skip read-only updates. - Fix `AndroidGradleBuilder.java` to correctly detect the Android SDK root when using `cmdline-tools` directly and ensure `sdkmanager` executes with the correct Java 17 environment.
1 parent d9de952 commit 550d74c

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

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

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -520,6 +520,7 @@ public boolean build(File sourceZip, final BuildRequest request) throws BuildExc
520520
log("NOTICE: Enabling Java 8 source level for Gradle 8 build because RetroLambda is not supported on Java 17, which is required for gradle 8.");
521521
useJava8SourceLevel = true;
522522
}
523+
defaultEnvironment.put("JAVA_HOME", getGradleJavaHome());
523524
}
524525
if (newFirebaseMessaging && !useGradle8) {
525526
throw new BuildException("android.newFirebaseMessaging requires gradle version 8.1 or higher. Please remove the android.gradleVersion build hint");
@@ -577,10 +578,21 @@ public boolean build(File sourceZip, final BuildRequest request) throws BuildExc
577578
if (!androidSDKDir.exists()) {
578579
throw new BuildException("Cannot find Android SDK at "+androidHome+". Please install Android studio, or set the ANDROID_HOME environment variable to point to your android sdk directory.");
579580
}
580-
if (!androidSDKDir.getName().equalsIgnoreCase("sdk")) {
581-
androidSDKDir = new File(androidSDKDir, "Sdk");
582-
if (!androidSDKDir.isDirectory()) {
583-
androidSDKDir = new File(androidSDKDir.getParentFile(), "sdk");
581+
// Check if this looks like an SDK directory
582+
if (!new File(androidSDKDir, "cmdline-tools").exists() &&
583+
!new File(androidSDKDir, "platform-tools").exists() &&
584+
!new File(androidSDKDir, "build-tools").exists() &&
585+
!new File(androidSDKDir, "tools").exists()) {
586+
if (!androidSDKDir.getName().equalsIgnoreCase("sdk")) {
587+
File childSdk = new File(androidSDKDir, "Sdk");
588+
if (childSdk.isDirectory()) {
589+
androidSDKDir = childSdk;
590+
} else {
591+
File siblingSdk = new File(androidSDKDir.getParentFile(), "sdk");
592+
if (siblingSdk.isDirectory()) {
593+
androidSDKDir = siblingSdk;
594+
}
595+
}
584596
}
585597
}
586598

0 commit comments

Comments
 (0)