Slide 1

Slide 1 text

{ Android | Kotlin } Gradle Plugin in 2026 Preparing for AGP 10.0.0 2026.09.03 DroidKaigi 2026 Bunjiro Miyoshi / RyuNen344

Slide 2

Slide 2 text

About me name: Bunjiro Miyoshi id: RyuNen344 bio: Kodee lover like: Build System や CI/CD、綺麗な API になっているライブラリ

Slide 3

Slide 3 text

ビルドを取り巻く環境は変化している Lightbuild (0.0.10 rc1) yaml で android を設定 Gradle の薄いラッパー Android CLI AI Agent 向けの開発 CLI Kotlin CLI yaml で定義 Gradle 非依存 AI Agent による開発の自動化の台頭により、環境の変化はますます大きくなっている

Slide 4

Slide 4 text

“ Investing in build speed pays off ” Improve the Performance of Gradle Builds https://docs.gradle.org/9.7.0/userguide/performance.html 誰が如何なる方法でビルドしようと、速ければ速いほどいい

Slide 5

Slide 5 text

Wrap up in 2025 Cache Me If You Can DroidKaigi 2025 · https://2025.droidkaigi.jp/timetable/946751/

Slide 6

Slide 6 text

01 / 02 WRAP UP IN 2025 Gradle Lifecycle Initialization android {} Configuration finalizeDsl beforeVariants Execution onVariants

Slide 7

Slide 7 text

02 / 02 WRAP UP IN 2025 Effective Gradle Cache Deterministic @Input / @Output を宣言する 出力のない Task にも出力を定義する 乱数や宣言していない入力を使わない Lazy Provider / Property を使う ProjectLayout でファイルを触る ProviderFactory で環境変数を読む Task の input/output は決定的かつ遅延評価可能にするのが望ましい Gradle が提供する API を使用して定義すること

Slide 8

Slide 8 text

{ Android | Kotlin } Gradle Plugin in 2026

Slide 9

Slide 9 text

01 / 03 BUILT-IN KOTLIN Built-in Kotlin: Plugin BEFORE AGP 8.x AFTER AGP 9.0 plugins { id("com.android.application") id("org.jetbrains.kotlin.android") id("org.jetbrains.kotlin.kapt") } plugins { id("com.android.application") id("com.google.devtools.ksp") } kotlin-android の削除 kapt を KSP に移行 ( 移行できない場合は legacy-kapt ) // if kapt cannot be migrated id("com.android.legacy-kapt")

Slide 10

Slide 10 text

02 / 03 BUILT-IN KOTLIN Built-in Kotlin: Extension BEFORE AGP 8.x AFTER AGP 9.0 android { compileOptions { sourceCompatibility = JavaVersion.VERSION_17 targetCompatibility = JavaVersion.VERSION_17 } android { compileOptions { sourceCompatibility = JavaVersion.VERSION_17 targetCompatibility = JavaVersion.VERSION_17 } } } kotlinOptions { languageVersion = "2.0" jvmTarget = "17" } kotlin { compilerOptions { languageVersion = KotlinVersion.KOTLIN_2_0 } } android.kotlinOptions を kotlin.compilerOptions へ移動 jvmTarget は android.compileOptions.targetCompatibility を継承

Slide 11

Slide 11 text

