Skip to content

Commit

Permalink
Update Java version to JDK 21.0.5+11 (#563)
Browse files Browse the repository at this point in the history
* Update Java version to JDK 21.0.5+11

* Update CI Java version to JDK 21.0.5+11.0.LTS

* Update docker images version.
Install R8 utility sepratly from Google bucket. That fixed issue with D8 and JDK21 (NPE).
Update how main dex list created because now it should pass in form of Proguard rules (--main-dex-list vs --main-dex-rules).

---------

Co-authored-by: Kharkunov Eugene <[email protected]>
  • Loading branch information
vlaaad and ekharkunov authored Nov 20, 2024
1 parent 8dbafb4 commit 2d8d83e
Show file tree
Hide file tree
Showing 26 changed files with 47 additions and 32 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/application-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
- name: Install Java
uses: actions/setup-java@8df1039502a15bceb9433410b1a100fbe190c53b
with:
java-version: '17'
java-version: '21.0.5+11.0.LTS'
distribution: 'temurin'
- name: Setup Gradle
uses: gradle/actions/setup-gradle@d156388eb19639ec20ade50009f3d199ce1e2808
Expand Down Expand Up @@ -94,7 +94,7 @@ jobs:
- name: Install Java
uses: actions/setup-java@8df1039502a15bceb9433410b1a100fbe190c53b
with:
java-version: '17'
java-version: '21.0.5+11.0.LTS'
distribution: 'temurin'
- name: Setup Gradle
uses: gradle/actions/setup-gradle@d156388eb19639ec20ade50009f3d199ce1e2808
Expand Down Expand Up @@ -160,7 +160,7 @@ jobs:
- name: Install Java
uses: actions/setup-java@8df1039502a15bceb9433410b1a100fbe190c53b
with:
java-version: '17'
java-version: '21.0.5+11.0.LTS'
distribution: 'temurin'
- name: Setup Gradle
uses: gradle/actions/setup-gradle@d156388eb19639ec20ade50009f3d199ce1e2808
Expand Down
6 changes: 3 additions & 3 deletions server/build-docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ DOCKER_NINTENDO_PRIVATE_REGISTRY=europe-west1-docker.pkg.dev/extender-426409/ext

# base images
echo "Base image"
DM_PACKAGES_URL=$DM_PACKAGES_URL docker buildx build --secret id=DM_PACKAGES_URL --platform linux/amd64 -t $DOCKER_REGISTRY/extender-base-env:1.2.1 -t $DOCKER_REGISTRY/extender-base-env:latest -f $SCRIPT_DIR/docker/Dockerfile.base-env $SCRIPT_DIR/docker
DM_PACKAGES_URL=$DM_PACKAGES_URL docker buildx build --secret id=DM_PACKAGES_URL --platform linux/amd64 -t $DOCKER_REGISTRY/extender-base-env:1.3.0 -t $DOCKER_REGISTRY/extender-base-env:latest -f $SCRIPT_DIR/docker/Dockerfile.base-env $SCRIPT_DIR/docker
echo "Linux image"
DM_PACKAGES_URL=$DM_PACKAGES_URL docker buildx build --secret id=DM_PACKAGES_URL --platform linux/amd64 -t $DOCKER_REGISTRY/extender-linux-env:latest -f $SCRIPT_DIR/docker/Dockerfile.linux-env $SCRIPT_DIR/docker

Expand Down Expand Up @@ -57,10 +57,10 @@ for request in $REQUESTED; do
DM_PACKAGES_URL=$DM_PACKAGES_URL docker buildx build --secret id=DM_PACKAGES_URL --platform linux/amd64 -t $DOCKER_NINTENDO_PRIVATE_REGISTRY/extender-${install}-env:latest -f $SCRIPT_DIR/docker/Dockerfile.$(echo $install | sed 's,-,.,')-env $SCRIPT_DIR/docker
;;
wine)
DM_PACKAGES_URL=$DM_PACKAGES_URL docker buildx build --secret id=DM_PACKAGES_URL --platform linux/amd64 -t $DOCKER_REGISTRY/extender-wine-env:1.2.1 -t $DOCKER_REGISTRY/extender-wine-env:latest -f $SCRIPT_DIR/docker/Dockerfile.wine-env $SCRIPT_DIR/docker
DM_PACKAGES_URL=$DM_PACKAGES_URL docker buildx build --secret id=DM_PACKAGES_URL --platform linux/amd64 -t $DOCKER_REGISTRY/extender-wine-env:1.3.0 -t $DOCKER_REGISTRY/extender-wine-env:latest -f $SCRIPT_DIR/docker/Dockerfile.wine-env $SCRIPT_DIR/docker
;;
android)
DM_PACKAGES_URL=$DM_PACKAGES_URL docker buildx build --secret id=DM_PACKAGES_URL --platform linux/amd64 -t $DOCKER_REGISTRY/extender-android-env:1.33 -f $SCRIPT_DIR/docker/Dockerfile.android-env $SCRIPT_DIR/docker
DM_PACKAGES_URL=$DM_PACKAGES_URL docker buildx build --secret id=DM_PACKAGES_URL --platform linux/amd64 -t $DOCKER_REGISTRY/extender-android-env:1.4.0 -f $SCRIPT_DIR/docker/Dockerfile.android-env $SCRIPT_DIR/docker
;;
android-ndk*|winsdk-*|emsdk-*)
DM_PACKAGES_URL=$DM_PACKAGES_URL docker buildx build --secret id=DM_PACKAGES_URL --platform linux/amd64 -t $DOCKER_REGISTRY/extender-${install}-env:latest -f $SCRIPT_DIR/docker/Dockerfile.$(echo $install | sed 's,-,.,')-env $SCRIPT_DIR/docker
Expand Down
2 changes: 1 addition & 1 deletion server/docker/Dockerfile.android-env
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM europe-west1-docker.pkg.dev/extender-426409/extender-public-registry/extender-base-env:1.2.1
FROM europe-west1-docker.pkg.dev/extender-426409/extender-public-registry/extender-base-env:1.3.0

