hi! Sorry if this is a Groovy question but this is...
# gradle
t
hi! Sorry if this is a Groovy question but this is blocking me from migrating to Kotlin DSL. I'm trying to figure out how to call the
create()
function here from a Groovy gradle file. I've tried calling this way:
Copy code
cklib {
    create("sqlighter") {
        language "co.touchlab.cklib.gradle.CompileToBitcode.Language.OBJC"
    }
}
but I'm getting:
Copy code
org.gradle.api.GradleScriptException: A problem occurred evaluating project ':SharedCode'.
...
Caused by: groovy.lang.MissingMethodException: No signature of method: build_89t0gtdiazmlot5b0npjl25b8.cklib() is applicable for argument types: (build_89t0gtdiazmlot5b0npjl25b8$_run_closure3) values: [build_89t0gtdiazmlot5b0npjl25b8$_run_closure3@7e7932ea]
Possible solutions: mkdir(java.lang.Object), split(groovy.lang.Closure), wait(), file(java.lang.Object), wait(long), copy(groovy.lang.Closure)
Here's a working example of it being called from Kotlin DSL. What simple syntax error am I making? ๐Ÿ™‚
h
The problem isn't
create
but
cklib
. How do you apply the plugin?
t
Copy code
apply plugin: 'co.touchlab.cklib'
h
So not in the top
plugins
block? If you apply the plugin dynamically at runtime, the Kotlin compiler does not find the
cklib
extension at compile time.
t
thanks for reminding me. I tried changing it to this without success:
Copy code
plugins {
    id 'co.touchlab.cklib'
}
(I didn't have a
plugins
block before this)
h
Workaround:
Copy code
apply(plugin = "org.jetbrains.kotlin.jvm")

extensions.configure<org.jetbrains.kotlin.gradle.dsl.KotlinJvmProjectExtension>("kotlin") {
        explicitApi()
        sourceSets.all {
            languageSettings {
                progressiveMode = true
                optIn("kotlin.RequiresOptIn")
            }
        }
        target.compilations.all {
            kotlinOptions.allWarningsAsErrors = true
        }
    }
t
oh - I've got a
kotlin
block. Is it possible to work it into there or is that unrelated?
h
Coping the linked project should work ๐Ÿ˜„
Copy code
plugins {
    kotlin("multiplatform")
    id("co.touchlab.cklib")
}
t
(this is a KMM project)
h
Nope, this was only a sample to call the extension block
KMM project does not matter ๐Ÿ™‚
t
right, I didn't think so ๐Ÿ™‚
I tried this:
Copy code
plugins {
    kotlin("multiplatform")
    id("co.touchlab.cklib")
}
but hit
Copy code
build file '.../SharedCode/build.gradle': 2: only id(String) method calls allowed in plugins {} script block
h
kotlin()
is a Kotlin DSL only function. In Groovy, you have to use
id("org.jetbrains.kotlin.jvm")
I think
t
if I use that last line, I get a conflict with
Copy code
apply plugin: 'org.jetbrains.kotlin.multiplatform'
because
kotlin
gets redefined
if I change the start of my file to this:
Copy code
plugins {
    id("org.jetbrains.kotlin.multiplatform")
    id("co.touchlab.cklib")
}

// FIXME: cut?
//apply plugin: 'org.jetbrains.kotlin.multiplatform'
apply plugin: 'com.android.library'
apply plugin: 'com.squareup.sqldelight'
apply plugin: 'kotlinx-serialization'
I end up with the original build failure:
Copy code
No signature of method: build_89t0gtdiazmlot5b0npjl25b8.cklib() is applicable for argument types [...]
h
Wait, I thought you want to migrate from groovy to Kotlin DSL? But I dont know, why the groovy syntax does not work, sorry
t
I do but I want to get this building and working first ๐Ÿ™‚
in my migration from
j2objc
to KMM, I've already done a bunch of smaller migrations in the middle and it's really stretched this process out a lot more than I'd hoped. I almost always prefer to do one thing at a time to keep my sanity ๐Ÿ™‚
my Gradle file isn't incredibly-complicated so maybe I'll try that migration first then try using the
cklib
plugin
v
Do you have an MCVE where it fails?
t
I don't believe so but I'd have to undo some changes. I started migrating to Kotlin DSL and it hopefully shouldn't be a ton more work so I'll probably just continue on that path
๐Ÿ‘Œ 1