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

Reference to KotlinMultiplatformExtension causes build failure #883

Open
drewhamilton opened this issue Dec 16, 2024 · 2 comments
Open

Reference to KotlinMultiplatformExtension causes build failure #883

drewhamilton opened this issue Dec 16, 2024 · 2 comments

Comments

@drewhamilton
Copy link

When updating from 0.25.3, the new reference to KotlinMultiplatformExtension causes my build to fail. The version bump PR is drewhamilton/Poko#28; my failed build is here with the relevant portion of the stacktrace pasted below:

Caused by: java.lang.NoClassDefFoundError: org/jetbrains/kotlin/gradle/dsl/KotlinMultiplatformExtension
	at com.vanniktech.maven.publish.KotlinMultiplatform.configure$plugin(Platform.kt:293)
	at com.vanniktech.maven.publish.MavenPublishBaseExtension.configure(MavenPublishBaseExtension.kt:358)
	at com.vanniktech.maven.publish.MavenPublishBaseExtension.configureBasedOnAppliedPlugins(MavenPublishBaseExtension.kt:375)
	at com.vanniktech.maven.publish.MavenPublishBaseExtension.configureBasedOnAppliedPlugins$default(MavenPublishBaseExtension.kt:364)
	at com.vanniktech.maven.publish.MavenPublishPlugin.apply$lambda$2(MavenPublishPlugin.kt:32)
	at com.vanniktech.maven.publish.MavenPublishPlugin.apply$lambda$3(MavenPublishPlugin.kt:30)
	at org.gradle.internal.code.DefaultUserCodeApplicationContext$CurrentApplication$1.execute(DefaultUserCodeApplicationContext.java:124)
	at org.gradle.configuration.internal.DefaultListenerBuildOperationDecorator$BuildOperationEmittingAction$1.run(DefaultListenerBuildOperationDecorator.java:173)

Best I can tell, this seems to stem from the following combination of things:

  • gradle-maven-publish-plugin has a compileOnly dependency on kotlin-gradle-plugin.
  • Poko's build-support module has an implementation dependency on kotlin-gradle-plugin-api.
  • KotlinMultiplatformExtension is defined in kotlin-gradle-plugin, not kotlin-gradle-plugin-api.

The following attempted fixes don't help:

  1. Changing my build-support module's dependency to kotlin-gradle-plugin causes my main project to throw the following. I think that's because build-support must use Gradle's built-in Kotlin version instead of the version I define?

    The request for this plugin could not be satisfied because the plugin is already on the classpath with an unknown version, so compatibility cannot be checked.

  2. Adding a compileOnly dependency on kotlin-gradle-plugin to my build-support module doesn't change anything.

Any idea if this is fixable, or whether there's a way to work around this?

@gabrielittner
Copy link
Collaborator

Changing my build-support module's dependency to kotlin-gradle-plugin causes my main project to throw the following. I think that's because build-support must use Gradle's built-in Kotlin version instead of the version I define?

You can make this work by then removing the kotlin plugin definitions that have apply false from the root build file and in the modules that use the plugin apply them with id("org.jetbrains.kotlin.jvm")/id("org.jetbrains.kotlin.multiplatform"). That way Gradle will use the plugin that comes from the build-support classpath instead of trying to add them again.

I'll need to think whether we can do something on this side.

@drewhamilton
Copy link
Author

Huh, that feels weird but seems to work. I thought that would bring in the Gradle-bundled Kotlin version instead of the version I specified, but it doesn't.

Seems like this would fix the issue without requiring use of the non-API dependency.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants