-
Notifications
You must be signed in to change notification settings - Fork 0
BCV-MU settings plugin requires Kotlin plugin is defined as a buildscript dependency #1
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
Comments
We cannot use the relocated symbol to find an extension, because our relocated symbol not only has a different name, but also originates from a different classpath and is thus considered to not be the same thing at all. We cannot even cast from one to the other, despite us knowing that they are the same (well, we actually don't, because we don't know what version of the plugin the user applied, anyway). We can retrieve the extension by name and use runtime reflection to force it into our desired target type. |
* allow for nested project paths in GradleProjectTest util, and minor doc update * rename testGradleVersion to supportedGradleVersion * make testMavenPublication task dependency more explicit * update from ignoredMarkers to nonPublicMarkers in test case * update from using KGP to KGP-api * allow setting default BCV target values in BCVSettingsPlugin * update test assertions * Add settings plugin test * update README example for settings plugin * try using Shadow plugin... which didn't work, but it might with different config? #1 (comment) * add kotest-datatest in libs.versions.toml * commit code style * update formatting
Edit: never mind, I didn't realize this was about a settings plugin...
pluginManager.withPlugin("org.jetbrains.kotlin.jvm") { found = true; doStuff() }
pluginManager.withPlugin("org.jetbrains.kotlin.multiplatform") { found = true; doStuff() }
pluginManager.withPlugin("org.jetbrains.kotlin.android") { found = true; doStuff() }
afterEvaluate {
check(found) {
"BCV requires the Kotlin Gradle Plugin to be applied"
}
}
// Wildly untested, probably crashes but you get the general idea
try {
val version = Class.forName("org.jetbrains.kotlin.gradle.plugin.KotlinPluginWrapperKt")
.getMethod("getKotlinPluginVersion")
.invoke(null, project)
when(version) {
"1.9.21" -> doStuff1921()
...
}
} catch (e: Exception) {
error("BCV requires the Kotlin Gradle Plugin to be in the classpath")
}
|
@martinbonnin This issue is about applying BCV in A workaround would have to use some sort of duck-typing, which is difficult in JVM... It would be nice if Kotlin/JS's |
Oh sorry I missed that 🤦 . Feel free to ignore my comment. FWIW, Gradle has plans for a way to add a plugin to all projects while being project isolation compatible. See gradle/gradle#22514. That might be a good solution long term. |
That being said, I'm curious now... Is the Of course this is quite different from the usual ways to apply KGP but I think it'd be the only "correct" way to proceed? |
When applying BCV-MU via the settings plugin, if any subproject is Kotlin/Multiplatform (and probably Android too) KGP is required as a buildscript dependency.
Without this, BCV-MU fails because the KGP classes it uses to fetch the dependencies are missing.
@Fleshgrinder explained more here: Kotlin/binary-compatibility-validator#88 (comment)
I have attempted to implement the proposed solution. Using KGP-api works well, but I have still encountered problems when using Shadow:
With
isEnableRelocation = true
, Gradle doesn't seem to pick up theKotlinTargetsContainer
extensionWith With
isEnableRelocation = false
and Kotlin/JVM subprojects there's some sort of problemI've also encountered a weird 'wasm' error with Shadowing and Kotlin Multiplatform subprojects
As there's a workaround, and the settings plugin is still experimental, this isn't critical to fix right now. I'm making this issue to collect any info in once place.
I'll commit the progress I've made so far, and the tests.
The text was updated successfully, but these errors were encountered: