Adam S
11/30/2023, 11:41 AM.
└── foo-project/
├── submodule1 (Kotlin JVM)
└── submodule2 (Kotlin JVM)
When I try and get KotlinProjectExtension I get an exception
val ke = project.extensions.findByType<org.jetbrains.kotlin.gradle.dsl.KotlinProjectExtension>()
// Type org.jetbrains.kotlin.gradle.dsl.KotlinProjectExtension not present
I find I need to have kotlin("jvm") version "1.8.22" apply false
on the root project, otherwise Dokkatoo can't fetch the Kotlin org.jetbrains.kotlin.gradle.dsl.KotlinProjectExtension
in the subprojects, even though they have applied the Kotlin JVM plugin.
I tried falling back to fetching org.jetbrains.kotlin.gradle.dsl.KotlinJvmProjectExtension
, but that also fails with the same error, "Type org.jetbrains.kotlin.gradle.dsl.KotlinJvmProjectExtension not present"
If I debug print the available extensions, I can see that KotlinJvmProjectExtension is present
logger.warn("extensions: ${project.extensions.extensionsSchema.elements.joinToString { "${it.name} ${it.publicType}" }}")
// extensions: kotlin org.jetbrains.kotlin.gradle.dsl.KotlinJvmProjectExtension (...)
Adam S
11/30/2023, 11:43 AMJavier
11/30/2023, 11:43 AMAdam S
11/30/2023, 11:44 AMkotlin("jvm")
is applied thereJavier
11/30/2023, 11:45 AMwithPlugin(…) { }
Adam S
11/30/2023, 11:45 AMkotlin("jvm") version "1.8.22" apply false
it fails https://github.com/adamko-dev/dokkatoo/blob/v2.0.0/modules/dokkatoo-plugin/src/testFunctional/kotlin/MultiModuleFunctionalTest.kt#L397-L399mbonnin
11/30/2023, 11:45 AMmbonnin
11/30/2023, 11:45 AMAdam S
11/30/2023, 11:45 AMwithPlugin(...) {}
https://github.com/adamko-dev/dokkatoo/blob/v2.0.0/modules/dokkatoo-plugin/src/main/kotlin/adapters/DokkatooKotlinAdapter.kt#L60-L67mbonnin
11/30/2023, 11:46 AMPlugin.apply()
) but not loading it (making .jar
known to the JVM)Javier
11/30/2023, 11:46 AMAdam S
11/30/2023, 11:47 AMPlugin.apply()
?Javier
11/30/2023, 11:47 AMJavier
11/30/2023, 11:48 AMJavier
11/30/2023, 11:48 AMmbonnin
11/30/2023, 11:48 AMJavier
11/30/2023, 11:49 AMmbonnin
11/30/2023, 11:49 AMmbonnin
11/30/2023, 11:51 AMmbonnin
11/30/2023, 11:51 AMmbonnin
11/30/2023, 11:51 AMmbonnin
11/30/2023, 11:51 AMAdam S
11/30/2023, 11:55 AMKotlinJvmProjectExtension
is present and applied via debug printing, but Dokkatoo fails to fetch itAdam S
11/30/2023, 11:55 AMmbonnin
11/30/2023, 11:59 AMam I right in thinking they should both be in the classloader?I'm not so sure they are in the "same" classloader. My current thinking is module classes can reference root classes but not the other way around
mbonnin
11/30/2023, 11:59 AMJavier
11/30/2023, 12:07 PMAdam S
11/30/2023, 12:12 PMAdam S
11/30/2023, 12:14 PMfindByName("kotlin")
fetches something successfully, but it's an Any
and casting it to KotlinProjectExtension
failsmbonnin
11/30/2023, 12:25 PMmbonnin
11/30/2023, 12:25 PMmbonnin
11/30/2023, 12:27 PMJavier
11/30/2023, 12:29 PMmbonnin
11/30/2023, 12:30 PMJavier
11/30/2023, 12:30 PMmbonnin
11/30/2023, 12:31 PMJavier
11/30/2023, 12:31 PMmbonnin
11/30/2023, 12:32 PMGradleRunner
and Tony's pluginsmbonnin
11/30/2023, 12:32 PMmbonnin
11/30/2023, 12:32 PMwithPluginClasspath
is a huge footgunJavier
11/30/2023, 12:33 PMval testPluginClasspath: Configuration =
configurations.create("testPluginClasspath")
tasks.withType<PluginUnderTestMetadata>().configureEach { metadata ->
metadata.pluginClasspath.from(testPluginClasspath)
}
and in the script something like
testPluginClasspath(libs.agp)
testPluginClasspath(libs.kgp)
mbonnin
11/30/2023, 12:34 PMJavier
11/30/2023, 12:34 PMJavier
11/30/2023, 12:34 PMGradleRunner
? It is what TestKit usesmbonnin
11/30/2023, 12:35 PMGradleRunner
is well defined. It's an API I can use, it has artifacts & kdocs and it's working well 👍 . TestKit
I have no idea what it is except it tests my plugin in conditions that are different from what my users are going to dombonnin
11/30/2023, 12:35 PMmbonnin
11/30/2023, 12:36 PMJavier
11/30/2023, 12:37 PMTestKit
is that GradleRunner
🤔 At least the import includes it org.gradle.testkit.runner.GradleRunner
Adam S
11/30/2023, 12:37 PMmbonnin
11/30/2023, 12:38 PMFor meis thatTestKit
GradleRunner
TestKit
= GradleRunner
+ withPluginClasspath()
+?Adam S
11/30/2023, 12:38 PMJavier
11/30/2023, 12:39 PMwithPluginClasspath
is a configuration inside GradleRunner
mbonnin
11/30/2023, 12:39 PMJavier
11/30/2023, 12:39 PMmbonnin
11/30/2023, 12:40 PMJavier
11/30/2023, 12:41 PMJavier
11/30/2023, 12:42 PMmbonnin
11/30/2023, 12:43 PMAdam S
11/30/2023, 12:48 PMJavier
11/30/2023, 12:50 PMJavier
11/30/2023, 12:50 PMJavier
11/30/2023, 12:50 PMTherefore, the test build does not share the same classpath or classloaders as the test process and the code under test is not implicitly available to the test build.
mbonnin
11/30/2023, 12:51 PMmbonnin
11/30/2023, 12:52 PMmbonnin
11/30/2023, 12:54 PMAdam S
11/30/2023, 12:57 PM