Skip to content

Conversation

@adam-enko
Copy link
Member

@adam-enko adam-enko commented Oct 14, 2025

When using AGP 9, KGP is no longer required. AGP will be responsible for configuring Kotlin compilation. DGP needs to support Kotlin Built-in by extracting information from AGP instead of KGP.

Fix #4256

Summary of changes

  • Update KotlinAdapter and AndroidAdapter to handle AGP with Kotlin built-in.
    • Capture classpaths of variants from AndroidComponentsExtension instead of the Android extension.
    • Update captured AGP variant info to include classpaths.
    • Only apply KotlinAdapter and AndroidAdapter once per project (Remove the exec() function, only apply the plugin once using KotlinAdapter.applyTo()).
  • Add tests for AGP 9.
    • it-android-kotlin-jvm-builtin - AGP & kotlin-built-in (no KGP plugin).
    • it-android-kotlin-mp-builtin - AGP & kotlin-multiplatform.
  • Fix AGP <9 tests & update test data.

Integration tests: support AGP 9 testing and version filtering

  • Add min/max version to @TestsAndroid and @TestsAndroidCompose filter AGP versions.
  • Add SemVerRange to help with filtering.
  • Add AGP9 properties.

@adam-enko adam-enko self-assigned this Oct 14, 2025
@adam-enko adam-enko added the runner: Gradle plugin An issue/PR related to Dokka's Gradle plugin label Oct 14, 2025
@adam-enko adam-enko changed the base branch from master to adam/kgp-2.2.20-compatibility November 5, 2025 09:24
@adam-enko adam-enko force-pushed the adam/support-agp-kotlin-builtin branch from 12c2bb1 to 4dd9e43 Compare November 5, 2025 09:26
When using AGP 9, KGP is no longer required. AGP will be responsible for configuring Kotlin compilation. DGP needs to support Kotlin BuiltIn by extracting information from AGP instead of KGP.

- Update KotlinAdapter and AndroidAdapter to handle AGP with Kotlin built-in.
  - Capture classpaths of variants from `AndroidComponentsExtension` instead of the Android extension.
  - Update captured AGP variant info to include classpaths.
  - Only apply KotlinAdapter and AndroidAdapter once per project (Remove the `exec()` function, only apply the plugin once using `KotlinAdapter.applyTo()`).
Preparation for testing AGP9.

- Add min/max version to `@TestsAndroid` and `@TestsAndroidCompose` filter AGP versions.
- Add SemVerRange to help with filtering.
- Add AGP9 properties.
Base automatically changed from adam/kgp-2.2.20-compatibility to master November 12, 2025 16:14
If a project has `kotlin-multiplatform` and `com.android.kotlin.multiplatform.library` then AndroidAdapter shouldn't be necessary. `compilationClasspath`  already contains android.jar and the classpath from Android's Components.
Filter out KGP versions, specifically because com.android.kotlin.multiplatform.library requires KGP 2.0.0+
minor tweak to make it easier to see where the comments refer to
# Conflicts:
#	dokka-integration-tests/gradle/src/main/kotlin/org/jetbrains/dokka/it/gradle/junit/TestedVersionsSource.kt
#	dokka-runners/dokka-gradle-plugin/src/main/kotlin/adapters/KotlinAdapter.kt
#	dokka-runners/dokka-gradle-plugin/src/main/kotlin/internal/findExtensionLenient.kt
#	dokka-runners/dokka-gradle-plugin/src/testFunctional/kotlin/MultiModuleFunctionalTest.kt
@adam-enko adam-enko marked this pull request as draft November 18, 2025 12:17
@adam-enko
Copy link
Member Author

Converted to a draft because I'm going to split this PR into smaller pieces.

  • Update test utils to support version filtering.
  • Updates to 'find extension lenient'.
  • Support AGP9.
  • Misc fixes.
  • Adding test projects.

Tag tests that use Kotlin JVM plugin.

(This will become more relevant when we add a test for AGP9 with Kotlin-built-in.)
Move the `@WithGradleProperties` defaults to the tags that require them.
The test classes are simpler.

(This will become more relevant when we need to test AGP9 with built-in-kotlin.)
…ort-agp-kotlin-builtin

# Conflicts:
#	dokka-integration-tests/gradle/src/main/kotlin/org/jetbrains/dokka/it/gradle/junit/testTags.kt
#	dokka-integration-tests/gradle/src/test/kotlin/AndroidComposeIT.kt
#	dokka-integration-tests/gradle/src/test/kotlin/AndroidProjectIT.kt
#	dokka-integration-tests/gradle/src/test/kotlin/MultiplatformAndroidJvmProjectIT.kt
# Conflicts:
#	dokka-integration-tests/gradle/src/main/kotlin/org/jetbrains/dokka/it/gradle/junit/testTags.kt
#	dokka-integration-tests/gradle/src/test/kotlin/AndroidComposeIT.kt
#	dokka-integration-tests/gradle/src/test/kotlin/MultiplatformAndroidJvmProjectIT.kt
# Conflicts:
#	build.gradle.kts
#	dokka-integration-tests/gradle/projects/it-android-kotlin-mp-builtin/build.gradle.kts
#	dokka-integration-tests/gradle/projects/it-android-kotlin-mp-builtin/gradle.properties
#	dokka-integration-tests/gradle/src/test/kotlin/AndroidKotlinMultiplatformBuiltInTest.kt
- Instead of lower-level manual version selection, instead defined whether a test project supports Kotlin built-in
- Remove SemVerRange
…enerated

It could be a bit of a pain to maintain? But it's quick and easy, and if it prevents a bug where a version is accidentally filtered out it'd be worth it.

(we could use test coverage support, but this is a quick and easy one)
# Conflicts:
#	dokka-runners/dokka-gradle-plugin/src/main/kotlin/adapters/AndroidAdapter.kt
#	dokka-runners/dokka-gradle-plugin/src/main/kotlin/adapters/JavaAdapter.kt
#	dokka-runners/dokka-gradle-plugin/src/main/kotlin/adapters/KotlinAdapter.kt
#	dokka-runners/dokka-gradle-plugin/src/main/kotlin/internal/PluginId.kt
#	dokka-runners/dokka-gradle-plugin/src/testFunctional/kotlin/MultiModuleFunctionalTest.kt
adam-enko added a commit that referenced this pull request Nov 24, 2025
Add support for testing AGP projects that use kotlin-built-in.

I converted the existing `requiredAgpMajorVersions` check into a unit test.
This will help verify that TestedVersionsSource doesn't accidentally filter out any of the tested versions.
It could be a bit of a pain to maintain? But this test is quick and easy, and if it prevents a bug where a version is accidentally excluded, it'd be worth it.
(We could use test coverage support on TeamCity? But I'm not sure how to add that, and it could be fragile or easy to ignore?)

Currently there are no test-projects for kotlin-built-in. These will be added in #4295.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

runner: Gradle plugin An issue/PR related to Dokka's Gradle plugin

Projects

None yet

Development

Successfully merging this pull request may close these issues.

AGP 9 support

4 participants