Support java 17 sealed classes

This commit is contained in:
Andrea Cavalli 2021-10-23 19:13:08 +02:00
parent c9d501f788
commit 5ed8eaf837
3 changed files with 38 additions and 8 deletions

View File

@ -54,10 +54,12 @@ echo "Deleting old data..."
[ -d ./generated/tdjni_build/ ] && rm -r ./generated/tdjni_build/
[ -d ./generated/tdjni_bin/ ] && rm -r ./generated/tdjni_bin/
[ -d ./generated/tdjni_docs/ ] && rm -r ./generated/tdjni_docs/
[ -f ./generated/src/main/java17/${JAVA_API_PACKAGE_PATH}/TdApi.java ] && rm ./generated/src/main/java17/${JAVA_API_PACKAGE_PATH}/TdApi.java
[ -f ./generated/src/main/java/${JAVA_API_PACKAGE_PATH}/TdApi.java ] && rm ./generated/src/main/java/${JAVA_API_PACKAGE_PATH}/TdApi.java
# Create missing folders
echo "Creating missing folders..."
[ -d "./generated/src/main/java17/${JAVA_API_PACKAGE_PATH}/" ] || mkdir -p "./generated/src/main/java17/${JAVA_API_PACKAGE_PATH}/"
[ -d "./generated/src/main/java/${JAVA_API_PACKAGE_PATH}/" ] || mkdir -p "./generated/src/main/java/${JAVA_API_PACKAGE_PATH}/"
[ -d "./generated/src/main/java/${JAVA_LIB_PACKAGE_PATH}/" ] || mkdir -p "./generated/src/main/java/${JAVA_LIB_PACKAGE_PATH}/"
[ -d ./generated/tdjni_build/ ] || mkdir ./generated/tdjni_build/
@ -83,18 +85,32 @@ echo "Telegram source path: '$(realpath -m ./implementation/)'"
echo "Generating TdApi.java..."
./td_tools/td/generate/td_generate_java_api TdApi "./implementation/td/generate/scheme/td_api.tlo" "./src/main/java" "$JAVA_API_PACKAGE_PATH"
php ./implementation/td/generate/JavadocTlDocumentationGenerator.php "./implementation/td/generate/scheme/td_api.tl" "./src/main/java/${JAVA_API_PACKAGE_PATH}/TdApi.java"
mv "./src/main/java/${JAVA_API_PACKAGE_PATH}/TdApi.java" "./src/main/java/${JAVA_API_PACKAGE_PATH}/php_TdApi.java"
echo "Patching TdApi.java..."
${PYTHON_EXECUTABLE} ../scripts/core/tdlib-serializer "$(realpath -m ./src/main/java/${JAVA_API_PACKAGE_PATH}/TdApi.java)" "$(realpath -m ./src/main/java/${JAVA_API_PACKAGE_PATH}/new_TdApi.java)" "$(realpath -m ../scripts/core/tdlib-serializer/headers.txt)"
rm ./src/main/java/${JAVA_API_PACKAGE_PATH}/TdApi.java
echo "Patching TdApi.java for Java 17..."
${PYTHON_EXECUTABLE} ../scripts/core/tdlib-serializer "$(realpath -m ./src/main/java/${JAVA_API_PACKAGE_PATH}/php_TdApi.java)" "$(realpath -m ./src/main/java17/${JAVA_API_PACKAGE_PATH}/unexpanded_TdApi.java)" "$(realpath -m ../scripts/core/tdlib-serializer/headers.txt)" true
if [[ "$OPERATING_SYSTEM_NAME" == "osx" ]]; then
unexpand --tabs=2 ./src/main/java/${JAVA_API_PACKAGE_PATH}/new_TdApi.java > ./src/main/java/${JAVA_API_PACKAGE_PATH}/TdApi.java
unexpand --tabs=2 ./src/main/java17/${JAVA_API_PACKAGE_PATH}/unexpanded_TdApi.java > ./src/main/java17/${JAVA_API_PACKAGE_PATH}/TdApi.java
else
unexpand -t 2 ./src/main/java/${JAVA_API_PACKAGE_PATH}/new_TdApi.java > ./src/main/java/${JAVA_API_PACKAGE_PATH}/TdApi.java
unexpand -t 2 ./src/main/java17/${JAVA_API_PACKAGE_PATH}/unexpanded_TdApi.java > ./src/main/java17/${JAVA_API_PACKAGE_PATH}/TdApi.java
fi
rm ./src/main/java/${JAVA_API_PACKAGE_PATH}/new_TdApi.java
rm ./src/main/java17/${JAVA_API_PACKAGE_PATH}/unexpanded_TdApi.java
echo "Generated '$(realpath -m ./src/main/java/${JAVA_API_PACKAGE_PATH}/TdApi.java)'"
echo "Generated '$(realpath -m ./src/main/java17/${JAVA_API_PACKAGE_PATH}/TdApi.java)'"
echo "Patching TdApi.java for Java 8..."
${PYTHON_EXECUTABLE} ../scripts/core/tdlib-serializer "$(realpath -m ./src/main/java/${JAVA_API_PACKAGE_PATH}/php_TdApi.java)" "$(realpath -m ./src/main/java/${JAVA_API_PACKAGE_PATH}/unexpanded_TdApi.java)" "$(realpath -m ../scripts/core/tdlib-serializer/headers.txt)" false
if [[ "$OPERATING_SYSTEM_NAME" == "osx" ]]; then
unexpand --tabs=2 ./src/main/java/${JAVA_API_PACKAGE_PATH}/unexpanded_TdApi.java > ./src/main/java/${JAVA_API_PACKAGE_PATH}/TdApi.java
else
unexpand -t 2 ./src/main/java/${JAVA_API_PACKAGE_PATH}/unexpanded_TdApi.java > ./src/main/java/${JAVA_API_PACKAGE_PATH}/TdApi.java
fi
rm ./src/main/java/${JAVA_API_PACKAGE_PATH}/unexpanded_TdApi.java
echo "Generated '$(realpath -m ./src/main/java17/${JAVA_API_PACKAGE_PATH}/TdApi.java)'"
rm ./src/main/java/${JAVA_API_PACKAGE_PATH}/php_TdApi.java
echo "Done."
exit 0

@ -1 +1 @@
Subproject commit 599c05f320898f37bd9e52f917ae4bcb2ecc2f2b
Subproject commit 36f96dfaf59b8add1813d57cc12467ae8eef55f0

View File

@ -134,6 +134,20 @@
<release>9</release>
</configuration>
</execution>
<!-- compile sources with Java 17 -->
<execution>
<id>java-17-module-compile</id>
<goals>
<goal>compile</goal>
</goals>
<configuration>
<release>17</release>
<compileSourceRoots>
<compileSourceRoot>${project.basedir}/src/main/java17</compileSourceRoot>
</compileSourceRoots>
<multiReleaseOutput>true</multiReleaseOutput>
</configuration>
</execution>
<!-- compile sources with Java 9 to generate and validate module-info.java -->
<execution>
<id>java-9-module-compile</id>