Norbi
09/11/2023, 8:45 AMbuildSrc
module loading several common Gradle plugins, used by precompiled script plugins:
// buildSrc/build.gradle.kts
dependencies {
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.10")
...
}
The project had no Android support, but now I'd like add the Android plugin as well to one of the sub-modules.
It seems that I have to add it to buildSrc
as well, otherwise I get the error (which seems to be a Gradle classloading conflict):
Unable to load class 'com.android.build.gradle.api.BaseVariant'.
So I added it to buildSrc
as well:
// buildSrc/build.gradle.kts
dependencies {
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.10")
...
implementation("com.android.tools.build:gradle:8.1.1")
}
Gradle sync now works in Idea but when I try to compile the project, errors like the following appear:
Cannot locate tasks that match ':kotlinw:kotlinw-remoting-client-ktor:compileJava' as task 'compileJava' not found in project ':kotlinw:kotlinw-remoting-client-ktor'.
Which I don't understand because the given project is a Kotlin-only project, it has no Java sources, and the Android plugin is not applied to it...
Do you have any idea what is happening? Thanks.xoangon
09/11/2023, 8:53 AMkotlinw-remoting-client-ktor
Gradle project?Norbi
09/11/2023, 8:57 AMplugins {
kotlin("multiplatform")
kotlin("plugin.serialization")
}
And in the root build.gradle.kts
there is a plugin applied to it in "legacy" style:
subprojects {
...
apply(plugin = "maven-publish")
...
xoangon
09/11/2023, 9:01 AMkotlin("multiplatform")
plugin and the id("com.android.library")
ones for their shared module. Can you try adding this last one?Norbi
09/11/2023, 9:53 AMcompileJava
, like
Executing tasks: [:buildSrc:compileJava, :buildSrc:testClasses] in project /home/norbi/project/workspace/buildSrc
and
Executing tasks: [:kotlinw:kotlinw-remoting-client-ktor:compileJava, ...] in project /home/norbi/project/workspace
So, if I do not build using CTRL+F9 but directly executing assemble
from the Gradle Tool Window, the build is successful 🙂
Now I have to figure out what should I bind to CTRL+F9 to build the project because assemble
seems to perform too much operations.Norbi
09/13/2023, 10:19 AM