Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kotlin 1.9.0: API files are not generated for a target if its leaf source set is empty #146

Open
arkivanov opened this issue Aug 11, 2023 · 3 comments
Labels
bug Something isn't working gradle

Comments

@arkivanov
Copy link

arkivanov commented Aug 11, 2023

Kotlin version 1.9.0
Plugin version: 0.13.0-0.13.2
Android + JVM + JS + linuxX64 + All Apple targets

When running apiDump task, no .api files are generated under api/jvm or api/android folder, if the corresponding leaf source set (i.e. jvmMain and androidMain respectively) is empty. If there is some code present in e.g. jvmMain source set (or at least jvmMain/kotlin empty folder is present), then the jvm API file gets generated, similar situate with android.

Also, running apiCheck task fails:

A problem was found with the configuration of task ':instance-keeper:jvmApiCheck' (type 'KotlinApiCompareTask').
  - In plugin 'org.jetbrains.kotlinx.binary-compatibility-validator' type 'kotlinx.validation.KotlinApiCompareTask' property 'apiBuildDir' specifies directory '/Users/arkivanov/dev/workspace/Essenty/instance-keeper/build/api/jvm' which doesn't exist.

Works fine with version 0.12.1 and Kotlin 1.8.20.

@arkivanov arkivanov changed the title Kotlin 1.9.0: the API file for the jvm target is not generated Kotlin 1.9.0: API files are not generated for a target if its leaf source set is empty Aug 11, 2023
@arkivanov
Copy link
Author

After further investigation, it appears that adding the following code to a module's build.gradle.kts causes the issue described above.

tasks.withType<KotlinApiCompareTask> {
}

Attached a reproducer: reproducer.zip

@qwwdfsad qwwdfsad added the bug Something isn't working label Aug 11, 2023
@fzhinkin
Copy link
Collaborator

There's a problem with how we set enabled property during task's configuration:

apiCheckEnabled(projectName, extension) && compilation.allKotlinSourceSets.any { it.kotlin.srcDirs.any { it.exists() } }

In the reproducer attached above, tasks.withType<KotlinApiCompareTask> triggers execution of the configuration block for "jvmApiBuild" task and at that point source sets are not yet filled/resolved/proper name for that action for the jvm compilation. There's only empty jvm source set, so we mark the task as disabled.

With the "normal" tasks flow, when the configuration block is executed for the build task, all source sets are already resolved for the JVM compilation and there should be some non-empty source set, for example, the common one/

@fzhinkin fzhinkin added the gradle label Apr 9, 2024
@fzhinkin
Copy link
Collaborator

fzhinkin commented Apr 9, 2024

Related: #206

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working gradle
Projects
None yet
Development

No branches or pull requests

3 participants