Skip to content

Commit

Permalink
Update Gradle versions to 7 (#1650)
Browse files Browse the repository at this point in the history
* Update gradle versions to 7

* Update Java version and buildToolsVersion

* Update integration_tests.yml

* Update integration_tests.yml

* More fixes

* Update google services dependency version

* Remove logic to set ANDROID_SDK_HOME

* Update minSdkVersion.

* Try working around a build tools error on Windows.

* Call d8 directly via java instead of by broken shell script.

* Add note about minSdkVersion.

* Change Java version in CI build too.

---------

Co-authored-by: Jon Simantov <[email protected]>
  • Loading branch information
a-maurice and jonsimantov authored Sep 26, 2024
1 parent 06ab3ec commit c5b228d
Show file tree
Hide file tree
Showing 71 changed files with 329 additions and 240 deletions.
5 changes: 2 additions & 3 deletions .github/workflows/android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,9 @@ jobs:
- name: setup Xcode version (macos)
if: runner.os == 'macOS'
run: sudo xcode-select -s /Applications/Xcode_${{ env.xcodeVersion }}.app/Contents/Developer
- name: Force Java 8 (macOS)
if: startsWith(matrix.os, 'macos')
- name: Force Java 11
shell: bash
run: echo "JAVA_HOME=${JAVA_HOME_8_X64}" >> $GITHUB_ENV
run: echo "JAVA_HOME=${JAVA_HOME_11_X64}" >> $GITHUB_ENV
- name: Store git credentials for all git commands
# Forces all git commands to use authenticated https, to prevent throttling.
shell: bash
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/cpp-packaging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,9 @@ jobs:
strategy:
fail-fast: false
steps:
- name: Force Java 11
shell: bash
run: echo "JAVA_HOME=${JAVA_HOME_11_X64}" >> $GITHUB_ENV
- name: fetch SDK
uses: actions/checkout@v3
with:
Expand Down
9 changes: 4 additions & 5 deletions .github/workflows/integration_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -426,10 +426,9 @@ jobs:
with:
ref: ${{needs.check_and_prepare.outputs.github_ref}}
submodules: true
- name: Force Java 8 (macOS)
if: startsWith(matrix.os, 'macos')
- name: Force Java 11
shell: bash
run: echo "JAVA_HOME=${JAVA_HOME_8_X64}" >> $GITHUB_ENV
run: echo "JAVA_HOME=${JAVA_HOME_11_X64}" >> $GITHUB_ENV
- name: Add msbuild to PATH (Windows)
if: startsWith(matrix.os, 'windows')
uses: microsoft/[email protected]
Expand Down Expand Up @@ -1058,11 +1057,11 @@ jobs:
run: |
echo "device_type=$( python scripts/gha/print_matrix_configuration.py -k ${{ matrix.android_device }} -get_device_type)" >> $GITHUB_OUTPUT
echo "device=$( python scripts/gha/print_matrix_configuration.py -k ${{ matrix.android_device }} -get_ftl_device_list)" >> $GITHUB_OUTPUT
- name: Setup java 8 for test_simulator.py
- name: Setup java 11 for test_simulator.py
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '8'
java-version: '11'
- name: Run Android integration tests on Emulator locally
timeout-minutes: 180
if: steps.device-info.outputs.device_type == 'virtual'
Expand Down
40 changes: 26 additions & 14 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ endif()
# Set directories needed by the Firebase subprojects
# Directory to store generated files.
set(FIREBASE_GEN_FILE_DIR ${CMAKE_BINARY_DIR}/generated)

# Directory for any shared scripts.
set(FIREBASE_SCRIPT_DIR ${CMAKE_CURRENT_LIST_DIR})

Expand Down Expand Up @@ -227,20 +228,30 @@ set(FIRESTORE_INCLUDE_OBJC OFF CACHE BOOL "Disabled for the CPP SDK")
set(RE2_BUILD_TESTING OFF CACHE BOOL "")

if(FIREBASE_CPP_USE_PRIOR_GRADLE_BUILD)
# Quote meta characters in ${CMAKE_CURRENT_LIST_DIR} so we can
# match it in a regex.
# For example, '/path/with/+meta/char.acters' will become
# '/path/with/\+meta/char\.acters'.
string(REGEX REPLACE
"([][+.*()^])" "\\\\\\1" # Yes, this many \'s is correct.
current_list_dir_regex
"${CMAKE_CURRENT_LIST_DIR}")
# Figure out where app's binary_dir was.
string(REGEX REPLACE
"${current_list_dir_regex}/[^/]+/(.*)"
"${CMAKE_CURRENT_LIST_DIR}/app/\\1"
APP_BINARY_DIR "${FIREBASE_BINARY_DIR}")

# Gradle now adds a random hash to each separate NDK cmake build.
# Scan the previously built directories to find the one containing app's header.
set(header_to_scan_for "generated/app/src/include/firebase/version.h")
set(prev_build_path "${CMAKE_BINARY_DIR}/../../../../../app/.cxx/${CMAKE_BUILD_TYPE}/*/${CMAKE_ANDROID_ARCH_ABI}")
file(GLOB possible_prev_build_dirs "${prev_build_path}")
# In case there are multiple matches, take the one with the newest timestamp.
set(newest_timestamp 0)
foreach(possible_prev_build_dir IN LISTS possible_prev_build_dirs)
if(IS_DIRECTORY ${possible_prev_build_dir})
if(EXISTS "${possible_prev_build_dir}/${header_to_scan_for}")
# Check if it's newer than any other files.
file(TIMESTAMP "${possible_prev_build_dir}/${header_to_scan_for}" timestamp "%s")
if(${timestamp} GREATER ${newest_timestamp})
set(APP_BINARY_DIR ${possible_prev_build_dir})
set(newest_timestamp ${timestamp})
endif()
endif()
endif()
endforeach()
if (IS_DIRECTORY "${APP_BINARY_DIR}")
message(STATUS "Found previous Firebase App build in ${APP_BINARY_DIR}")
else()
message(FATAL_ERROR "Could not find previous Firebase App build under ${prev_build_path}")
endif()
set(FIRESTORE_SOURCE_DIR ${APP_BINARY_DIR}/external/src/firestore)
else()
# Run the CMake build logic that will download all the external dependencies.
Expand Down Expand Up @@ -579,6 +590,7 @@ if(NOT FIREBASE_CPP_USE_PRIOR_GRADLE_BUILD)
else()
# Add firebase_app as a target on the previously built app.
add_library(firebase_app STATIC IMPORTED GLOBAL)

file(MAKE_DIRECTORY "${APP_BINARY_DIR}/generated")
file(MAKE_DIRECTORY "${FIREBASE_BINARY_DIR}/generated")
set(app_include_dirs
Expand Down
1 change: 1 addition & 0 deletions analytics/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

# Analytics generates header files for default events, parameters, and
# properties based on the iOS SDK, that are used across all platforms.

set(analytics_generated_headers_dir
"${FIREBASE_GEN_FILE_DIR}/analytics/src/include/firebase/analytics")
set(event_names_header "${analytics_generated_headers_dir}/event_names.h")
Expand Down
7 changes: 4 additions & 3 deletions analytics/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ buildscript {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.2.1'
classpath 'com.android.tools.build:gradle:7.4.2'
}
}
allprojects {
Expand All @@ -33,7 +33,7 @@ apply plugin: 'com.android.library'
android {
compileSdkVersion 34
ndkPath System.getenv('ANDROID_NDK_HOME')
buildToolsVersion '30.0.2'
buildToolsVersion '32.0.0'

sourceSets {
main {
Expand All @@ -48,7 +48,7 @@ android {
}

defaultConfig {
minSdkVersion 23
minSdkVersion 24
targetSdkVersion 34
versionCode 1
versionName "1.0"
Expand Down Expand Up @@ -85,4 +85,5 @@ apply from: "$rootDir/android_build_files/extract_and_dex.gradle"
apply from: "$rootDir/android_build_files/generate_proguard.gradle"
project.afterEvaluate {
generateProguardFile('analytics')
preBuild.dependsOn(':app:build')
}
12 changes: 6 additions & 6 deletions analytics/integration_test/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ buildscript {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.2.1'
classpath 'com.google.gms:google-services:4.0.1'
classpath 'com.android.tools.build:gradle:7.4.2'
classpath 'com.google.gms:google-services:4.4.1'
}
}

Expand All @@ -37,12 +37,12 @@ apply plugin: 'com.android.application'

android {
compileOptions {
sourceCompatibility 1.8
targetCompatibility 1.8
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11
}
compileSdkVersion 34
ndkPath System.getenv('ANDROID_NDK_HOME')
buildToolsVersion '30.0.2'
buildToolsVersion '32.0.0'

sourceSets {
main {
Expand All @@ -55,7 +55,7 @@ android {

defaultConfig {
applicationId 'com.google.android.analytics.testapp'
minSdkVersion 23
minSdkVersion 24
targetSdkVersion 34
versionCode 1
versionName '1.0'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https://services.gradle.org/distributions/gradle-6.7.1-all.zip
distributionUrl=https://services.gradle.org/distributions/gradle-7.5.1-all.zip
14 changes: 5 additions & 9 deletions android_build_files/extract_and_dex.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,11 @@ def defineExtractionTasks(String resourceName, String buildType) {
outputs.file "$outPro"

// Convert the jar format using the dx tool.
String dex_path = "${sdk_dir}/build-tools/${buildToolsVersion}/dx"
if (org.gradle.internal.os.OperatingSystem.current().isWindows()) {
dex_path = "${dex_path}.bat"
}

commandLine "${dex_path}",
'--dex',
"--output=$dexedJar",
"$buildDir/classes.jar"
String dex_path = "${sdk_dir}/build-tools/${buildToolsVersion}/lib/d8.jar"
commandLine "java", "-cp", "${dex_path}", "com.android.tools.r8.D8",
"$buildDir/classes.jar",
"--output",
"$dexedJar"
}

// Once the dexed jar has been made, generate a proguard file for it.
Expand Down
2 changes: 1 addition & 1 deletion android_build_files/generate_proguard.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def defineGenerateProguardFile(String subproject, String buildType,
String nativeBuildDir =
project.android.externalNativeBuild.cmake.buildStagingDirectory
if (nativeBuildDir == null || nativeBuildDir.isEmpty()) {
nativeBuildDir = file('.cxx/cmake').absolutePath
nativeBuildDir = file('.cxx').absolutePath
}

// Find the static library that was built. Note that there are multiple
Expand Down
14 changes: 10 additions & 4 deletions app/app_resources/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ buildscript {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.2.1'
classpath 'com.google.gms:google-services:4.2.0'
classpath 'com.android.tools.build:gradle:7.4.2'
classpath 'com.google.gms:google-services:4.4.1'
}
}
allprojects {
Expand All @@ -33,10 +33,16 @@ apply plugin: 'com.android.library'

android {
compileOptions {
sourceCompatibility 1.8
targetCompatibility 1.8
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11
}
compileSdkVersion 34
buildToolsVersion '32.0.0'

defaultConfig {
minSdkVersion 24
targetSdkVersion 34
}

sourceSets {
main {
Expand Down
6 changes: 3 additions & 3 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ buildscript {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.2.1'
classpath 'com.android.tools.build:gradle:7.4.2'
}
}
allprojects {
Expand All @@ -33,7 +33,7 @@ apply plugin: 'com.android.library'
android {
compileSdkVersion 34
ndkPath System.getenv('ANDROID_NDK_HOME')
buildToolsVersion '30.0.2'
buildToolsVersion '32.0.0'

sourceSets {
main {
Expand All @@ -48,7 +48,7 @@ android {
}

defaultConfig {
minSdkVersion 23
minSdkVersion 24
targetSdkVersion 34
versionCode 1
versionName "1.0"
Expand Down
14 changes: 10 additions & 4 deletions app/google_api_resources/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ buildscript {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.2.1'
classpath 'com.google.gms:google-services:4.2.0'
classpath 'com.android.tools.build:gradle:7.4.2'
classpath 'com.google.gms:google-services:4.4.1'
}
}
allprojects {
Expand All @@ -33,10 +33,16 @@ apply plugin: 'com.android.library'

android {
compileOptions {
sourceCompatibility 1.8
targetCompatibility 1.8
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11
}
compileSdkVersion 34
buildToolsVersion '32.0.0'

defaultConfig {
minSdkVersion 24
targetSdkVersion 34
}

sourceSets {
main {
Expand Down
12 changes: 6 additions & 6 deletions app/integration_test/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ buildscript {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.2.1'
classpath 'com.google.gms:google-services:4.0.1'
classpath 'com.android.tools.build:gradle:7.4.2'
classpath 'com.google.gms:google-services:4.4.1'
}
}

Expand All @@ -37,12 +37,12 @@ apply plugin: 'com.android.application'

android {
compileOptions {
sourceCompatibility 1.8
targetCompatibility 1.8
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11
}
compileSdkVersion 34
ndkPath System.getenv('ANDROID_NDK_HOME')
buildToolsVersion '30.0.2'
buildToolsVersion '32.0.0'

sourceSets {
main {
Expand All @@ -55,7 +55,7 @@ android {

defaultConfig {
applicationId 'com.google.android.analytics.testapp'
minSdkVersion 23
minSdkVersion 24
targetSdkVersion 34
versionCode 1
versionName '1.0'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https://services.gradle.org/distributions/gradle-6.7.1-all.zip
distributionUrl=https://services.gradle.org/distributions/gradle-7.5.1-all.zip
14 changes: 10 additions & 4 deletions app/invites_resources/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ buildscript {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.2.1'
classpath 'com.google.gms:google-services:4.2.0'
classpath 'com.android.tools.build:gradle:7.4.2'
classpath 'com.google.gms:google-services:4.4.1'
}
}
allprojects {
Expand All @@ -33,10 +33,16 @@ apply plugin: 'com.android.library'

android {
compileOptions {
sourceCompatibility 1.8
targetCompatibility 1.8
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11
}
compileSdkVersion 34
buildToolsVersion '32.0.0'

defaultConfig {
minSdkVersion 24
targetSdkVersion 34
}

sourceSets {
main {
Expand Down
Loading

0 comments on commit c5b228d

Please sign in to comment.