03 / 03 BUILT-IN KOTLIN Built-in Kotlin: Runtime buildscript { dependencies { classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:$version") classpath("com.google.devtools.ksp:symbol-processing-gradle-plugin: $version") } } KGP / KSP のバージョンは AGP に埋め込み バージョンを変更する場合は buildscript で classpath 指定

Slide 12

Slide 12 text

01 / 02 KMP LIBRARY com.android.kotlin.multiplatform.library BEFORE AGP 8.x AFTER AGP 9.0 plugins { id("org.jetbrains.kotlin.multiplatform") id("com.android.library") } plugins { id("org.jetbrains.kotlin.multiplatform") id("com.android.kotlin.multiplatform.library" ) } kotlin { androidTarget() } kotlin { // AGP 8.10-8.11: androidLibrary // AGP 8.12+: android android { // namespace, compileSdk, minSdk } } android { // namespace, compileSdk, minSdk } com.android.library を com.android.kotlin.multiplatform.library に変更 kotlin.androidTarget() と android {} は kotlin.android {} に統合

Slide 13

Slide 13 text

02 / 02 KMP LIBRARY com.android.kotlin.multiplatform.library できること ソースと依存は KMP の sourceSet へ Resources / Java / Local Unit Test / Instrumented Test は opt-in Android Lint 使用する場合は明示的に com.android.lint を適用 https://issuetracker.google.com/issues/385271861 できなくなること Build Type と Product Flavor Test Fixtures / Data Binding / View Binding / BuildConfig / AIDL / RenderScript / etc... アプリのエントリーポイント(com.android.application)

Slide 14

Slide 14 text

01 / 02 TEST FIXTURES AGP 9 supports Kotlin Test Fixtures android { testFixtures { enable = true androidResources = true } } dependencies { testFixturesImplementation(/* dependency */) } 別モジュールむけの Fixture が同一モジュールで実装可能 src/testFixtures/kotlin にコードを配置 app src androidTest main test [unitTest] testFixtures build.gradle

Slide 15

Slide 15 text

02 / 02 TEST FIXTURES AGP が対応するまで AGP 7.1 AGP 8.5 Adds DSL Gradle 5.6 Supports JVM Gradle 5.6 から AGP 9.0 まで 6 年 Experimental Kotlin AGP 7.2 Supports Java AGP 9.0 Stable Kotlin & IDE

Slide 16

Slide 16 text

01 / 02 WHY BUILD MODEL Why so complicated Document を 写すだけ... AGP / KGP が 大きすぎる... Compile SDK の ための作業...

Slide 17

Slide 17 text

02 / 02 WHY BUILD MODEL May the Build Model be with you 書いた 1 行を 説明できる どこを触るか 当たりがつく API diff の 意味がわかる

Slide 18

Slide 18 text

01 / 04 GRADLE BUILD MODEL Gradle Build Model INITIALIZATION CONFIGURATION EXECUTION Settings Plugin Extension Project SourceSet Configuration Task

Slide 19

Slide 19 text

02 / 04 GRADLE BUILD MODEL Initialization Phase INITIALIZATION Settings CONFIGURATION EXECUTION Settings org.gradle.api.initialization.Settings Plugin Extension この build が何で構成されるかを表すモデル Project Project org.gradle.api.Project SourceSet Configuration :app のような Gradle モジュール 1 つを表すモデル Task

Slide 20

Slide 20 text

03 / 04 GRADLE BUILD MODEL Configuration Phase INITIALIZATION CONFIGURATION EXECUTION Settings Plugin Extension Project Plugin org.gradle.api.Plugin SourceSet Extension、ビルド対象、Task を作るオブジェクト ビルド対象と Task は Set<*> で保持される Extension Configuration Plugin に値を設定するためのモデル Task

Slide 21

Slide 21 text

04 / 04 GRADLE BUILD MODEL Configuration Phase INITIALIZATION CONFIGURATION SourceSet Settings ※ org.gradle.api.tasks.SourceSet 入力として扱うソースとリソースの集合 EXECUTION Configuration Task org.gradle.api.artifacts.Configuration org.gradle.api.Task Plugin Extension 依存とアーティファクトの集合 Project SourceSet Configuration Task 処理のまとまりを表すモデル

Slide 22

Slide 22 text

01 / 06 JAVA GRADLE PLUGIN Configuration, what? gradle.afterProject { configurations.forEach { println(it.name) } } androidJdkImage androidTestAnnotationProcessor androidTestApi androidTestCompileOnly androidTestDebugAnnotationProcessor androidTestDebugApi androidTestDebugCompileOnly androidTestDebugImplementation androidTestDebugImplementationDependenciesMetadata androidTestDebugRuntimeOnly androidTestDebugWearApp androidTestImplementation androidTestImplementationDependenciesMetadata androidTestReleaseAnnotationProcessor androidTestReleaseApi androidTestReleaseCompileOnly androidTestReleaseImplementation androidTestReleaseImplementationDependenciesMetadata androidTestReleaseRuntimeOnly androidTestReleaseWearApp androidTestRuntimeOnly androidTestUtil androidTestWearApp annotationProcessor api archives compileOnly compileOnlyApi composeMappingProducerClasspath coreLibraryDesugaring debugAnnotationProcessor debugApi debugCompileOnly debugCompileOnlyApi debugImplementation debugImplementationDependenciesMetadata debugRuntimeOnly debugWearApp default implementation implementationDependenciesMetadata jacocoAgent jacocoAnt kotlinBuildToolsApiClasspath kotlinCompilerClasspath kotlinCompilerPluginClasspath kotlinInternalAbiValidation kotlinKlibCommonizerClasspath kotlinNativeCompilerPluginClasspath ksp kspAndroidTest kspAndroidTestDebug kspAndroidTestRelease kspDebug kspRelease kspTest kspTestDebug kspTestFixtures kspTestFixturesDebug kspTestFixturesRelease kspTestRelease lintChecks lintPublish releaseAnnotationProcessor releaseApi releaseCompileOnly releaseCompileOnlyApi releaseImplementation releaseImplementationDependenciesMetadata releaseRuntimeOnly releaseWearApp runtimeOnly testAnnotationProcessor testApi testCompileOnly testDebugAnnotationProcessor testDebugApi testDebugCompileOnly testDebugImplementation testDebugImplementationDependenciesMetadata testDebugRuntimeOnly testDebugWearApp testFixturesAnnotationProcessor testFixturesApi testFixturesCompileOnly testFixturesCompileOnlyApi testFixturesDebugAnnotationProcessor testFixturesDebugApi testFixturesDebugCompileOnly testFixturesDebugCompileOnlyApi testFixturesDebugImplementation testFixturesDebugImplementationDependenciesMetadata testFixturesDebugRuntimeOnly testFixturesDebugWearApp testFixturesImplementation testFixturesImplementationDependenciesMetadata testFixturesReleaseAnnotationProcessor testFixturesReleaseApi testFixturesReleaseCompileOnly testFixturesReleaseCompileOnlyApi testFixturesReleaseImplementation testFixturesReleaseImplementationDependenciesMetadata testFixturesReleaseRuntimeOnly testFixturesReleaseWearApp testFixturesRuntimeOnly testFixturesWearApp testImplementation testImplementationDependenciesMetadata testReleaseAnnotationProcessor testReleaseApi testReleaseCompileOnly testReleaseImplementation testReleaseImplementationDependenciesMetadata testReleaseRuntimeOnly testReleaseWearApp testRuntimeOnly testWearApp wearApp

Slide 23

Slide 23 text

02 / 06 JAVA GRADLE PLUGIN Configuration, what? gradle.afterProject { configurations.forEach { println(it.name) } } androidJdkImage androidTestAnnotationProcessor androidTestApi androidTestCompileOnly androidTestDebugAnnotationProcessor androidTestDebugApi androidTestDebugCompileOnly androidTestDebugImplementation androidTestDebugImplementationDependenciesMetadata androidTestDebugRuntimeOnly androidTestDebugWearApp androidTestImplementation androidTestImplementationDependenciesMetadata androidTestReleaseAnnotationProcessor androidTestReleaseApi androidTestReleaseCompileOnly androidTestReleaseImplementation androidTestReleaseImplementationDependenciesMetadata androidTestReleaseRuntimeOnly androidTestReleaseWearApp androidTestRuntimeOnly androidTestUtil androidTestWearApp annotationProcessor api archives compileOnly compileOnlyApi composeMappingProducerClasspath coreLibraryDesugaring debugAnnotationProcessor debugApi debugCompileOnly debugCompileOnlyApi debugImplementation debugImplementationDependenciesMetadata debugRuntimeOnly debugWearApp default implementation implementationDependenciesMetadata jacocoAgent jacocoAnt kotlinBuildToolsApiClasspath kotlinCompilerClasspath kotlinCompilerPluginClasspath kotlinInternalAbiValidation kotlinKlibCommonizerClasspath kotlinNativeCompilerPluginClasspath ksp kspAndroidTest kspAndroidTestDebug kspAndroidTestRelease kspDebug kspRelease kspTest kspTestDebug kspTestFixtures kspTestFixturesDebug kspTestFixturesRelease kspTestRelease lintChecks lintPublish releaseAnnotationProcessor releaseApi releaseCompileOnly releaseCompileOnlyApi releaseImplementation releaseImplementationDependenciesMetadata releaseRuntimeOnly releaseWearApp runtimeOnly testAnnotationProcessor testApi testCompileOnly testDebugAnnotationProcessor testDebugApi testDebugCompileOnly testDebugImplementation testDebugImplementationDependenciesMetadata testDebugRuntimeOnly testDebugWearApp testFixturesAnnotationProcessor testFixturesApi testFixturesCompileOnly testFixturesCompileOnlyApi testFixturesDebugAnnotationProcessor testFixturesDebugApi testFixturesDebugCompileOnly testFixturesDebugCompileOnlyApi 一旦 Java Gradle Plugin で考える testFixturesDebugImplementation testFixturesDebugImplementationDependenciesMetadata testFixturesDebugRuntimeOnly testFixturesDebugWearApp testFixturesImplementation testFixturesImplementationDependenciesMetadata testFixturesReleaseAnnotationProcessor testFixturesReleaseApi testFixturesReleaseCompileOnly testFixturesReleaseCompileOnlyApi testFixturesReleaseImplementation testFixturesReleaseImplementationDependenciesMetadata testFixturesReleaseRuntimeOnly testFixturesReleaseWearApp testFixturesRuntimeOnly testFixturesWearApp testImplementation testImplementationDependenciesMetadata testReleaseAnnotationProcessor testReleaseApi testReleaseCompileOnly testReleaseImplementation testReleaseImplementationDependenciesMetadata testReleaseRuntimeOnly testReleaseWearApp testRuntimeOnly testWearApp wearApp

Slide 24

Slide 24 text

03 / 06 JAVA GRADLE PLUGIN Java Gradle Plugin, then? gradle.afterProject { configurations.forEach { println(it.name) } } api implementation compileOnly compileOnlyApi runtimeOnly annotationProcessor testImplementation testCompileOnly testRuntimeOnly testAnnotationProcessor compileClasspath runtimeClasspath testCompileClasspath testRuntimeClasspath apiElements runtimeElements mainSourceElements testResultsElementsForTest

Slide 25

Slide 25 text

04 / 06 JAVA GRADLE PLUGIN Java Gradle Plugin, then? gradle.afterProject { configurations.forEach { println(it.name) } } Dependency Scope Classpath Elements 依存を宣言する場所 artifact を解決する入力 artifact を公開する出力 api implementation compileOnly compileOnlyApi runtimeOnly annotationProcessor testImplementation testCompileOnly testRuntimeOnly testAnnotationProcessor compileClasspath runtimeClasspath testCompileClasspath testRuntimeClasspath apiElements runtimeElements mainSourceElements testResultsElementsForTest

Slide 26

Slide 26 text

05 / 06 JAVA GRADLE PLUGIN You already type them dependencies { implementation("$groupId:$artifactId:$version") } dependencies { add("implementation", "$groupId:$artifactId:$version") } fun DependencyHandler.implementation(dependencyNotation: Any): Dependency? = add("implementation", dependencyNotation)

Slide 27

Slide 27 text

06 / 06 JAVA GRADLE PLUGIN Java Gradle Plugin, doing what? INITIALIZATION Settings CONFIGURATION implementation Plugin compileOnly EXECUTION extendsFrom Extension Project main が持つ input は src/main/java src/main/resources main compile Classpath compileJava

Slide 28

Slide 28 text

01 / 03 EXTENSION & SOURCESET sourceSets is not a SourceSet Java Gradle Plugin AGP sourceSets { main { java.srcDir("src/gen") } } android { sourceSets { getByName("main") { ... } } } fun Project.sourceSets(configure: Action) = (this as ExtensionAware).extensions.configure("sourceSets", configure) interface com.android.build.api.dsl.ApplicationExtension { val sourceSets: NamedDomainObjectContainer } sourceSets は SourceSet への入り口

Slide 29

Slide 29 text

02 / 03 EXTENSION & SOURCESET AGP 9, no more type parameters BEFORE AGP 8.x fun CommonExtension<*, *, *, *>.something() { } fun CommonExtension<*, *, *, *, *>.something() { } fun CommonExtension<*, *, *, *, *, *>.something() { } // AGP 7.0 - 8.0 // AGP 8.1 // AGP 8.3 AFTER AGP 9.0 interface com.android.build.api.dsl.CommonExtension interface com.android.build.api.dsl.ApplicationExtension : CommonExtension fun CommonExtension.something() { } Type Parameter が増減していたため ソース互換性 が低かった AGP 9 で CommonExtension の Type Parameter を全廃し、DSL ブロックをサブタイプ側へ移した

Slide 30

Slide 30 text

03 / 03 EXTENSION & SOURCESET Kotlin DSL gets it too inline fun ExtensionContainer.findByType(): T? = findByType(typeOf()) // TypeOf, not Class BEFORE AGP 8.x extensions.findByType>() // null -> org.gradle.api.reflect.TypeOf> AFTER AGP 9.0 extensions.findByType() -> TypeOf Class なら型引数は消えるが TypeOf は型引数 が消えない Type Parameter がなくなったため TypeOf でも CommonExtension を取得できるようになった

Slide 31

Slide 31 text

01 / 02 NON BUILD PLUGIN And com.google.devtools.ksp? Plugin plugins { id("com.google.devtools.ksp") } Extension ksp { arg("key", "value") } fun Project.`ksp`(configure: Action): Unit = (this as ExtensionAware).extensions.configure("ksp", configure) Configuration dependencies { ksp("$groupId:$artifactId:$version") } fun DependencyHandler.`ksp`(dependencyNotation: Any): Dependency? = add("ksp", dependencyNotation)

Slide 32

Slide 32 text

02 / 02 NON BUILD PLUGIN And com.google.devtools.ksp? Plugin plugins { id("com.google.devtools.ksp") } Task ksp { arg("key", "value") } kspDebugKotlin Extension fun Project.`ksp`(configure: Action): Unit = (this as ExtensionAware).extensions.configure("ksp", configure) dependencies { ksp("$groupId:$artifactId:$version") } Configuration fun DependencyHandler.`ksp`(dependencyNotation: Any): Dependency? = add("ksp", dependencyNotation)

Slide 33

Slide 33 text

01 / 01 FIRST HALF WRAP UP What You Write, What a Plugin Makes Gradle はビルドを抽象化したモデルを持っている Plugin は Extension と SourceSet と Configuration と Task を作る ビルドを設定しない Plugin も、Extension と Configuration から Task へ入力を渡す 書いているブロックは Extension、dependencies の名前は Configuration Kotlin DSL の Generics に要注意 Plugin を作る側は、公開 API を不必要に Generics へ依存させない 使う側は、必要なら Java like な書き方で対応する

Slide 34

Slide 34 text

01 / 06 KGP BUILD MODEL Kotlin JVM Gradle Plugin, doing what? INITIALIZATION CONFIGURATION EXECUTION Settings Java Gradle Plugin とほぼ同じ構成 Plugin Extension Project main が持つ入力は src/main/kotlin src/main/java main compile Classpath compileKotlin

Slide 35

Slide 35 text

02 / 06 KGP BUILD MODEL Kotlin JVM Gradle Plugin, doing what? SourceSet Configuration Task Output Java Gradle Plugin main compileClasspath compileJava classes compileClasspath compileKotlin classes Java Plugin のものを そのまま使う 出力が compileJava の classpath へ src/main/java Kotlin JVM Plugin main src/main/kotlin src/main/java Kotlin JVM Plugin は Java Gradle Plugin を適用した上に乗っている

Slide 36

Slide 36 text

03 / 06 KGP BUILD MODEL Sharing commonMain commonMain nativeMain jvmMain androidMain appleMain linuxMain mingwMain iosMain tvosMain watchosMain iosArm64Main iosSimulatorArm64Main iosArm64 / main の Compilation jvm / main の Compilation androidNativeMain macosMain

Slide 37

Slide 37 text

04 / 06 KGP BUILD MODEL commonMain's output, what? SourceSet Configuration Task Output Java Gradle Plugin main compileClasspath compileJava classes jvmCompileClasspath compileKotlinJvm classes iosArm64CompileKlibraries compileKotlinIosArm64 klib Kotlin Multiplatform Plugin commonMain org.gradle.api.tasks.SourceSet は行き先が一つであることを前提に作られている

Slide 38

Slide 38 text

05 / 06 KGP BUILD MODEL KGP defines its own SourceSet and Compilation org.gradle.api.tasks.SourceSet Source Dependency KotlinSourceSet Source Classpath Output KotlinCompilation Dependency + 他の SourceSet への dependsOn Classpath + どの SourceSet を集めるか + どの Target 向けか 共有できる org.jetbrains.kotlin.gradle.plugin.KotlinSourceSet を定義した Output

Slide 39

Slide 39 text

06 / 06 KGP BUILD MODEL Between SourceSet and Task INITIALIZATION CONFIGURATION EXECUTION Settings KotlinTarget Plugin Project Extension KotlinCompilation commonMain SourceSet jvmMain Configuration jvmCompileClasspath Task KotlinSourceSet と KotlinCompilation で Many to Many を実現した

Slide 40

Slide 40 text

01 / 04 LEGACY VARIANT API Sharing main SourceSet Output Java Gradle Plugin main compileJava jar Android Gradle Plugin fooDebug main flavor foo/bar type debug/release fooRelease barDebug barRelease main の出力は build type × flavor 通りある apk aab aar etc...

Slide 41

Slide 41 text

02 / 04 LEGACY VARIANT API main's tasks, how many? SourceSet Output Java Gradle Plugin main compileJava jar Android は ビルドするものがいっぱいある Android Gradle Plugin fooDebug main flavor foo/bar type debug/release fooRelease barDebug barRelease preBuild checkManifest aidlCompile apk renderscriptCompile mergeResources aab mergeAssets aar generateBuildConfig etc... javaCompile processJavaResources assemble

Slide 42

Slide 42 text

03 / 04 LEGACY VARIANT API com.android.build.gradle.api.BaseVariant SourceSet Output Java Gradle Plugin compileJava fooDebug main ひとつぶんが BaseVariant ひとつ Android Gradle Plugin BaseVariant fooDebug main flavor foo/bar type debug/release jar fooRelease barDebug barRelease preBuild checkManifest aidlCompile apk renderscriptCompile mergeResources aab mergeAssets aar generateBuildConfig etc... javaCompile processJavaResources assemble

Slide 43

Slide 43 text

04 / 04 LEGACY VARIANT API From SourceSet to Task INITIALIZATION CONFIGURATION EXECUTION Settings Variant の数だけ Configuration と Task が作られる Plugin Extension com.android.build.gradle.api.BaseVariant Project com.android.build.gradle.api AndroidSourceSet Configuration Task

Slide 44

Slide 44 text

01 / 03 ANDROID COMPONENTS API Build Model of Components API INITIALIZATION CONFIGURATION EXECUTION Extension Settings 束ねる型が Component になり、 Extension が 1 つ増えた Plugin androidComponents com.android.build.api.variant.Component Project com.android.build.api.dsl AndroidSourceSet Configuration Task new

Slide 45

Slide 45 text

02 / 03 ANDROID COMPONENTS API Build Model of Components API INITIALIZATION CONFIGURATION EXECUTION Extension Settings 束ねる型が Component になり、 Extension が 1 つ増えた Plugin ココ androidComponents com.android.build.api.variant.Component Project com.android.build.api.dsl AndroidSourceSet Configuration AndroidSourceSet com.android.build.api.dsl Task

Slide 46

Slide 46 text

03 / 03 ANDROID COMPONENTS API Component Lifecycle Hooks 何をいつ変えられるのかが型で決まる Initialization android {} com.android.build.api.variant Configuration com.android.build.api.variant ComponentBuilder Component 確定前 確定後 finalizeDsl beforeVariants Execution onVariants

Slide 47

Slide 47 text

01 / 02 BUILT-IN KOTLIN Built-in Kotlin means ... Extension & Task Extension kotlin ブロックを AGP が用意する - id("org.jetbrains.kotlin.android") Task KotlinCompile を Component ごとに AGP が用意する KotlinCompile を AGP が主導する形に変わった

Slide 48

Slide 48 text

02 / 02 BUILT-IN KOTLIN Built-in Kotlin means ... Who Calls Whom Timing AGP 8.x AGP BaseVariant を作る BaseVariant を覗く Kotlin の出力を登録する KotlinCompile を作る KGP AGP 9.0 AGP Component を作る Artifacts に組み込む KotlinCompile を作らせる KGP コンパイルするのは KGP のまま KotlinCompile を作る source と classpath

Slide 49

Slide 49 text

01 / 02 KMP LIBRARY KMP Plugin means ... One Extension BEFORE AGP 8.x AFTER AGP 9.0 plugins { id("org.jetbrains.kotlin.multiplatform") id("com.android.library") } plugins { id("org.jetbrains.kotlin.multiplatform") id("com.android.kotlin.multiplatform.library" ) } kotlin { androidTarget() } kotlin { // AGP 8.10-8.11: androidLibrary // AGP 8.12+: android android { // namespace, compileSdk, minSdk } AGP が KGP を拡張する } KGP が AGP を拡張する android { // namespace, compileSdk, minSdk } Android のビルドをより一層 KGP に移譲する

Slide 50

Slide 50 text

02 / 02 KMP LIBRARY KMP Plugin means ... One Build Unit Timing com.android.library + androidTarget() AGP BaseVariant を作る BaseVariant を覗く Kotlin の出力を登録する KotlinCompilation を作る KGP com.android.kotlin.multiplatform.library AGP KotlinTarget を実装する 実装を渡す KGP 同じ 2 つの Plugin の境界が、モジュールの種類で逆を向く Compilation と Task を組み立てる

Slide 51

Slide 51 text

01 / 01 TEST FIXTURES Test Fixtures means ... AGP 8.5 - 8.x, flag ON Variant / HostTest / DeviceTest TestFixtures KGP が作る AGP が呼んで作る android.experimental.enableTestFixturesKotlinSupport KotlinCompile KotlinCompile AGP 9.0 All Component AGP が呼んで作る KotlinCompile 実験フラグの向こうで先取りしていた形が、そのまま既定になった

Slide 52

Slide 52 text

01 / 02 WRAP UP Models and FQCNs KGP は source を 階層で共有できるようにモデリングした AGP は組み合わせをビルド単位で管理する Legacy Variant API を細分化して Components API になった 同じ名前で別のモデルがあるので要注意 SourceSet org.gradle.api.tasks.SourceSet org.jetbrains.kotlin.gradle.plugin.KotlinSourceSet com.android.build.gradle.api.AndroidSourceSet com.android.build.api.dsl.AndroidSourceSet Variant / Component com.android.build.api.variant.Variant / Component com.android.build.gradle.api.BaseVariant org.gradle.api.component.SoftwareComponentVariant org.gradle.api.artifacts.ConfigurationVariant ← Gradle にもある

Slide 53

Slide 53 text

02 / 02 WRAP UP What to Look at, What to Follow Plugin を読み解くとき SourceSet / Configuration / Task の関係を整理して、ビルド単位を見つける SourceSet と Configuration に変更が入りそうなとき モデルの基礎なので、Plugin 全体へ波及する 今後のことも考えて、なるべく早く追従する AGP が Kotlin Gradle Plugin を扱うようになった ただし KMP はまだどうなるか分からない

Slide 54

Slide 54 text

Notice The Android robot is reproduced or modified from work created and shared by Google and used according to terms described in the Creative Commons 3.0 Attribution License. Kodee by JetBrains s.r.o. is licensed under CC BY 4.0. Modified from the original. This deck was built with Claude Code (Anthropic) as an authoring tool. All structure, wording, and technical claims were written, verified, and edited by the author. Android™ is a trademark of Google LLC. Kotlin® is a trademark of the Kotlin Foundation. Gradle® and Gradle Build Tool™ are trademarks of Gradle, Inc. This session is not affiliated with, sponsored, or endorsed by Google LLC, JetBrains s.r.o., the Kotlin Foundation, or Gradle, Inc.

Slide 55

Slide 55 text

EOF