Skip to content

Commit

Permalink
Update to AGP 8/Gradle 8 (#117)
Browse files Browse the repository at this point in the history
* Gradle 8.0-rc-1

* Update deps

* Update CI

* Update artifacts API

* fix CI

* 19

* Restore cache

* API

* Replace classpath prop

* Remove unused function

* Add missing sensitivities

* Use resolve b/199411018

* Remove appExtension where possible

* Use ALL scope

* Comment + distinct and sorted for determinism

* Don't run as parameterized

* test file cleanups

* Fix plugin toolchain

* Update deps

* inline away minifiertype

* Formatting + always emit diagnostics in tests

* Fix missing classpath wiring in test jar

* ABI

* set toolchains and compilerOptions

* More compilerOptions

* subprojects only

* ...unfiltered?

* Use provider

* Consolidate repositories

* Trim comparison

* uh

* What about compileConfiguration

* Update CI versions

* Gradle 8.0 final

* Disable 8.1.0 on CI for now

* Try ADTs

* De-flake

* Disable AVD caching for now

* Assemble eagerly

* Apparently compileConfiguration explodes

* Update AGP

* Add disable mechanism

* Gradle 8.0.1

* Fix property location

* Always use trace refs

* Try just artifactFiles

* Revert "Try just artifactFiles"

This reverts commit 008e52b.

* Re-enable config caching in tests

* Fix config cache tests

* Revert "Revert "Try just artifactFiles""

This reverts commit 4f7b534.

* Update again

* Wrap in provider

* beta03

* KeeperJarTask cleanups

* Don't extend JavaExec anymore

* Remove old suppression

* Update API

* Update to final versions

* Update wrapper files

* Fix rules version

* Update CI

* Fix name

* Improve message

* Remove unused import

* Apparently new content in the file

* Convert to kotlin DSL

* Use Truth for better messages

* Spotless 6.18.0

* do these still matter in the year of our lord 2023

* spotless
  • Loading branch information
ZacSweers authored Apr 15, 2023
1 parent b2847d7 commit 5b9d59c
Show file tree
Hide file tree
Showing 24 changed files with 697 additions and 576 deletions.
97 changes: 74 additions & 23 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,57 +11,101 @@ on:
# Always run on PRs
pull_request:

env:
# Test on API 30 because that's the first version with ATDs
API_LEVEL: '30'
AVD_TARGET: 'aosp_atd'

jobs:
build:
name: ${{ matrix.job }} / JDK ${{ matrix.java }} / AGP ${{ matrix.agp }}
name: ${{ matrix.job }} / AGP ${{ matrix.agp }}
# Use macOS for emulator hardware acceleration
runs-on: 'macOS-latest'
timeout-minutes: 30
strategy:
fail-fast: false # We want to see all results
matrix:
java: ['11']
agpTestVersion: ['7.3.1']
# TODO add back '8.1.0-alpha04' once API changes around L8 keep rules are sorted out
agp: ['8.0.0']
job: ['instrumentation', 'plugin']
env:
DEP_OVERRIDE_agp: ${{ matrix.agp }}
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Gradle Wrapper Validation
uses: gradle/wrapper-validation-action@v1

- name: Generate cache key
run: ./checksum.sh checksum.txt

- uses: actions/cache@v2
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ matrix.java }}-${{ hashFiles('checksum.txt') }}
restore-keys: |
${{ runner.os }}-gradle-${{ matrix.java }}-
- name: Install JDK ${{ matrix.java }}
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: ${{ matrix.java }}
java-version: '19'

- name: Spot check
run: ./gradlew spotlessCheck

- name: Test plugin
id: gradle
if: matrix.job == 'plugin'
env:
DEP_OVERRIDE_agpTestVersion: ${{ matrix.agpTestVersion }}
run: ./gradlew -p keeper-gradle-plugin check
uses: gradle/gradle-build-action@v2
with:
arguments: -p keeper-gradle-plugin check

