Skip to content

Commit

Permalink
Upgrade to AGP 8 & Kotlin 1.9.20
Browse files Browse the repository at this point in the history
  • Loading branch information
mattkranzler5 committed Dec 14, 2023
1 parent 62c935f commit 0e994d6
Show file tree
Hide file tree
Showing 20 changed files with 95 additions and 224 deletions.
67 changes: 65 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
import com.android.build.api.dsl.ApplicationExtension
import com.android.build.api.dsl.CommonExtension
import com.android.build.api.dsl.LibraryExtension
import com.android.build.api.dsl.TestExtension

buildscript {

repositories {
Expand All @@ -20,22 +25,79 @@ buildscript {
apply(plugin = "com.github.ben-manes.versions")
apply(plugin = "org.jetbrains.dokka")
apply(from = "gradle/jacoco.gradle")
apply(from = "gradle/merge-reports.gradle")

allprojects {
repositories {
google()
mavenCentral()
}
}

subprojects {
val javaVersion = JavaVersion.VERSION_11

tasks.withType<org.jetbrains.dokka.gradle.DokkaTaskPartial>().configureEach {
dokkaSourceSets.named("main") {
jdkVersion.set(8)
jdkVersion.set(11)
skipDeprecated.set(true)
skipEmptyPackages.set(true)
reportUndocumented.set(false)
}
}

// Common android config
val commonAndroidConfig: CommonExtension<*, *, *, *, *>.() -> Unit = {
compileSdk = 30

compileOptions {
sourceCompatibility = javaVersion
targetCompatibility = javaVersion
}
}

// Android library config
pluginManager.withPlugin("com.android.library") {
with(extensions.getByType<LibraryExtension>()) {
commonAndroidConfig()
defaultConfig { minSdk = 21 }
}
}

// Android app config
pluginManager.withPlugin("com.android.application") {
with(extensions.getByType<ApplicationExtension>()) {
commonAndroidConfig()
defaultConfig {
minSdk = 21
//noinspection ExpiredTargetSdkVersion
targetSdk = 30
}
}
}

// Android test config
pluginManager.withPlugin("com.android.test") {
with(extensions.getByType<TestExtension>()) {
commonAndroidConfig()
defaultConfig {
// Using sdk 28 for robolectric tests.
minSdk = 28
//noinspection ExpiredTargetSdkVersion
targetSdk = 28
}
}
}

tasks.withType<JavaCompile>().configureEach {
sourceCompatibility = javaVersion.toString()
targetCompatibility = javaVersion.toString()
}

tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile>().configureEach {
kotlinOptions {
jvmTarget = javaVersion.toString()
}
}
}

tasks.register("clean", Delete::class) {
Expand All @@ -53,3 +115,4 @@ tasks.register("install") {
dependsOn(publishTasks)
}

apply(from = "gradle/merge-reports.gradle")
27 changes: 6 additions & 21 deletions formula-android-compose/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,34 +9,17 @@ apply {
}

android {
compileSdk = libs.versions.compileSdk.get().toInt()

defaultConfig {
minSdk = libs.versions.minSdk.get().toInt()
targetSdk = libs.versions.targetSdk.get().toInt()
}
namespace = "com.instacart.formula.android.compose"

buildFeatures {
compose = true
}

compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}

composeOptions {
kotlinCompilerVersion = libs.versions.kotlin.get()
kotlinCompilerExtensionVersion = libs.versions.compose.get()
}
}

tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile>().all {
kotlinOptions {
jvmTarget = "1.8"
}
}

task<Jar>("sourcesJar") {
from(android.sourceSets["main"].java.srcDirs)
archiveClassifier.set("sources")
Expand All @@ -45,9 +28,11 @@ task<Jar>("sourcesJar") {
task<Javadoc>("javadoc") {
isFailOnError = false
source(android.sourceSets["main"].java.getSourceFiles())
classpath += project.files(android.bootClasspath.joinToString(separator = File.pathSeparator))
classpath += configurations.api
classpath += configurations.implementation
classpath = project.files(
android.bootClasspath.joinToString(separator = File.pathSeparator),
configurations.api,
configurations.implementation
)
}

task<Jar>("javadocJar") {
Expand Down
15 changes: 1 addition & 14 deletions formula-android-tests/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,14 @@ apply {
}

android {
compileSdk = 28
namespace = "com.instacart.formula.samples"
defaultConfig {
applicationId = "com.instacart.formula.samples"
minSdk = libs.versions.minSdk.get().toInt()
targetSdk = 28 // Using sdk 28 for robolectric tests.
versionCode = 1
versionName = "1.0"
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}

compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}

buildTypes {
release {
isMinifyEnabled = false
Expand All @@ -38,12 +31,6 @@ android {
}
}

tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile>().all {
kotlinOptions {
jvmTarget = "1.8"
}
}

dependencies {
implementation(project(":formula-rxjava3"))
implementation(project(":formula-android"))
Expand Down
26 changes: 6 additions & 20 deletions formula-android/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -11,29 +11,13 @@ apply {
}

android {
compileSdk = libs.versions.compileSdk.get().toInt()

defaultConfig {
minSdk = libs.versions.minSdk.get().toInt()
targetSdk = libs.versions.targetSdk.get().toInt()
}

compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
namespace = "com.instacart.formula.android"

testOptions {
unitTests.isReturnDefaultValues = true
}
}

tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile>().all {
kotlinOptions {
jvmTarget = "1.8"
}
}

task<Jar>("sourcesJar") {
from(android.sourceSets["main"].java.srcDirs)
archiveClassifier.set("sources")
Expand All @@ -42,9 +26,11 @@ task<Jar>("sourcesJar") {
task<Javadoc>("javadoc") {
isFailOnError = false
source(android.sourceSets["main"].java.getSourceFiles())
classpath += project.files(android.bootClasspath.joinToString(separator = File.pathSeparator))
classpath += configurations.api
classpath += configurations.implementation
classpath = project.files(
android.bootClasspath.joinToString(separator = File.pathSeparator),
configurations.api,
configurations.implementation
)
}

task<Jar>("javadocJar") {
Expand Down
11 changes: 0 additions & 11 deletions formula-coroutines/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,6 @@ plugins {
id("kotlin")
}

java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}

dependencies {
implementation(libs.kotlin)
implementation(libs.coroutines)
Expand All @@ -18,10 +13,4 @@ dependencies {
testImplementation(libs.truth)
testImplementation(libs.junit)
testImplementation(libs.coroutines.test)
}

tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile>().all {
kotlinOptions {
freeCompilerArgs += "-Xopt-in=kotlin.RequiresOptIn"
}
}
5 changes: 0 additions & 5 deletions formula-lint/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,6 @@ apply {
from("$rootDir/.buildscript/configure-signing.gradle")
}

java {
targetCompatibility = JavaVersion.VERSION_1_8
sourceCompatibility = JavaVersion.VERSION_1_8
}

dependencies {
compileOnly(libs.lint.api)
compileOnly(libs.lint.checks)
Expand Down
15 changes: 0 additions & 15 deletions formula-rxjava3/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,6 @@ apply {
from("$rootDir/.buildscript/configure-signing.gradle")
}

repositories {
mavenCentral()
}

java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}

tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile>().all {
kotlinOptions {
jvmTarget = "1.8"
}
}

dependencies {
implementation(libs.kotlin)

Expand Down
15 changes: 0 additions & 15 deletions formula-test/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,6 @@ apply {
from("$rootDir/.buildscript/configure-signing.gradle")
}

java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}

repositories {
mavenCentral()
}

tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile>().all {
kotlinOptions {
jvmTarget = "1.8"
}
}

dependencies {
implementation(libs.kotlin)
api(project(":formula-rxjava3"))
Expand Down
16 changes: 0 additions & 16 deletions formula/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,6 @@ apply {
from("$rootDir/.buildscript/configure-signing.gradle")
}

repositories {
mavenCentral()
}


java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}

tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile>().all {
kotlinOptions {
jvmTarget = "1.8"
}
}

dependencies {
implementation(libs.kotlin)

Expand Down
13 changes: 6 additions & 7 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
[versions]
android-gradle = "7.0.4"
android-gradle = "8.2.0"
dokka-gradle = "1.4.32"

minSdk = "21"
compileSdk = "30"
targetSdk = "30"

kotlin = "1.5.21"
kotlin = "1.9.20"
coroutines = "1.5.2"
compose = "1.0.1"

Expand All @@ -26,7 +22,10 @@ dokka-gradle = { module = "org.jetbrains.dokka:dokka-gradle-plugin", version.ref
dokka-android-gradle = { module = "org.jetbrains.dokka:android-documentation-plugin", version.ref = "dokka-gradle" }
maven-publish-gradle = { module = "com.vanniktech:gradle-maven-publish-plugin", version = "0.14.2" }
version-gradle = { module = "com.github.ben-manes:gradle-versions-plugin", version = "0.38.0" }
jacoco-gradle = { module = "com.vanniktech:gradle-android-junit-jacoco-plugin", version = "0.16.0" }

# We need to fork the plugin to fix an incorrect usage of tasks.withType(Test)
# https://github.com/vanniktech/gradle-android-junit-jacoco-plugin/compare/master...Laimiux:gradle-android-junit-jacoco-plugin:laimonas/gradle-8?expand=1
jacoco-gradle = { module = "com.github.Jawnnypoo:gradle-android-junit-jacoco-plugin", version = "61a9cc0129" }

kotlin = { module = "org.jetbrains.kotlin:kotlin-stdlib-jdk8", version.ref = "kotlin" }
kotlin-reflect = { module = "org.jetbrains.kotlin:kotlin-reflect", version.ref = "kotlin" }
Expand Down
4 changes: 2 additions & 2 deletions gradle/merge-reports.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ afterEvaluate {
}

task mergeReports(type: Copy) {
from { testTasks*.reports.junitXml.destination } {
from { file("$buildDir/test-results") } {
exclude("**/binary/*")
}
into { file("$buildDir/reports/allTests") }
Expand All @@ -39,7 +39,7 @@ def disableHtmlTestReport(Project project) {
project.android {
testOptions {
unitTests.all {
reports.html.enabled = false
reports.html.required = false
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#Wed Dec 13 14:59:32 PST 2023
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading

0 comments on commit 0e994d6

Please sign in to comment.