-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Upgrade dependencies and tidy up build logic (#100)
* Upgrade to Gradle 8.12.1 * Upgrade dependencies - AGP to 8.8 - Kotlin to 2.0 - Dagger to 2.53 - Anvil to 2.5.1 - Others to (latest - x) version to avoid forcing a lot of responsibility on the consumers * Migrate buildscript block to plugins DSL * Set compile SDK to 35 * Use compileOnly for library deps when applicable and migrate to new compose plugin * Update sample deps * Replace subproject config with a proper build-logic plugin * Tidy up toolchains config * Remove autoservice config in whetstone-gradle-plugin * Upgrade maven-publish plugin * Run apiDump
- Loading branch information
1 parent
34d67b2
commit cccafb5
Showing
18 changed files
with
224 additions
and
166 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
plugins { | ||
id("java-gradle-plugin") | ||
alias(libs.plugins.kotlinJvm) | ||
alias(libs.plugins.kotlinSam) | ||
} | ||
|
||
samWithReceiver { | ||
annotation("org.gradle.api.HasImplicitReceiver") | ||
} | ||
|
||
gradlePlugin { | ||
plugins.register("buildPlugin") { | ||
id = "com.deliveryhero.whetstone.build" | ||
implementationClass = "com.deliveryhero.whetstone.build.BuildPlugin" | ||
} | ||
} | ||
|
||
kotlin.compilerOptions { | ||
optIn.add("kotlin.ExperimentalStdlibApi") | ||
freeCompilerArgs.add("-Xjvm-default=all") | ||
} | ||
|
||
dependencies { | ||
implementation(gradleKotlinDsl()) | ||
compileOnly(libs.kotlinGradle) | ||
compileOnly(libs.androidGradle) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../gradle/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
@file:Suppress("UnstableApiUsage") | ||
|
||
rootProject.name = "build-logic" | ||
|
||
pluginManagement { | ||
repositories { | ||
gradlePluginPortal() | ||
google() | ||
mavenCentral() | ||
} | ||
} | ||
|
||
dependencyResolutionManagement { | ||
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) | ||
repositories { | ||
google() | ||
mavenCentral() | ||
} | ||
} |
48 changes: 48 additions & 0 deletions
48
build-logic/src/main/java/com/deliveryhero/whetstone/build/BuildPlugin.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package com.deliveryhero.whetstone.build | ||
|
||
import com.android.build.api.dsl.CommonExtension | ||
import org.gradle.api.JavaVersion | ||
import org.gradle.api.Plugin | ||
import org.gradle.api.Project | ||
import org.gradle.api.plugins.JavaPluginExtension | ||
import org.gradle.kotlin.dsl.configure | ||
import org.jetbrains.kotlin.gradle.dsl.* | ||
|
||
class BuildPlugin : Plugin<Project> { | ||
|
||
override fun apply(target: Project) { | ||
target.configureJava() | ||
target.configureKotlin() | ||
target.configureAndroid() | ||
} | ||
|
||
private fun Project.configureJava() = configure<JavaPluginExtension> { | ||
sourceCompatibility = JavaVersion.VERSION_11 | ||
targetCompatibility = JavaVersion.VERSION_11 | ||
} | ||
|
||
private fun Project.configureKotlin() = configure<KotlinProjectExtension> { | ||
val config: KotlinJvmCompilerOptions.() -> Unit = { | ||
optIn.add("com.squareup.anvil.annotations.ExperimentalAnvilApi") | ||
freeCompilerArgs.addAll("-Xjvm-default=all", "-Xassertions=jvm") | ||
jvmTarget.set(JvmTarget.JVM_11) | ||
} | ||
when (this) { | ||
is KotlinJvmProjectExtension -> compilerOptions(config) | ||
is KotlinAndroidProjectExtension -> compilerOptions(config) | ||
} | ||
if (project.name != "sample") explicitApi() | ||
jvmToolchain(17) | ||
} | ||
|
||
private fun Project.configureAndroid() = plugins.withId("com.android.base") { | ||
extensions.configure(CommonExtension::class) { | ||
compileSdk = 35 | ||
defaultConfig.minSdk = 21 | ||
compileOptions { | ||
sourceCompatibility = JavaVersion.VERSION_11 | ||
targetCompatibility = JavaVersion.VERSION_11 | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,68 +1,18 @@ | ||
import com.android.build.gradle.BaseExtension | ||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile | ||
|
||
buildscript { | ||
repositories { | ||
gradlePluginPortal() | ||
google() | ||
} | ||
|
||
dependencies { | ||
classpath(libs.androidGradle) | ||
classpath(libs.kotlinGradle) | ||
classpath(libs.anvilGradle) | ||
classpath(libs.mavenPublishGradle) | ||
} | ||
} | ||
|
||
subprojects { | ||
afterEvaluate { | ||
tasks.withType<KotlinCompile> { | ||
configureTask() | ||
} | ||
extensions.findByType<BaseExtension>()?.apply { | ||
configureExtension() | ||
} | ||
} | ||
} | ||
|
||
fun KotlinCompile.configureTask() { | ||
kotlinOptions { | ||
jvmTarget = JavaVersion.VERSION_11.toString() | ||
|
||
val compilerArgs = mutableListOf( | ||
"-Xassertions=jvm", | ||
"-opt-in=kotlin.RequiresOptIn", | ||
"-opt-in=com.squareup.anvil.annotations.ExperimentalAnvilApi", | ||
) | ||
if (project.name != "sample") compilerArgs += "-Xexplicit-api=strict" | ||
freeCompilerArgs = freeCompilerArgs + compilerArgs | ||
} | ||
} | ||
|
||
fun BaseExtension.configureExtension() { | ||
compileSdkVersion(34) | ||
|
||
defaultConfig { | ||
minSdk = 21 | ||
targetSdk = 33 | ||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" | ||
} | ||
compileOptions { | ||
sourceCompatibility = JavaVersion.VERSION_11 | ||
targetCompatibility = JavaVersion.VERSION_11 | ||
} | ||
} | ||
|
||
|
||
plugins { | ||
id("org.jetbrains.kotlinx.binary-compatibility-validator") version "0.13.2" | ||
alias(libs.plugins.kotlinCompose).apply(false) | ||
alias(libs.plugins.androidApp).apply(false) | ||
alias(libs.plugins.androidLib).apply(false) | ||
alias(libs.plugins.kotlinJvm).apply(false) | ||
alias(libs.plugins.kotlinKapt).apply(false) | ||
alias(libs.plugins.anvil).apply(false) | ||
alias(libs.plugins.mavenPublish).apply(false) | ||
alias(libs.plugins.binaryValidator) | ||
} | ||
|
||
apiValidation { | ||
ignoredProjects.addAll(listOf("sample", "whetstone-compiler")) | ||
} | ||
|
||
tasks.register("clean", Delete::class) { | ||
tasks.register<Delete>("clean") { | ||
delete(rootProject.layout.buildDirectory) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,19 @@ | ||
plugins { | ||
kotlin("jvm") | ||
kotlin("kapt") | ||
id("com.deliveryhero.whetstone.build") | ||
id("com.vanniktech.maven.publish") | ||
} | ||
|
||
java { | ||
toolchain { | ||
languageVersion.set(JavaLanguageVersion.of("11")) | ||
} | ||
kotlin { | ||
jvmToolchain(17) | ||
} | ||
|
||
dependencies { | ||
implementation(libs.anvilCompiler) | ||
implementation(libs.anvilCompilerUtils) | ||
implementation(libs.anvilAnnotations) | ||
implementation(libs.dagger) | ||
implementation(libs.autoServiceAnnotations) | ||
compileOnly(libs.anvilCompiler) | ||
compileOnly(libs.anvilCompilerUtils) | ||
compileOnly(libs.anvilAnnotations) | ||
compileOnly(libs.dagger) | ||
compileOnly(libs.autoServiceAnnotations) | ||
kapt(libs.autoServiceCompiler) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.