mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
chore: update ui-mobile-base android script to support Java 21 and gradle 8+ (#10907)
Also allows fallbacks per detection.
This commit is contained in:
@ -6,7 +6,8 @@ buildscript {
|
||||
mavenCentral()
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:7.1.0'
|
||||
// Updated for Java 21 compatibility via Gradle 8.4
|
||||
classpath 'com.android.tools.build:gradle:8.3.2'
|
||||
|
||||
// NOTE: Do not place your application dependencies here; they belong
|
||||
// in the individual module build.gradle files
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
||||
@ -6,7 +6,7 @@ def isWinOs = System.properties['os.name'].toLowerCase().contains('windows')
|
||||
|
||||
apply plugin: 'com.android.library'
|
||||
|
||||
def computeCompileSdkVersion () {
|
||||
def computeCompileSdkValue () {
|
||||
if(project.hasProperty("compileSdk")) {
|
||||
return compileSdk
|
||||
}
|
||||
@ -15,15 +15,6 @@ def computeCompileSdkVersion () {
|
||||
}
|
||||
}
|
||||
|
||||
def computeBuildToolsVersion() {
|
||||
if(project.hasProperty("buildToolsVersion")) {
|
||||
return buildToolsVersion
|
||||
}
|
||||
else {
|
||||
return "32.0.0"
|
||||
}
|
||||
}
|
||||
|
||||
def computeTargetSdkVersion() {
|
||||
if(project.hasProperty("targetSdk")) {
|
||||
return targetSdk
|
||||
@ -34,12 +25,13 @@ def computeTargetSdkVersion() {
|
||||
}
|
||||
|
||||
android {
|
||||
compileSdkVersion computeCompileSdkVersion()
|
||||
buildToolsVersion computeBuildToolsVersion()
|
||||
// AGP 8 DSL: use 'compileSdk' and specify namespace
|
||||
compileSdk computeCompileSdkValue()
|
||||
namespace "org.nativescript.widgets"
|
||||
|
||||
defaultConfig {
|
||||
minSdkVersion 17
|
||||
targetSdkVersion computeTargetSdkVersion()
|
||||
minSdk 17
|
||||
targetSdk computeTargetSdkVersion()
|
||||
versionCode 1
|
||||
versionName "1.0"
|
||||
}
|
||||
|
||||
@ -6,6 +6,33 @@ set -e
|
||||
echo "Use dumb gradle terminal"
|
||||
export TERM=dumb
|
||||
|
||||
# Prefer running with JDK 21 for Gradle 8.4+/AGP 8.3+
|
||||
if [ "$(uname)" = "Darwin" ]; then
|
||||
# On macOS, prefer JDK 21, fall back to JDK 17
|
||||
if /usr/libexec/java_home -v 21 >/dev/null 2>&1; then
|
||||
export JAVA_HOME=$(/usr/libexec/java_home -v 21)
|
||||
export PATH="$JAVA_HOME/bin:$PATH"
|
||||
echo "Using Java (21) at $JAVA_HOME"
|
||||
java -version 2>&1 | head -n 1
|
||||
elif /usr/libexec/java_home -v 17 >/dev/null 2>&1; then
|
||||
export JAVA_HOME=$(/usr/libexec/java_home -v 17)
|
||||
export PATH="$JAVA_HOME/bin:$PATH"
|
||||
echo "Using Java (17) at $JAVA_HOME"
|
||||
java -version 2>&1 | head -n 1
|
||||
else
|
||||
echo "Warning: JDK 21 or 17 not found via /usr/libexec/java_home. Using current JAVA_HOME: ${JAVA_HOME:-unset}"
|
||||
java -version 2>&1 || true
|
||||
echo "Install JDK 21 (preferred) or JDK 17."
|
||||
fi
|
||||
else
|
||||
# Non-macOS: print Java version for visibility
|
||||
if command -v java >/dev/null 2>&1; then
|
||||
echo "Detected Java runtime: $(java -version 2>&1 | head -n 1)"
|
||||
else
|
||||
echo "Warning: 'java' not found on PATH. Build will likely fail."
|
||||
fi
|
||||
fi
|
||||
|
||||
rm -rf dist/package/platforms/android || true
|
||||
mkdir -p dist/package/platforms/android
|
||||
|
||||
|
||||
Reference in New Issue
Block a user