Status Update
Comments
au...@google.com <au...@google.com> #2
Known issue, we cannot do anything because AGP doesn't provide an API to fetch Kotlin sources (specifically here
al...@google.com <al...@google.com> #3
Would you be opposed to failing the build if we see a src/kotlin
directory?
au...@google.com <au...@google.com> #4
No, go ahead if you want to add that check.
al...@google.com <al...@google.com> #5
Adding to bounty list since this isn't a frequent occurrence.
- Sponsor: alanv
- Tech stack: Gradle build plugin
- Summary: Add check in
AndroidXPluginImpl
that raises an exception if a project is usingsrc/kotlin
for its source sets. The exception should indicate thatsrc/kotlin
is not fully supported by AGP and thatsrc/java
should be used instead.
al...@google.com <al...@google.com> #6
I'm seeing one library that's using src/main/kotlin
and seems to generate API files without issue: paging/paging-common
. Aurimas, any idea what might be going on there?
au...@google.com <au...@google.com> #7
That library is
plugins {
id("AndroidXPlugin")
id("kotlin")
}
a non android library and we use a different path for java/kotlin libraries.
au...@google.com <au...@google.com> #8
So correction is that metalava doesnt track APIs under src/main/kotlin for android projects.
al...@google.com <al...@google.com> #9
Thanks! Uploaded a CL that migrates the only two library projects that were using src/main/kotlin
.
al...@google.com <al...@google.com>
ga...@gmail.com <ga...@gmail.com> #10
ap...@google.com <ap...@google.com> #11
Branch: androidx-main
commit d76ba7bae7f5c13a30229e6104e7a7828f6f78b7
Author: Alan Viverette <alanv@google.com>
Date: Mon Apr 18 10:22:13 2022
Fail the build if library projects use src/kotlin instead of src/java
Migrates existing projects that fail check, none of which had public APIs.
Fixes: 229245098
Test: ./gradlew checkApi
Change-Id: I4035b1fbfa1dd6552152f9e3516c90cadfa27af2
M room/room-paging/src/main/java/androidx/room/paging/LimitOffsetPagingSource.kt
M buildSrc/private/src/main/kotlin/androidx/build/AndroidXImplPlugin.kt
M room/room-paging/src/main/java/androidx/room/paging/util/ThreadSafeInvalidationObserver.kt
M room/room-paging-guava/src/main/java/androidx/room/paging/guava/LimitOffsetListenableFuturePagingSource.kt
M room/room-paging/src/main/java/androidx/room/paging/util/RoomPagingUtil.kt
Description
./gradlew updateApi
does not yield any API file changes or API lint issues for aosp/2063429 because the source files are undersrc/main/kotlin
. This is a valid default source directory in AGP, and we should support it.If we choose not to support it, we should prevent developers from accidentally using this as a source directory.
Moving the files to
src/main/java
can be used as a temporary workaround.