# Technically part of the Android build, but also required by the GradleService.java
# until it can be disabled (e.g. by looking for the existance of GRADLE_USER_HOME)
Expand Down
11 changes: 10 additions & 1 deletion server/docker/Dockerfile.android.ndk25-env
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM europe-west1-docker.pkg.dev/extender-426409/extender-public-registry/extender-android-env:1.3.3
FROM europe-west1-docker.pkg.dev/extender-426409/extender-public-registry/extender-android-env:1.4.0

#
# Android SDK/NDK
Expand Down Expand Up @@ -99,6 +99,15 @@ RUN --mount=type=secret,id=DM_PACKAGES_URL,required=true \
aapt v && \
aapt2 version

# download and install R8 utility separatly. It's done in that way because
# R8/D8 received fixes from time to time which not populated with build tools
# It's ok that R8.jar downloaded but saved to D8.jar. Can't find D8 as separate utility.
# R8 contains all classes of D8.
ENV R8_VERSION=8.7.0-dev
RUN \
wget -O ${ANDROID_SDK_BUILD_TOOLS_PATH_34}/lib/d8.jar https://storage.googleapis.com/r8-releases/raw/${R8_VERSION}/r8.jar && \
wget -O ${ANDROID_SDK_BUILD_TOOLS_PATH_33}/lib/d8.jar https://storage.googleapis.com/r8-releases/raw/${R8_VERSION}/r8.jar

# Since dotnet cannot really cross compile, we need to create a "ar" shim for "llvm-ar"
# As long as it's in the path, it will be picked up
RUN \
Expand Down
4 changes: 2 additions & 2 deletions server/docker/Dockerfile.base-env
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ RUN \
#
# Java
#
ENV JAVA_HOME=/usr/local/jdk-17.0.7+7
ENV JAVA_HOME=/usr/local/jdk-21.0.5+11
ENV PATH=${JAVA_HOME}/bin:${PATH}

