Skip to content

Commit bec401c

Browse files
authored
feat: NDK 27 and Support for Java 21 (#1819)
1 parent 3633aed commit bec401c

File tree

14 files changed

+88
-71
lines changed

14 files changed

+88
-71
lines changed

.github/workflows/npm_release.yml

+8-8
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ on:
88
env:
99
NPM_TAG: "next"
1010
EMULATOR_NAME: "runtime-emu"
11-
NDK_VERSION: r23c
12-
ANDROID_API: 29
11+
NDK_VERSION: r27
12+
ANDROID_API: 33
1313
ANDROID_ABI: x86_64
1414
NDK_ARCH: darwin
1515

@@ -27,12 +27,12 @@ jobs:
2727
submodules: true
2828
- uses: actions/setup-node@v3
2929
with:
30-
node-version: 18
30+
node-version: 22
3131
registry-url: "https://registry.npmjs.org"
3232
- uses: actions/setup-java@v3
3333
with:
3434
distribution: "temurin"
35-
java-version: "17"
35+
java-version: "21"
3636
cache: gradle
3737
- name: Setup Android SDK
3838
uses: android-actions/setup-android@v2
@@ -93,12 +93,12 @@ jobs:
9393
submodules: true
9494
- uses: actions/setup-node@v3
9595
with:
96-
node-version: 18
96+
node-version: 22
9797
registry-url: "https://registry.npmjs.org"
9898
- uses: actions/setup-java@v3
9999
with:
100100
distribution: "temurin"
101-
java-version: "17"
101+
java-version: "21"
102102
cache: gradle
103103
- name: Setup Android SDK
104104
uses: android-actions/setup-android@v2
@@ -144,7 +144,7 @@ jobs:
144144
steps:
145145
- uses: actions/setup-node@v3
146146
with:
147-
node-version: 18
147+
node-version: 22
148148
registry-url: "https://registry.npmjs.org"
149149
- uses: actions/download-artifact@v4
150150
with:
@@ -173,7 +173,7 @@ jobs:
173173
fetch-depth: 0
174174
- uses: actions/setup-node@v3
175175
with:
176-
node-version: 18
176+
node-version: 22
177177
- name: Setup
178178
run: npm install
179179
- uses: actions/download-artifact@v4

.github/workflows/pull_request.yml

+6-6
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ on:
44
env:
55
NPM_TAG: "pr"
66
EMULATOR_NAME: "runtime-emu"
7-
NDK_VERSION: r23c
8-
ANDROID_API: 29
7+
NDK_VERSION: r27
8+
ANDROID_API: 33
99
ANDROID_ABI: x86_64
1010
NDK_ARCH: darwin
1111

@@ -24,12 +24,12 @@ jobs:
2424
submodules: true
2525
- uses: actions/setup-node@v3
2626
with:
27-
node-version: 18
27+
node-version: 22
2828
registry-url: "https://registry.npmjs.org"
2929
- uses: actions/setup-java@v3
3030
with:
3131
distribution: "temurin"
32-
java-version: "17"
32+
java-version: "21"
3333
cache: gradle
3434
- name: Setup Android SDK
3535
uses: android-actions/setup-android@v2
@@ -89,12 +89,12 @@ jobs:
8989
submodules: true
9090
- uses: actions/setup-node@v3
9191
with:
92-
node-version: 18
92+
node-version: 22
9393
registry-url: "https://registry.npmjs.org"
9494
- uses: actions/setup-java@v3
9595
with:
9696
distribution: "temurin"
97-
java-version: "17"
97+
java-version: "21"
9898
cache: gradle
9999
- name: Setup Android SDK
100100
uses: android-actions/setup-android@v2

gradle/wrapper/gradle-wrapper.jar

-16.8 KB
Binary file not shown.
+3-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
4+
networkTimeout=10000
5+
validateDistributionUrl=true
46
zipStoreBase=GRADLE_USER_HOME
57
zipStorePath=wrapper/dists

gradlew

+25-13
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
# See the License for the specific language governing permissions and
1616
# limitations under the License.
1717
#
18+
# SPDX-License-Identifier: Apache-2.0
19+
#
1820

1921
##############################################################################
2022
#
@@ -55,7 +57,7 @@
5557
# Darwin, MinGW, and NonStop.
5658
#
5759
# (3) This script is generated from the Groovy template
58-
# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
60+
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
5961
# within the Gradle project.
6062
#
6163
# You can find Gradle at https://github.com/gradle/gradle/.
@@ -80,13 +82,12 @@ do
8082
esac
8183
done
8284

83-
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
84-
85-
APP_NAME="Gradle"
85+
# This is normally unused
86+
# shellcheck disable=SC2034
8687
APP_BASE_NAME=${0##*/}
87-
88-
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
89-
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
88+
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
89+
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s
90+
' "$PWD" ) || exit
9091

9192
# Use the maximum available, or set MAX_FD != -1 to use that value.
9293
MAX_FD=maximum
@@ -133,22 +134,29 @@ location of your Java installation."
133134
fi
134135
else
135136
JAVACMD=java
136-
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
137+
if ! command -v java >/dev/null 2>&1
138+
then
139+
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
137140
138141
Please set the JAVA_HOME variable in your environment to match the
139142
location of your Java installation."
143+
fi
140144
fi
141145

142146
# Increase the maximum file descriptors if we can.
143147
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
144148
case $MAX_FD in #(
145149
max*)
150+
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
151+
# shellcheck disable=SC2039,SC3045
146152
MAX_FD=$( ulimit -H -n ) ||
147153
warn "Could not query maximum file descriptor limit"
148154
esac
149155
case $MAX_FD in #(
150156
'' | soft) :;; #(
151157
*)
158+
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
159+
# shellcheck disable=SC2039,SC3045
152160
ulimit -n "$MAX_FD" ||
153161
warn "Could not set maximum file descriptor limit to $MAX_FD"
154162
esac
@@ -193,11 +201,15 @@ if "$cygwin" || "$msys" ; then
193201
done
194202
fi
195203

