Upgrade Hermes to use Gradle v6.5 (#306)

Summary:
Pull Request resolved: https://github.com/facebook/hermes/pull/306

React Native uses Gradle 6.5 for their open source builds now,
so Hermes should too.

Doing this required fixing a few places:
* Bump `com.android.tools.build:gradle` to 4.0.0
(based on this article https://developer.android.com/studio/releases/gradle-plugin)
* Deprecated keys for `task githubRelease`
* `./gradlew wrapper --gradle-version 6.5` two times to upgrade the
gradle version and the wrapper script
* Renamed `transformNativeLibsWithMergeJniLibsFor*` to `merge*NativeLibs`
* Remove `uses-sdk` from AndroidManifest.xml since it was deprecated

Reviewed By: fkgozali

Differential Revision: D22803177

fbshipit-source-id: 16cc8b1f0f2e3c637f1a33d161c71bf8a73ef3c5
This commit is contained in:
Riley Dulin 2020-07-29 14:04:04 -07:00 коммит произвёл Facebook GitHub Bot
Родитель 557e181be5
Коммит 43927258eb
11 изменённых файлов: 32 добавлений и 32 удалений

Просмотреть файл

@ -47,7 +47,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.0'
classpath 'com.android.tools.build:gradle:4.0.0'
}
}
@ -80,9 +80,9 @@ task copyPublicHeaders(type: Copy) {
}
task githubRelease(dependsOn: ['hermes:build', 'cppruntime:build', 'copyApiHeaders', 'copyJsiHeaders', 'copyPublicHeaders'], type: Tar) {
baseName = "hermes-runtime-android"
version = "v" + release_version
extension = "tar.gz"
archiveBaseName = "hermes-runtime-android"
archiveVersion = "v" + release_version
archiveExtension = "tar.gz"
compression = Compression.GZIP
destinationDirectory = file("${hermes_ws}/build_android/distributions")
from "$outputDir"

Просмотреть файл

@ -1,3 +1,2 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.facebook.hermes.cppruntime">
<uses-sdk android:minSdkVersion="9" />
</manifest>

Просмотреть файл

@ -0,0 +1,3 @@
android.useAndroidX=true
android.enableJetifier=true

Двоичные данные
android/gradle/wrapper/gradle-wrapper.jar поставляемый

Двоичный файл не отображается.

Просмотреть файл

@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

37
android/gradlew поставляемый
Просмотреть файл

@ -7,7 +7,7 @@
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
@ -82,6 +82,7 @@ esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
@ -125,10 +126,11 @@ if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
# For Cygwin, switch paths to Windows format before running java
if $cygwin ; then
# For Cygwin or MSYS, switch paths to Windows format before running java
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath
@ -154,19 +156,19 @@ if $cygwin ; then
else
eval `echo args$i`="\"$arg\""
fi
i=$((i+1))
i=`expr $i + 1`
done
case $i in
(0) set -- ;;
(1) set -- "$args0" ;;
(2) set -- "$args0" "$args1" ;;
(3) set -- "$args0" "$args1" "$args2" ;;
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
0) set -- ;;
1) set -- "$args0" ;;
2) set -- "$args0" "$args1" ;;
3) set -- "$args0" "$args1" "$args2" ;;
4) set -- "$args0" "$args1" "$args2" "$args3" ;;
5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi
@ -175,14 +177,9 @@ save () {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}
APP_ARGS=$(save "$@")
APP_ARGS=`save "$@"`
# Collect all arguments for the java command, following the shell quoting and substitution rules
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
cd "$(dirname "$0")"
fi
exec "$JAVACMD" "$@"

6
android/gradlew.bat поставляемый
Просмотреть файл

@ -5,7 +5,7 @@
@rem you may not use this file except in compliance with the License.
@rem You may obtain a copy of the License at
@rem
@rem http://www.apache.org/licenses/LICENSE-2.0
@rem https://www.apache.org/licenses/LICENSE-2.0
@rem
@rem Unless required by applicable law or agreed to in writing, software
@rem distributed under the License is distributed on an "AS IS" BASIS,
@ -29,6 +29,9 @@ if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
@ -81,6 +84,7 @@ set CMD_LINE_ARGS=%*
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%

Просмотреть файл

@ -74,7 +74,7 @@ android {
file("$aarDir/hermes.aar").renameTo("${rootProject.ext.outputDir}/hermes-release.aar")
}
}
tasks.named("transformNativeLibsWithMergeJniLibsForDebug").configure {
tasks.named("mergeDebugNativeLibs").configure {
doLast { task ->
copy {
from(task)
@ -82,7 +82,7 @@ android {
}
}
}
tasks.named("transformNativeLibsWithMergeJniLibsForRelease").configure {
tasks.named("mergeReleaseNativeLibs").configure {
doLast { task ->
copy {
from(task)

Просмотреть файл

@ -1,3 +1,2 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.facebook.hermes">
<uses-sdk android:minSdkVersion="9" />
</manifest>

Просмотреть файл

@ -1,3 +1,2 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.facebook.hermes.intl">
<uses-sdk android:minSdkVersion="24" />
</manifest>

Просмотреть файл

@ -1,3 +1,2 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.facebook.hermes.intltest">
<uses-sdk android:minSdkVersion="24" />
</manifest>