RUN locale-gen en_US.UTF-8
Expand All @@ -30,7 +30,7 @@ ENV LANG=en_US.UTF-8 \
LC_ALL=en_US.UTF-8

RUN \
wget -q -O - https://aka.ms/download-jdk/microsoft-jdk-17.0.7-linux-x64.tar.gz | tar xz -C /usr/local && \
wget -q -O - https://github.com/adoptium/temurin21-binaries/releases/download/jdk-21.0.5%2B11/OpenJDK21U-jdk_x64_linux_hotspot_21.0.5_11.tar.gz | tar xz -C /usr/local && \
java -version && \
javac -version

Expand Down
2 changes: 1 addition & 1 deletion server/docker/Dockerfile.emsdk.2011-env
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM europe-west1-docker.pkg.dev/extender-426409/extender-public-registry/extender-base-env:1.2.1
FROM europe-west1-docker.pkg.dev/extender-426409/extender-public-registry/extender-base-env:1.3.0

#
# EMSCRIPTEN
Expand Down
2 changes: 1 addition & 1 deletion server/docker/Dockerfile.emsdk.3155-env
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM europe-west1-docker.pkg.dev/extender-426409/extender-public-registry/extender-base-env:1.2.1
FROM europe-west1-docker.pkg.dev/extender-426409/extender-public-registry/extender-base-env:1.3.0

# Ubuntu still seem to use python3 3.8 as default version
RUN \
Expand Down
2 changes: 1 addition & 1 deletion server/docker/Dockerfile.emsdk.3165-env
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM europe-west1-docker.pkg.dev/extender-426409/extender-public-registry/extender-base-env:1.2.1
FROM europe-west1-docker.pkg.dev/extender-426409/extender-public-registry/extender-base-env:1.3.0

# Ubuntu still seem to use python3 3.8 as default version
RUN \
Expand Down
2 changes: 1 addition & 1 deletion server/docker/Dockerfile.linux-env
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM europe-west1-docker.pkg.dev/extender-426409/extender-public-registry/extender-base-env:1.2.1
FROM europe-west1-docker.pkg.dev/extender-426409/extender-public-registry/extender-base-env:1.3.0

RUN \
echo "LINUX TOOLS + COMPILER" && \
Expand Down
2 changes: 1 addition & 1 deletion server/docker/Dockerfile.nssdk.1532-env
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM europe-west1-docker.pkg.dev/extender-426409/extender-public-registry/extender-wine-env:1.2.1
FROM europe-west1-docker.pkg.dev/extender-426409/extender-public-registry/extender-wine-env:1.3.0

# Added in version 1.4.4
ENV NINTENDO_SDK_ROOT_15_3_2=${PLATFORMSDK_DIR}/nx-15.3.2
Expand Down
2 changes: 1 addition & 1 deletion server/docker/Dockerfile.nssdk.1753-env
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM europe-west1-docker.pkg.dev/extender-426409/extender-public-registry/extender-wine-env:1.2.1
FROM europe-west1-docker.pkg.dev/extender-426409/extender-public-registry/extender-wine-env:1.3.0

ENV NINTENDO_SDK_ROOT_17_5=${PLATFORMSDK_DIR}/nx-17.5.3
ENV SWITCH_SDK_17_FILENAME=nx64-sdk-17.5.3.tar.gz
Expand Down
2 changes: 1 addition & 1 deletion server/docker/Dockerfile.nssdk.1832-env
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM europe-west1-docker.pkg.dev/extender-426409/extender-public-registry/extender-wine-env:1.2.1
FROM europe-west1-docker.pkg.dev/extender-426409/extender-public-registry/extender-wine-env:1.3.0

ENV NINTENDO_SDK_ROOT_18_3=${PLATFORMSDK_DIR}/nx-18.3.2
ENV SWITCH_SDK_18_FILENAME=nx64-sdk-18.3.2.tar.gz
Expand Down
2 changes: 1 addition & 1 deletion server/docker/Dockerfile.ps4.10500-env
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM europe-west1-docker.pkg.dev/extender-426409/extender-public-registry/extender-wine-env:1.2.1
FROM europe-west1-docker.pkg.dev/extender-426409/extender-public-registry/extender-wine-env:1.3.0