196-
# Collect all arguments for the java command;
197-
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
198-
# shell script including quotes and variable substitutions, so put them in
199-
# double quotes to make sure that they get re-expanded; and
200-
# * put everything else in single quotes, so that it's not re-expanded.
204+
205+
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
206+
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
207+
208+
# Collect all arguments for the java command:
209+
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
210+
# and any embedded shellness will be escaped.
211+
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
212+
# treated as '${Hostname}' itself on the command line.
201213

202214
set -- \
203215
"-Dorg.gradle.appname=$APP_BASE_NAME" \

gradlew.bat

+13-10
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
@rem See the License for the specific language governing permissions and
1414
@rem limitations under the License.
1515
@rem
16+
@rem SPDX-License-Identifier: Apache-2.0
17+
@rem
1618

1719
@if "%DEBUG%"=="" @echo off
1820
@rem ##########################################################################
@@ -26,6 +28,7 @@ if "%OS%"=="Windows_NT" setlocal
2628

2729
set DIRNAME=%~dp0
2830
if "%DIRNAME%"=="" set DIRNAME=.
31+
@rem This is normally unused
2932
set APP_BASE_NAME=%~n0
3033
set APP_HOME=%DIRNAME%
3134

@@ -42,11 +45,11 @@ set JAVA_EXE=java.exe
4245
%JAVA_EXE% -version >NUL 2>&1
4346
if %ERRORLEVEL% equ 0 goto execute
4447

45-
echo.
46-
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
47-
echo.
48-
echo Please set the JAVA_HOME variable in your environment to match the
49-
echo location of your Java installation.
48+
echo. 1>&2
49+
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
50+
echo. 1>&2
51+
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
52+
echo location of your Java installation. 1>&2
5053

5154
goto fail
5255

@@ -56,11 +59,11 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe
5659

5760
if exist "%JAVA_EXE%" goto execute
5861

