When trying to write a compiler plugin inside an a...
# compiler
b
When trying to write a compiler plugin inside an android project, I'm getting
Caused by: org.gradle.api.artifacts.UnknownConfigurationException: Configuration with name 'kotlinCompilerPluginClasspath' not found.
error when trying to add it as dependency. Using groovy for the configs and not kts. Is there any classpath I need to add?
Nvm 😅. Was trying to define the dependency in the wrong place before the kotlin plugin is initiated
s
Hey @brookmg Would you mind to share your gradle structure after fixing? Seems like I encounter the similar one. My case is
kotlinCompilerPluginClasspathDebug
b
Ok, so it was my mistake actually. I placed the dependency definition in the root build.gradle file before the kotlin plugin was initiated. Just had to move it to a module that had the kotlin jvm plugin at the top.
Copy code
plugins {
    id 'java-library'
    id 'org.jetbrains.kotlin.jvm'
    id 'org.jetbrains.kotlin.plugin.serialization' version '1.6.20'
    id 'com.google.devtools.ksp' version "$ksp_version"
}

java {
    sourceCompatibility = JavaVersion.VERSION_17
    targetCompatibility = JavaVersion.VERSION_17

    sourceSets["main"].java {
        srcDir('build/generated/ksp/main/kotlin')
    }

    ksp {
        arg("appVersion", rootProject.ext.appVersionCode.toString())
    }
}

// set freeCompilerArgs
compileKotlin {
    kotlinOptions {
        freeCompilerArgs = ["-P", "plugin:app.example.localization_ksp.kcp.TKeyVerifier:enable=false"]
    }
}

dependencies {
    api project(path: ':libs:core:redux')
    implementation project(path: ':libs:analytics:core')
    ksp project(path: ':analytics-ksp')

    implementation "io.arrow-kt:arrow-fx-coroutines:0.13.2"
    implementation "org.jetbrains.kotlinx:kotlinx-serialization-json:1.3.3"

    def koin_version = "3.2.0-beta-1"
    implementation "io.insert-koin:koin-core-jvm:$koin_version"

    implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4'
    kotlinCompilerPluginClasspath(project(":localization-ksp"))
}
This is how it looked at the end. Notice the plugin defs at the top. That was the missing thing