Skip to content

Commit

Permalink
Bump Kotlin, JDK, Compose, Gradle, etc.
Browse files Browse the repository at this point in the history
  • Loading branch information
psteiger committed Oct 14, 2024
1 parent 6cf61b1 commit 685bd46
Show file tree
Hide file tree
Showing 34 changed files with 205 additions and 195 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
strategy:
matrix:
# TODO Add 9, 10, 11, 12, and 13 after Kotlin 1.3.60
java_version: [11]
java_version: [17]
steps:
- name: Checkout
uses: actions/checkout@v2
Expand Down
2 changes: 2 additions & 0 deletions android/build.gradle → android/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ plugins {
alias(libs.plugins.android.application) apply false
alias(libs.plugins.android.library) apply false
alias(libs.plugins.kotlin.android) apply false
alias(libs.plugins.kotlin.symbol.processor) apply false
alias(libs.plugins.kotlin.kapt) apply false
alias(libs.plugins.compose.compiler) apply false
alias(libs.plugins.maven.publish) apply false
alias(libs.plugins.errorprone) apply false
alias(libs.plugins.nullaway) apply false
Expand Down
2 changes: 1 addition & 1 deletion android/conventions/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/
plugins {
`kotlin-dsl`
`kotlin-dsl-precompiled-script-plugins`
alias(libs.plugins.spotless)
}

repositories {
Expand Down
23 changes: 7 additions & 16 deletions android/conventions/src/main/kotlin/Extensions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,34 +14,25 @@
* limitations under the License.
*/
import com.android.build.gradle.AbstractAppExtension
import com.android.build.gradle.LibraryExtension
import com.android.build.gradle.TestedExtension
import com.android.build.gradle.api.BaseVariant
import net.ltgt.gradle.errorprone.CheckSeverity
import net.ltgt.gradle.errorprone.errorprone
import net.ltgt.gradle.nullaway.nullaway

fun AbstractAppExtension.errorprone() {
applicationVariants.configureEach { errorprone() }
testErrorprone()
}

fun LibraryExtension.errorprone() {
libraryVariants.configureEach { errorprone() }
testErrorprone()
}

fun TestedExtension.testErrorprone() {
testVariants.configureEach { errorprone() }
unitTestVariants.configureEach { errorprone() }
}

fun BaseVariant.errorprone() {
private fun BaseVariant.errorprone() {
javaCompileProvider.configure {
options.errorprone.nullaway {
severity.set(CheckSeverity.ERROR)
annotatedPackages.add("com.uber")
options.errorprone {
nullaway {
severity.set(CheckSeverity.ERROR)
annotatedPackages.add("com.uber")
}
excludedPaths.set(".*/build/generated/.*")
}
options.errorprone.excludedPaths.set(".*/build/generated/.*")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,40 +24,36 @@ plugins {
}

kotlin {
jvmToolchain(11)
jvmToolchain(17)
}

android {
compileSdk = 33

compileSdk = 34
defaultConfig {
minSdk = 21
targetSdk = 28
targetSdk = 34
versionCode = 1
versionName = "1.0"
}

compileOptions {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
buildFeatures {
buildConfig = true
}

// No need for lint. Those are just tutorials.
lint {
abortOnError = false
quiet = true
}

buildTypes {
debug {
matchingFallbacks.add("release")
}
}

sourceSets {
getByName("main").java.srcDir("src/main/kotlin")
getByName("test").java.srcDir("src/test/kotlin")
getByName("androidTest").java.srcDir("src/androidTest/kotlin")
compileOptions {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
kotlinOptions {
jvmTarget = "11"
}
}

Expand All @@ -71,9 +67,6 @@ androidComponents {

tasks.withType<KotlinCompile>().configureEach {
compilerOptions {
freeCompilerArgs.addAll(
"-Xjvm-default=all",
"-opt-in=kotlin.RequiresOptIn",
)
freeCompilerArgs.add("-Xjvm-default=all")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,30 +24,28 @@ plugins {
}

kotlin {
jvmToolchain(8)
jvmToolchain(17)
explicitApi()
}

android {
compileSdk = 33
compileSdk = 34

defaultConfig {
minSdk = 21
}

// This can be removed on AGP 8.1.0-alpha09 onwards, since we are using JVM Toolchain
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}

buildFeatures {
buildConfig = false
kotlinOptions {
jvmTarget = "11"
}

sourceSets {
getByName("main").java.srcDir("src/main/kotlin")
getByName("test").java.srcDir("src/test/kotlin")
getByName("androidTest").java.srcDir("src/androidTest/kotlin")
buildFeatures {
buildConfig = false
}

testOptions {
Expand All @@ -67,10 +65,6 @@ androidComponents {

tasks.withType<KotlinCompile>().configureEach {
compilerOptions {
freeCompilerArgs.addAll(
"-Xexplicit-api=warning",
"-Xjvm-default=all",
"-opt-in=kotlin.RequiresOptIn",
)
freeCompilerArgs.add("-Xjvm-default=all")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,29 @@
* 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.dsl.jvm.JvmTargetValidationMode
import org.jetbrains.kotlin.gradle.tasks.KotlinJvmCompile

plugins {
kotlin("jvm")
id("ribs.spotless-convention")
}

kotlin {
jvmToolchain(8)
explicitApi()
java {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}

tasks.named("compileKotlin", org.jetbrains.kotlin.gradle.tasks.KotlinCompilationTask::class.java) {
kotlin {
jvmToolchain(17)
explicitApi()
compilerOptions {
freeCompilerArgs.add("-Xjvm-default=all")
jvmTarget = JvmTarget.JVM_11
}
}

tasks.withType<KotlinJvmCompile>().configureEach {
jvmTargetValidationMode = JvmTargetValidationMode.WARNING
}
12 changes: 7 additions & 5 deletions android/demos/compose/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
plugins {
id("ribs.kotlin-android-application-conventions")
alias(libs.plugins.kotlin.kapt)
alias(libs.plugins.compose.compiler)
alias(libs.plugins.kotlin.symbol.processor)
}

android {
Expand All @@ -12,13 +13,14 @@ android {
buildFeatures {
compose true
}
composeOptions {
kotlinCompilerExtensionVersion libs.versions.compose.compiler.get()
}
}

dependencies {
kapt(libs.motif.compiler)
def composeBom = platform(libs.compose.bom)
implementation(composeBom)
androidTestImplementation(composeBom)

ksp(libs.motif.compiler)
implementation(project(":libraries:rib-android"))
implementation(project(":libraries:rib-android-compose"))
implementation(project(":libraries:rib-coroutines"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,47 +16,39 @@
package com.uber.rib;

import android.app.Application;
import com.squareup.leakcanary.LeakCanary;
import com.squareup.leakcanary.RefWatcher;
import com.uber.rib.core.ActivityDelegate;
import com.uber.rib.core.HasActivityDelegate;
import com.uber.rib.core.RibRefWatcher;
import java.util.concurrent.TimeUnit;
import leakcanary.AppWatcher;
import org.jetbrains.annotations.NotNull;

public class SampleApplication extends Application implements HasActivityDelegate {
public class SampleApplication extends Application
implements HasActivityDelegate, RibRefWatcher.ReferenceWatcher {

private SampleActivityDelegate activityDelegate;

@Override
public void onCreate() {
activityDelegate = new SampleActivityDelegate();
super.onCreate();
if (!LeakCanary.isInAnalyzerProcess(this)) {
// This process is dedicated to LeakCanary for heap analysis. You should not init your app in
// this process.
installLeakCanary();
}
installLeakCanary();
}

/** Install leak canary for both activities and RIBs. */
private void installLeakCanary() {
final RefWatcher refWatcher =
LeakCanary.refWatcher(this).watchDelay(2, TimeUnit.SECONDS).buildAndInstall();
LeakCanary.install(this);
RibRefWatcher.getInstance()
.setReferenceWatcher(
new RibRefWatcher.ReferenceWatcher() {
@Override
public void watch(Object object) {
refWatcher.watch(object);
}
final RibRefWatcher watcher = RibRefWatcher.getInstance();
watcher.setReferenceWatcher(this);
watcher.enableLeakCanary();
}

@Override
public void logBreadcrumb(String eventType, String data, String parent) {
// Ignore for now. Useful for collecting production analytics.
}
});
RibRefWatcher.getInstance().enableLeakCanary();
@Override
public void watch(Object objectToWatch) {
AppWatcher.INSTANCE.getObjectWatcher().watch(objectToWatch);
}

@Override
public void logBreadcrumb(String eventType, @NotNull String data, @NotNull String parent) {
// Ignore for now. Useful for collecting production analytics.
}

@Override
Expand Down
11 changes: 7 additions & 4 deletions android/demos/rib-workers/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
plugins {
id("ribs.kotlin-android-application-errorprone-conventions")
alias(libs.plugins.compose.compiler)
alias(libs.plugins.kotlin.symbol.processor)
}

android {
Expand All @@ -11,13 +13,14 @@ android {
buildFeatures {
compose true
}
composeOptions {
kotlinCompilerExtensionVersion libs.versions.compose.compiler.get()
}
}

dependencies {
kapt(libs.motif.compiler)
def composeBom = platform(libs.compose.bom)
implementation(composeBom)
androidTestImplementation(composeBom)

ksp(libs.motif.compiler)
implementation(project(":libraries:rib-android"))
implementation(project(":libraries:rib-android-compose"))
implementation(project(":libraries:rib-coroutines"))
Expand Down
Loading

0 comments on commit 685bd46

Please sign in to comment.