https://kotlinlang.org logo
#ksp
Title
# ksp
g

Gaurav Dhingra

03/07/2023, 10:26 AM
I've a multi-module project using KSP version 1.8.10-1.0.9 and it would be helpful if someone can help me with disabling the task of code-generation in the tests sub-directory of the build directory. This is roughly the structure of the project:
Copy code
myProject
    - api
    - engine
    - methods
        - build.gradle.kts
dependencies { implementation(project(":engine")) implementation(project(":methodsProcessor")) testImplementation(kotlin("test")) testImplementation(testFixtures(project(":engine"))) testImplementation("org.junit.jupiterjunit jupiter params5.8.2") ksp(project(":methodsProcessor")) }
Copy code
- build
            - generated
                - ksp
                    - main
                        - kotlin
                            - methods
                                - PublicMethods.kt

                    - test   ##  I don't want this directory to be created at all
                        - kotlin
                            - methods
                                - PublicMethods.kt
    - methodsProcessor
        - build.gradle.kts (contents below)
dependencies { implementation(libs.ksp.api) }
Copy code
- src.main.kotlin.processor.MethodsProcessor
            ## this file has a SymbolProcessor which creates a new file (PublicMethods.kt) in
            ## `methods/build/generated/ksp/main/kotlin/methods` &
            ## `methods/build/generated/ksp/test/kotlin/methods` (THIS I would like not to be created)
    - build.gradle.kts
    - settings.gradle.kts
rootProject.name = "myProject" include("engine") include("methods") include("api") include("methodsProcessor") val kotlinVersion: String by settings val kspVersion: String by settings pluginManagement { plugins { // For some reason the global variables are not accessible here val kotlinVersion: String by settings val kspVersion: String by settings kotlin("jvm") version kotlinVersion kotlin("plugin.jpa") version kotlinVersion kotlin("plugin.spring") version kotlinVersion id("com.google.devtools.ksp") version kspVersion } } dependencyResolutionManagement { repositories { mavenCentral() } versionCatalogs { create("libs") { library("ksp-api", "com.google.devtools.kspsymbol processing api$kspVersion") } } }
Copy code
```

When I run `./gradlew build` for my project, the output on the terminal looks like:
```> Task :api:openApiGenerate
################################################################################
# Thanks for using OpenAPI Generator.                                          #
# Please consider donation to help us maintain this project :pray:                 #
# <https://opencollective.com/openapi_generator/donate>                          #
################################################################################
Successfully generated code to /Users/gxyd/projects/solver-engine/api/build/generated-src/openapi

> Task :methods:kspKotlin
w: [ksp] hello world

Daemon will be stopped at the end of the build after running out of JVM memory

> Task :methods:kspTestKotlin
w: [ksp] hello world
So, the second task that you see, i.e.
:methods:kspTestKotlin
is something I don't to it to run. I've already tried having the below configuration in `methods.build.gradle.kts`:
Copy code
ksp {
    tasks.named("kspTestKotlin") {
        enabled = false
    }
}
which raises the error saying, there is no task named "kspTestKotlin", while building my project.
20 Views