ENV PS4_SDK_10=${PLATFORMSDK_DIR}/ps4-sdk-10.500

Expand Down
2 changes: 1 addition & 1 deletion server/docker/Dockerfile.ps4.11000-env
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM europe-west1-docker.pkg.dev/extender-426409/extender-public-registry/extender-wine-env:1.2.1
FROM europe-west1-docker.pkg.dev/extender-426409/extender-public-registry/extender-wine-env:1.3.0

ENV PS4_SDK_11_VERSION=11.000
ENV PS4_SDK_11=${PLATFORMSDK_DIR}/ps4-sdk-${PS4_SDK_11_VERSION}
Expand Down
2 changes: 1 addition & 1 deletion server/docker/Dockerfile.ps4.12000-env
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM europe-west1-docker.pkg.dev/extender-426409/extender-public-registry/extender-wine-env:1.2.1
FROM europe-west1-docker.pkg.dev/extender-426409/extender-public-registry/extender-wine-env:1.3.0

ENV PS4_SDK_VERSION=12.000
ENV PS4_SDK=${PLATFORMSDK_DIR}/ps4-sdk-${PS4_SDK_VERSION}
Expand Down
2 changes: 1 addition & 1 deletion server/docker/Dockerfile.ps5.10000-env
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM europe-west1-docker.pkg.dev/extender-426409/extender-public-registry/extender-wine-env:1.2.1
FROM europe-west1-docker.pkg.dev/extender-426409/extender-public-registry/extender-wine-env:1.3.0

ENV PS5_SDK_VERSION=10.000
ENV PS5_SDK=${PLATFORMSDK_DIR}/ps5-sdk-${PS5_SDK_VERSION}
Expand Down
2 changes: 1 addition & 1 deletion server/docker/Dockerfile.ps5.8000-env
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM europe-west1-docker.pkg.dev/extender-426409/extender-public-registry/extender-wine-env:1.2.1
FROM europe-west1-docker.pkg.dev/extender-426409/extender-public-registry/extender-wine-env:1.3.0

ENV PS5_SDK_8_VERSION=8.000
ENV PS5_SDK_8=${PLATFORMSDK_DIR}/ps5-sdk-${PS5_SDK_8_VERSION}
Expand Down
2 changes: 1 addition & 1 deletion server/docker/Dockerfile.ps5.9000-env
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM europe-west1-docker.pkg.dev/extender-426409/extender-public-registry/extender-wine-env:1.2.1
FROM europe-west1-docker.pkg.dev/extender-426409/extender-public-registry/extender-wine-env:1.3.0

ENV PS5_SDK_9_VERSION=9.000
ENV PS5_SDK_9=${PLATFORMSDK_DIR}/ps5-sdk-${PS5_SDK_9_VERSION}
Expand Down
2 changes: 1 addition & 1 deletion server/docker/Dockerfile.wine-env
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM europe-west1-docker.pkg.dev/extender-426409/extender-public-registry/extender-base-env:1.2.1
FROM europe-west1-docker.pkg.dev/extender-426409/extender-public-registry/extender-base-env:1.3.0

# Installation notes: https://wiki.winehq.org/Ubuntu
# TODO: Backup the files as descibed here: https://wiki.winehq.org/Ubuntu
Expand Down
2 changes: 1 addition & 1 deletion server/docker/Dockerfile.winsdk.2019-env
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM europe-west1-docker.pkg.dev/extender-426409/extender-public-registry/extender-wine-env:1.2.1
FROM europe-west1-docker.pkg.dev/extender-426409/extender-public-registry/extender-wine-env:1.3.0

ENV \
PLATFORMSDK_WIN32=$PLATFORMSDK_DIR/Win32 \
Expand Down
2 changes: 1 addition & 1 deletion server/docker/Dockerfile.winsdk.2022-env
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM europe-west1-docker.pkg.dev/extender-426409/extender-public-registry/extender-wine-env:1.2.1
FROM europe-west1-docker.pkg.dev/extender-426409/extender-public-registry/extender-wine-env:1.3.0

