Matheus Finatti
01/20/2023, 10:57 AMbuild-logic
module with a bunch of convention plugins
In build.gradle.kts
I tried adding a gradle plugin like such:
plugins {
`kotlin-dsl`
`kotlin-dsl-precompiled-script-plugins`
}
group = "buildlogic"
repositories {
mavenCentral()
google()
maven ("<https://s01.oss.sonatype.org/content/repositories/releases/>")
}
java {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
dependencies {
implementation(libs.gradlePlugin.android)
implementation(libs.gradlePlugin.kotlin)
implementation(libs.detekt)
implementation(libs.kmm.spm) // This one is throwing an exception
}
My version catalog looks like this:
[versions]
detekt = "1.22.0"
kmm-spm = "2.1.1"
[libraries]
detekt = { module = "io.gitlab.arturbosch.detekt:detekt-gradle-plugin", version.ref = "detekt" }
kmm-spm = { group = "io.github.luca992.multiplatform-swiftpackage", name = "io.github.luca992.multiplatform-swiftpackage.gradle.plugin", version.ref = "kmm-spm" }
Detekt works fine, but kmm-spm
does not.
I get an exception when syncing:
* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':build-logic:generateExternalPluginSpecBuilders'.
[...]
Caused by: java.lang.NullPointerException: implementationClass must not be null
at org.gradle.kotlin.dsl.codegen.PluginIdExtensionsKt$pluginEntriesFrom$1$2.invoke(PluginIdExtensions.kt:105)
at org.gradle.kotlin.dsl.codegen.PluginIdExtensionsKt$pluginEntriesFrom$1$2.invoke(PluginIdExtensions.kt)
Could this be an issue with Gradle, or with the plugin I’m trying to import?
plugin in question: https://github.com/luca992/multiplatform-swiftpackage
Thanks in advance!Adam S
01/20/2023, 11:04 AMkmm-spm = { group = "io.github.luca992.multiplatform-swiftpackage", name = "io.github.luca992.multiplatform-swiftpackage.gradle.plugin", version.ref = "kmm-spm"
this looks like a mistake, I guess this Maven coordinates of the the Gradle plugin marker, not the actual plugin implementationMatheus Finatti
01/20/2023, 11:05 AM.gradle/caches
and all the contents are thereAdam S
01/20/2023, 11:06 AMAdam S
01/20/2023, 11:06 AMMatheus Finatti
01/20/2023, 11:07 AMmaven ("<https://s01.oss.sonatype.org/content/repositories/releases/>")
Adam S
01/20/2023, 11:09 AMrepositories {
mavenCentral()
google()
// maven("<https://s01.oss.sonatype.org/content/repositories/releases/>")
}
Adam S
01/20/2023, 11:13 AMafterEvaluate {}
which could cause problems, and it requires that the Kotlin Multiplatform plugin is applied rather than reacting to it.
What are the contents of your convention plugin where you’re applying the plugin? What’s the full stacktrace? Are there any com.chromaticnoise
lines in there?Matheus Finatti
01/20/2023, 11:16 AMmport buildlogic.Namespace
import buildlogic.Versions
import org.jetbrains.kotlin.gradle.plugin.mpp.apple.XCFramework
plugins {
id("kotlin-multiplatform")
id("com.android.library")
}
group = "mp"
kotlin {
android()
val frameworkName = name
val xcf = XCFramework(frameworkName)
listOf(
iosArm64(),
iosSimulatorArm64(),
).forEach { target ->
target.binaries.framework {
baseName = frameworkName
xcf.add(this)
}
}
sourceSets {
val commonMain by getting
val commonTest by getting {
dependencies {
implementation(kotlin("test"))
}
}
val androidMain by getting
val androidTest by getting
val iosArm64Main by getting
val iosSimulatorArm64Main by getting
val iosMain by creating {
dependsOn(commonMain)
iosArm64Main.dependsOn(this)
iosSimulatorArm64Main.dependsOn(this)
}
val iosArm64Test by getting
val iosSimulatorArm64Test by getting
val iosTest by creating {
dependsOn(commonTest)
iosArm64Test.dependsOn(this)
iosSimulatorArm64Test.dependsOn(this)
}
}
}
android {
namespace = "${Namespace.shared}.core"
compileSdk = Versions.compileSdk
defaultConfig {
minSdk = Versions.minSdk
}
}
This is the convention plugin, I haven’t added multiplatform-swiftpackage
yet, because it fails beforeVampire
01/20/2023, 11:16 AMio.github.luca992.multiplatform-swiftpackage
plugin is broken.Vampire
01/20/2023, 11:17 AMMETA-INF\gradle-plugins\com.chromaticnoise.multiplatform-swiftpackage.properties
you find a property implementationClass
but not a property implementation-class
which should be there.Matheus Finatti
01/20/2023, 11:19 AMimplementation-class
would fix the issue?Matheus Finatti
01/20/2023, 11:20 AMplugins{}
block in a regular build.gradle.kts
?Vampire
01/20/2023, 11:21 AMVampire
01/20/2023, 11:21 AMkotlin-dsl
already applies kotlin-dsl-precompiled-script-plugins
internally, there is no need to apply it explicitly.Adam S
01/20/2023, 11:21 AMorg.gradle.kotlin.dsl.codegen.PluginIdExtensionsKt
. So given that the plugin is released at all, yeah, I think it should work in normal plugins {}
blocks.Matheus Finatti
01/20/2023, 11:22 AMAdam S
01/20/2023, 11:23 AMAdam S
01/20/2023, 11:25 AMsrc/main/resources/META-INF/gradle-plugins/com.chromaticnoise.multiplatform-swiftpackage.properties
2. change the publishing coordinates of the plugin to be different to the plugin marker ID
then the gradlePlugin {}
config will make the plugin ID work automatically https://github.com/ge-org/multiplatform-swiftpackage/blob/8d7c25ecc19841d4af515db885ae3426f7f32274/build.gradle.kts#L52-L59Matheus Finatti
01/20/2023, 11:27 AM