# Switch from groovy to kotlin

**URL:** <https://discuss.gradle.org/t/switch-from-groovy-to-kotlin/43277>\
**Category:** Help/Discuss\
**Created:** [July 7, 2022, 6:43am UTC](https://discuss.gradle.org/t/switch-from-groovy-to-kotlin/43277 "2022-07-07T06:43:45Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![livk-cloud](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/livk-cloud/32/10362_2.png) [@livk-cloud](https://discuss.gradle.org/u/livk-cloud)\
**Post date:** [July 7, 2022, 6:43am UTC](https://discuss.gradle.org/t/switch-from-groovy-to-kotlin/43277/1 "2022-07-07T06:43:45Z")

</div>

> I try to switch from groovy to kotlin, I want to know how to switch from groovy to kotlin in buildSrc, such as the plugin “groovy-gradle-plugin”, what should the corresponding kotlin look like  
> I want to switch the plugin written in groovy to kotlin  
> can someone give me an answer

---

<div class="post-metadata">

**Author:** ![Vampire](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/vampire/32/9082_2.png) [@Vampire](https://discuss.gradle.org/u/Vampire)\
**Post date:** [July 7, 2022, 11:29pm UTC](https://discuss.gradle.org/t/switch-from-groovy-to-kotlin/43277/2 "2022-07-07T23:29:26Z")

</div>

You can use `java-gradle-plugin` and also apply the Kotlin JVM plugin with the embedded Kotlin version like `compileOnly(embeddedKotlin("jvm"))` and it should be comparable.  
If you also want to write precompiled script plugins in Kotlin you might want to use the `kotlin-dsl` plugin instead.  
Or if you just want normal Kotlin plugins, but also use the Kotlin DSL extensions, you might just want to use `compileOnly(gradleKotlinDsl())`.

The `kotlin-dsl` plugin applies `java-gradle-plugin` , `kotlin-dsl.base` , and `kotlin-dsl.precompiled-script-plugins` plugins  
`kotlin-dsl.base` plugin applies `embedded-kotlin` , adds `gradleKotlinDsl()` to the dependencies of `compileOnly` and `testImplementation` configurations, and configures the Kotlin DSL compiler plugins for example for proper SAM conversion for `Action` and similar.
