# Is it possible to make the usage of KSP easier?

**URL:** <https://discuss.kotlinlang.org/t/is-it-possible-to-make-the-usage-of-ksp-easier/25258>\
**Category:** Libraries\
**Created:** [July 21, 2022, 5:08pm UTC](https://discuss.kotlinlang.org/t/is-it-possible-to-make-the-usage-of-ksp-easier/25258 "2022-07-21T17:08:14Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![babyfish-ct](https://avatars.discourse-cdn.com/v4/letter/b/ec9cab/32.png) [@babyfish-ct](https://discuss.kotlinlang.org/u/babyfish-ct)\
**Post date:** [July 21, 2022, 5:08pm UTC](https://discuss.kotlinlang.org/t/is-it-possible-to-make-the-usage-of-ksp-easier/25258/1 "2022-07-21T17:08:14Z")

</div>

Now, I’m adding kotlin-api to my framework.

The existing java-api uses annotation processor, the user gradle code looks like this

```auto
annotationProcessor(project("org.babyfish.jimmer:jimmer-apt:0.0.35"))

```

it’s very simple, isn’t it?

However, the kotlin-api should use [KSP](https://kotlinlang.org/docs/ksp-overview.html), the user gradle code looks like this

```auto
plugins {
    id("com.google.devtools.ksp") version "1.6.21-1.0.5" // 1
}
dependencies {
    ksp(project("org.babyfish.jimmer:jimmer-ksp:0.0.35")) //2
}
kotlin {
    sourceSets.main {
        kotlin.srcDir("build/generated/ksp/main/kotlin") //3
    }
}

```

1. Add the ksp plugin
2. Use ksp plugin to generate source files
3. Add generated source files into compile path.

From the user’s point of view, using KSP is more troublesome than using annotation processor. Is there a way to make using KSP as easy as using annotation processor?

---

<div class="post-metadata">

**Author:** ![gildor](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/gildor/32/1891_2.png) [@gildor](https://discuss.kotlinlang.org/u/gildor)\
**Post date:** [July 28, 2022, 4:56am UTC](https://discuss.kotlinlang.org/t/is-it-possible-to-make-the-usage-of-ksp-easier/25258/2 "2022-07-28T04:56:47Z")

</div>

You cannot really avoid plugins part, because KSP is not a part of Kotlin Gradle Plugin, so it always at least 2 parts: ksp plugin and ksp dependency.

About sourceSets declaration it probably better to report a feature request to KSP issue tracker: [GitHub - google/ksp: Kotlin Symbol Processing API](https://github.com/google/ksp)

One more possible solution, is to replace your dependency with own Gradle Plugin, which will apply KSP plugin, dependency and add source sets, so it probably the easiest way for user to use it (though it may be less flexible in some cases)
