I have a Kotlin Multiplatform project (1.7.10), with multiple subprojects, using Gradle 7.4.2. When running Gradle tasks I regularly get an error message from the Kotlin Gradle plugin:
* What went wrong:
Execution failed for task ':modules:web-map:publicPackageJson'.
> Error while evaluating property 'externalDependencies$kotlin_gradle_plugin' of task ':modules:web-map:publicPackageJson'
> Projects must be configuring
The error will not go away, unless I somehow force the project to 'refresh'. So I can temporarily work around this by making an incidental edit to the root build.gradle.kts
, for example changing
// $projectRoot/build.gradle.kts
println("annoying bug")
into
// $projectRoot/build.gradle.kts
//println("annoying bug")
This minor change somehow forces the Kotlin plugin to 'refresh', and I can then run the Gradle task again.... until the next time. The bug is very quick to re-occur.
There are several bug tickets opened, but they have been awaiting resolution for months.
- https://youtrack.jetbrains.com/issue/KT-49774
- https://youtrack.jetbrains.com/issue/KT-50168
- https://youtrack.jetbrains.com/issue/KT-52647
However this bug is incredibly frustrating, so I would like to have a work around.
I have already tried
- disable Gradle caching
- disable Gradle parallelization
- force the Kotlin Gradle tasks to always run, by adding a 'cache busting' Gradle task input to all tasks
- creating a Gradle task that will automatically edit
build.gradle.kts
before all tasks, to automate forcing the refresh.
Unfortunately nothing worked consistently.
An example project is available here: https://youtrack.jetbrains.com/issue/KT-52647/KJS-Gradle-Make-Projects-must-be-configuring-a-warning#focus=Comments-27-6195302.0-0