- name: Assemble instrumentation tests
id: gradle-assemble-instrumentation
if: matrix.job == 'instrumentation'
uses: gradle/gradle-build-action@v2
with:
arguments: :sample:minifyExternalStagingWithR8 --stacktrace -Pkeeper.verifyL8=true

# TODO AVD caching disabled due to https://github.com/ReactiveCircus/android-emulator-runner/issues/278
# - name: AVD cache
# uses: actions/cache@v3
# id: avd-cache
# if: matrix.job == 'instrumentation'
# with:
# path: |
# ~/.android/avd/*
# ~/.android/adbkey
# ~/.android/adbkey.pub
# key: avd-${{ env.API_LEVEL }}-${{ env.AVD_TARGET }}
#
# - name: Create AVD and generate snapshot for caching
# if: matrix.job == 'instrumentation' && steps.avd-cache.outputs.cache-hit != 'true'
# uses: reactivecircus/android-emulator-runner@v2
# with:
# api-level: ${{ env.API_LEVEL }}
# force-avd-creation: false
# emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
# disable-animations: true
# disable-spellchecker: true
# target: ${{ env.AVD_TARGET }}
# channel: canary # Necessary for ATDs
# script: echo "Generated AVD snapshot for caching."

- name: Run instrumentation tests
uses: reactivecircus/android-emulator-runner@v2
if: matrix.job == 'instrumentation'
uses: reactivecircus/android-emulator-runner@v2
with:
# We don't want to wait for the emulator to start/stop twice, so we combine this script into the same step.
script: .github/workflows/run_instrumentation_tests.sh
api-level: 29
api-level: ${{ env.API_LEVEL }}
force-avd-creation: false
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
disable-animations: true
disable-spellchecker: true
target: 'aosp_atd'
channel: canary # Necessary for ATDs
script: |
adb uninstall com.slack.keeper.sample || true
adb uninstall com.slack.keeper.sample.androidTest || true
# Now proceed, with much of the build being cached up to this point
echo "Running instrumentation tests"
./gradlew connectedExternalStagingAndroidTest --stacktrace
adb uninstall com.slack.keeper.sample || true
adb uninstall com.slack.keeper.sample.androidTest || true
- name: (Fail-only) Bundle the build report
if: failure()
Expand All @@ -83,11 +127,18 @@ jobs:
- name: Checkout
uses: actions/checkout@v2

- name: Install JDK ${{ matrix.java }}
- name: Install JDK
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: '11'
java-version: '19'

# Just here to restore cache
- name: Gradle prep
id: gradle
uses: gradle/gradle-build-action@v2
with:
arguments: help

- name: Upload snapshot (main only)
env:
Expand Down
11 changes: 0 additions & 11 deletions .github/workflows/run_instrumentation_tests.sh

This file was deleted.

75 changes: 0 additions & 75 deletions build.gradle

This file was deleted.