ENV PLATFORMSDK_WIN32=$PLATFORMSDK_DIR/Win32

Expand Down
8 changes: 7 additions & 1 deletion server/src/main/java/com/defold/extender/Extender.java
Original file line number Diff line number Diff line change
Expand Up @@ -2094,7 +2094,9 @@ private File buildMainDexList(List<String> jars) throws ExtenderException {
try {
mainList.createNewFile();
for (String classFile : mainClassNames) {
FileUtils.writeStringToFile(mainList, classFile + "\n", Charset.defaultCharset(), true);
// create main dex list in form of Proguards rules. Additional info https://github.com/defold/extender/issues/393
classFile = classFile.replace("/", ".").replace(".class", "");
FileUtils.writeStringToFile(mainList, String.format("-keep class %s { *; }\n", classFile), Charset.defaultCharset(), true);
}
} catch (IOException e) {
throw new ExtenderException(e, "Failed to write to " + mainList.getAbsolutePath());
Expand All @@ -2114,6 +2116,10 @@ private File[] buildClassesDex(List<String> jars, File mainDexList) throws Exten
context.put("engineJars", empty_list);
context.put("mainDexList", mainDexList.getAbsolutePath());

// replace parameter name because '--main-dex-list' is deprecated and reported as error
// we can't change command format for older version of engine so replace parameter here.
// Remove when old versions won't be supported.
platformConfig.dxCmd = platformConfig.dxCmd.replace("--main-dex-list", "--main-dex-rules");
executeCommand(platformConfig.dxCmd, context);

File[] classes = ExtenderUtil.listFilesMatching(buildDirectory, "^classes(|[0-9]+)\\.dex$");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ private String getRemotePlatformSdkMappings(String hash) throws IOException, URI
return new String(body.readAllBytes(), StandardCharsets.UTF_8);
}
}
throw new ExtenderException(String.format("Cannot found platform sdks mappings for hash: %s", hash));
throw new ExtenderException(String.format("Cannot find platform sdks mappings for hash: %s", hash));
}

public String getPlatformSdkMappings(String hash) throws IOException, URISyntaxException, ExtenderException {
Expand Down
2 changes: 1 addition & 1 deletion server/src/main/resources/template.gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ android.enableJetifier={{android-enable-jetifier}}
# Gradle will stop resolving dependencies if android.useAndroidX is false and a dependency is using Android X
android.useAndroidX={{android-enable-jetifier}}

org.gradle.java.home=/usr/local/jdk-17.0.7+7
org.gradle.java.home=/usr/local/jdk-21.0.5+11
4 changes: 2 additions & 2 deletions server/test-data/jars/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ ANDROID_JAR=${ANDROID_HOME}/platforms/android-${ANDROID_SDK_VERSION}/android.jar
mkdir -p $BUILD

# Dummy.jar
javac -source 1.6 -target 1.6 -cp . com/defold/dummy/Dummy.java
javac -source 1.8 -target 1.8 -cp . com/defold/dummy/Dummy.java
jar -cvf ../ext/lib/armv7-android/Dummy.jar com

# VeryLarge.jar
Expand Down Expand Up @@ -46,7 +46,7 @@ do

echo "done."

javac -source 1.6 -target 1.6 -cp . $VERYLARGE_JAVA
javac -source 1.8 -target 1.8 -cp . $VERYLARGE_JAVA
rm $VERYLARGE_JAVA
jar -cvf ../../ext/lib/armv7-android/$NAME.jar com

Expand Down
2 changes: 1 addition & 1 deletion server/test-data/sdk/a/defoldsdk/share/java/build.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@

javac -source 1.6 -target 1.6 -cp . com/defoldtest/engine/Engine.java
javac -source 1.8 -target 1.8 -cp . com/defoldtest/engine/Engine.java
jar cvf Engine.jar com

0 comments on commit 2d8d83e

Please sign in to comment.