59-
echo.
60-
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
61-
echo.
62-
echo Please set the JAVA_HOME variable in your environment to match the
63-
echo location of your Java installation.
62+
echo. 1>&2
63+
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
64+
echo. 1>&2
65+
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
66+
echo location of your Java installation. 1>&2
6467

6568
goto fail
6669

package.json

+9-9
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,19 @@
1111
],
1212
"version_info": {
1313
"v8": "10.3.22.0",
14-
"gradle": "8.4",
15-
"gradleAndroid": "8.3.2",
16-
"ndk": "r23c",
17-
"ndkApiLevel": "17",
18-
"minSdk": "17",
19-
"compileSdk": "34",
20-
"buildTools": "34.0.0",
14+
"gradle": "8.7",
15+
"gradleAndroid": "8.5.0",
16+
"ndk": "r27",
17+
"ndkApiLevel": "21",
18+
"minSdk": "21",
19+
"compileSdk": "35",
20+
"buildTools": "35.0.0",
2121
"kotlin": "2.0.0"
2222
},
2323
"// this gradle key is here for backwards compatibility - we'll phase it out slowly...": "",
2424
"gradle": {
25-
"version": "8.4",
26-
"android": "8.3.2"
25+
"version": "8.7",
26+
"android": "8.5.0"
2727
},
2828
"scripts": {
2929
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s",

test-app/build-tools/android-metadata-generator/build.gradle

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ apply plugin: 'java'
22
apply plugin: 'kotlin'
33

44
java {
5-
sourceCompatibility = '17'
6-
targetCompatibility = '17'
5+
sourceCompatibility = JavaVersion.VERSION_17
6+
targetCompatibility = JavaVersion.VERSION_17
77
}
88

99
// todo: check if still needed

test-app/runtime-binding-generator/build.gradle

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ dependencies {
77
}
88

99
java {
10-
sourceCompatibility = '17'
11-
targetCompatibility = '17'
10+
sourceCompatibility = JavaVersion.VERSION_17
11+
targetCompatibility = JavaVersion.VERSION_17
1212
}
1313

1414
// Disable compilation tasks as these are compiled *with* the runtime and not separately

test-app/runtime/CMakeLists.txt

+3-7
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ endif (CCACHE_FOUND AND (USE_CCACHE))
1818
# "-DANDROID_STL=c++_static" is just not enough for clang++ to find some libraries in the ndk
1919
MESSAGE(STATUS "## ANDROID_NDK_ROOT: " ${ANDROID_NDK_ROOT})
2020

21-
set(COMMON_CMAKE_ARGUMENTS "-std=c++20 -Werror -Wno-vla-cxx-extension -Wno-unused-result -mstackrealign -fexceptions -fno-builtin-stpcpy -fno-rtti -DV8_31BIT_SMIS_ON_64BIT_ARCH -DV8_31BIT_SMIS_ON_64BIT_ARCH -DV8_ENABLE_REGEXP_INTERPRETER_THREADED_DISPATCH -DV8_EMBEDDED_BUILTINS")
21+
22+
set(COMMON_CMAKE_ARGUMENTS "-std=c++20 -Werror -Wno-unused-result -mstackrealign -fexceptions -fno-builtin-stpcpy -fno-rtti -DV8_31BIT_SMIS_ON_64BIT_ARCH -DV8_31BIT_SMIS_ON_64BIT_ARCH -DV8_ENABLE_REGEXP_INTERPRETER_THREADED_DISPATCH -DV8_EMBEDDED_BUILTINS -Wno-vla-extension -Wno-deprecated -Wno-vla-cxx-extension")
23+
2224

2325
if("${ANDROID_ABI}" MATCHES "arm64-v8a$" OR "${ANDROID_ABI}" MATCHES "x86_64$")
2426
# Enable pointer compression on 64 bit platforms
@@ -179,12 +181,6 @@ MESSAGE(STATUS "# CMAKE_CXX_FLAGS: " ${CMAKE_CXX_FLAGS})
179181
target_link_libraries(NativeScript ${PROJECT_SOURCE_DIR}/src/main/libs/${ANDROID_ABI}/libzip.a)
180182
target_link_libraries(NativeScript ${PROJECT_SOURCE_DIR}/src/main/libs/${ANDROID_ABI}/libv8_monolith.a)
181183

182-
if("${ANDROID_ABI}" MATCHES "armeabi-v7a$" OR "${ANDROID_ABI}" MATCHES "x86$")
183-
# On API Level 19 and lower we need to link with android_support
184-
# because it contains some implementation of functions such as "strtoll" and "strtoul"
185-
MESSAGE(STATUS "# Linking with libandroid_support.a")
186-
target_link_libraries(NativeScript ${ANDROID_NDK_ROOT}/sources/cxx-stl/llvm-libc++/libs/${ANDROID_ABI}/libandroid_support.a)
187-
endif()
188184

189185
# Command info: https://cmake.org/cmake/help/v3.4/command/find_library.html
190186
# Searches for a specified prebuilt library and stores the path as a

test-app/runtime/build.gradle

+12-8
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ if (useCCache) {
2323

2424
def defaultNdkVersion = "27.2.12479018"
2525

26-
2726
def hasNdkVersion = project.hasProperty("ndkVersion")
2827
if (hasNdkVersion) {
2928
println "Runtime using NDK version " + ndkVersion
@@ -115,7 +114,7 @@ android {
115114
// arguments "-DANDROID_TOOLCHAIN=clang", "-DANDROID_STL=c++_static", "-DANDROID_NDK_ROOT=${NDK_PATH}"
116115

117116
cppFlags "-std=c++20"
118-
arguments "-DANDROID_STL=c++_static", "-DANDROID_NDK_ROOT=${NDK_PATH}"
117+
arguments "-DANDROID_STL=c++_static", "-DANDROID_NDK_ROOT=${NDK_PATH}", "-DANDROID_SUPPORT_FLEXIBLE_PAGE_SIZES=ON"
119118
}
120119
}
121120

@@ -129,6 +128,11 @@ android {
129128
}
130129
}
131130

131+
compileOptions {
132+
sourceCompatibility JavaVersion.VERSION_17
133+
targetCompatibility JavaVersion.VERSION_17
134+
}
135+
132136
buildTypes {
133137
release {
134138
minifyEnabled false
@@ -145,13 +149,13 @@ android {
145149
}
146150

147151
allprojects {
148-
gradle.projectsEvaluated {
149-
tasks.withType(JavaCompile).tap {
150-
configureEach {
151-
//options.compilerArgs << "-Xlint:all" << "-Werror"
152-
}
153-
}
152+
afterEvaluate {
153+
tasks.withType(JavaCompile).configureEach {
154+
// remove after "-Xlint:-classfile" https://issuetracker.google.com/issues/359561906
155+
// todo remove "-Xlint:-this-escape" after updating runtime-binding-generator
156+
options.compilerArgs << "-Xlint:all" << "-Werror" << "-Xlint:-classfile" << "-Xlint:-this-escape"
154157
}
158+
}
155159
}
156160

157161
dependencies {

test-app/runtime/src/main/java/com/tns/NativeScriptAbstractMap.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public abstract class NativeScriptAbstractMap<K, V> implements Map<K, V> {
4949
*
5050
* @since 1.6
5151
*/
52-
public static class SimpleImmutableEntry<K, V> implements Map.Entry<K, V>, Serializable {
52+
public static class SimpleImmutableEntry<K extends Serializable, V extends Serializable> implements Map.Entry<K, V>, Serializable {
5353
private static final long serialVersionUID = 7138329143949025153L;
5454

5555
private final K key;
@@ -111,7 +111,7 @@ public String toString() {
111111
*
112112
* @since 1.6
113113
*/
114-
public static class SimpleEntry<K, V> implements Map.Entry<K, V>, Serializable {
114+
public static class SimpleEntry<K extends Serializable, V extends Serializable> implements Map.Entry<K, V>, Serializable {
115115
private static final long serialVersionUID = -8499721149061103585L;
116116

117117
private final K key;

0 commit comments

Comments
 (0)