79 changes: 79 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
/*
* Copyright (C) 2020. Slack Technologies, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* 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,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.plugin.KotlinBasePlugin
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
alias(libs.plugins.kotlin.jvm) apply false
alias(libs.plugins.agp.library) apply false
// Version just here to make gradle happy. It's always substituted as an included build
id("com.slack.keeper") version "0.12.0" apply false
alias(libs.plugins.spotless)
}

subprojects {
pluginManager.withPlugin("java") {
configure<JavaPluginExtension> { toolchain { languageVersion.set(JavaLanguageVersion.of(19)) } }

tasks.withType<JavaCompile>().configureEach { options.release.set(11) }
}

plugins.withType<KotlinBasePlugin>().configureEach {
project.tasks.withType<KotlinCompile>().configureEach {
compilerOptions {
jvmTarget.set(JvmTarget.JVM_11)
freeCompilerArgs.add("-progressive")
}
}
}
}

spotless {
format("misc") {
target("**/*.md", ".gitignore")
trimTrailingWhitespace()
endWithNewline()
}
val ktfmtVersion = libs.versions.ktfmt.get()
kotlin {
target("**/*.kt")
targetExclude("**/.gradle/**", "**/build/**")
ktfmt(ktfmtVersion).googleStyle()
trimTrailingWhitespace()
endWithNewline()
licenseHeaderFile(rootProject.file("spotless/copyright.kt"))
targetExclude("**/copyright.kt")
}
kotlinGradle {
target("**/*.kts", "./*.kts")
ktfmt(ktfmtVersion).googleStyle()
trimTrailingWhitespace()
endWithNewline()
licenseHeaderFile(
"spotless/copyright.kt",
"(import|plugins|buildscript|dependencies|dependencyResolutionManagement|pluginManagement|rootProject)"
)
}
java {
target("**/*.java")
googleJavaFormat(libs.versions.gjf.get()).reflowLongStrings()
trimTrailingWhitespace()
endWithNewline()
licenseHeaderFile(rootProject.file("spotless/copyright.java"))
targetExclude("**/copyright.java")
}
}
30 changes: 14 additions & 16 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,33 +1,31 @@
[versions]
agp = "7.3.1"
androidx-test = "1.4.0"
kotlin = "1.7.22"
gjf = "1.15.0"
ktfmt = "0.42"
agp = "8.0.0"
androidx-test = "1.5.2"
kotlin = "1.8.10"
gjf = "1.16.0"
ktfmt = "0.43"

[plugins]
agp-library = { id = "com.android.library", version.ref = "agp" }
binaryCompatibilityValidator = { id = "org.jetbrains.kotlinx.binary-compatibility-validator", version = "0.12.1" }
kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
mavenPublish = { id = "com.vanniktech.maven.publish", version = "0.22.0" }
spotless = { id = "com.diffplug.spotless", version = "6.12.0" }
mavenPublish = { id = "com.vanniktech.maven.publish", version = "0.25.1" }
spotless = { id = "com.diffplug.spotless", version = "6.18.0" }

[libraries]
androidx-annotation = "androidx.annotation:annotation:1.3.0"
androidx-test-orchestrator = "androidx.test:orchestrator:1.4.1"
androidx-test-rules = { module = "androidx.test:rules", version.ref = "androidx-test" }
androidx-annotation = "androidx.annotation:annotation:1.6.0"
androidx-test-orchestrator = "androidx.test:orchestrator:1.4.2"
androidx-test-rules = { module = "androidx.test:rules", version = "1.5.0" }
androidx-test-runner = { module = "androidx.test:runner", version.ref = "androidx-test" }
androidx-test-truth = "androidx.test.ext:junit:1.1.3"
androidx-test-truth = "androidx.test.ext:junit:1.1.5"
agp = { module = "com.android.tools.build:gradle", version.ref = "agp" }
# There's a bug in AGP 7.3.x that breaks our tests: https://issuetracker.google.com/249359878
agpTestVersion = { module = "com.android.tools.build:gradle", version = "7.4.0-rc01" }
desugarJdkLibs = "com.android.tools:desugar_jdk_libs:1.1.5"
desugarJdkLibs = "com.android.tools:desugar_jdk_libs:2.0.3"
javapoet = "com.squareup:javapoet:1.13.0"
junit = "junit:junit:4.13.2"
kgp = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlin" }
kgp-api = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin-api", version.ref = "kotlin" }
kotlinpoet = "com.squareup:kotlinpoet:1.12.0"
okio = "com.squareup.okio:okio:3.2.0"
kotlinpoet = "com.squareup:kotlinpoet:1.13.0"
okio = "com.squareup.okio:okio:3.3.0"
truth = "com.google.truth:truth:1.1.3"
zipflinger = { module = "com.android:zipflinger", version.ref = "agp" }

Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1-bin.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading

0 comments on commit 5b9d59c

Please sign in to comment.