Skip to content

Commit

Permalink
Add option to set or disable the Ktorfit compiler plugin #764 (#770)
Browse files Browse the repository at this point in the history
  • Loading branch information
Foso authored Feb 3, 2025
1 parent f500b60 commit cb314d8
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
13 changes: 13 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,19 @@ and this project orients towards [Semantic Versioning](http://semver.org/spec/v2
Note: This project needs KSP to work and every new Ktorfit with an update of the KSP version is technically a breaking change.
But there is no intent to bump the Ktorfit major version for every KSP update.

# Unreleased
- Provide option to not use the compiler plugin #764
You can now set the Kotlin version for the compiler plugin.
By default, it will use the Kotlin version of the project. You can set it to "-" to disable the plugin.

```kotlin
ktorfit{
kotlinVersion = "-"
// or
kotlinVersion = "x.x.x"
}
```

# [2.2.0]()
* Supported Kotlin version: 2.0.0; 2.0.10; 2.0.20, 2.1.0-Beta1; 2.0.21-RC, 2.0.21, 2.1.0-RC, 2.1.0-RC2, 2.1.0, 2.1.10
* Supported KSP version: 1.0.27, 1.0.28, 1.0.29
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,12 @@ internal class KtorfitCompilerSubPlugin : KotlinCompilerPluginSupportPlugin {
override fun getCompilerPluginId(): String = COMPILER_PLUGIN_ID

override fun isApplicable(kotlinCompilation: KotlinCompilation<*>): Boolean {
return true
val kotlinVersion =
myproject.ktorfitExtension(
GRADLE_TASKNAME
).kotlinVersion.get()

return kotlinVersion != "-"
}

@OptIn(ExperimentalKotlinGradlePluginApi::class, ExperimentalBuildToolsApi::class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package de.jensklingenberg.ktorfit.gradle
import org.gradle.api.Project
import org.gradle.api.model.ObjectFactory
import org.gradle.api.provider.Property
import org.jetbrains.kotlin.buildtools.api.ExperimentalBuildToolsApi
import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi
import org.jetbrains.kotlin.gradle.dsl.kotlinExtension
import javax.inject.Inject
Expand Down Expand Up @@ -32,10 +33,11 @@ open class KtorfitPluginExtension
* Specify the Kotlin version of the compiler plugin.
*
* Default: your current Kotlin version
* Set value to "-" to disable the compiler plugin
*/
open val kotlinVersion: Property<String> = objectFactory.property(String::class.java)

@OptIn(ExperimentalKotlinGradlePluginApi::class)
@OptIn(ExperimentalKotlinGradlePluginApi::class, ExperimentalBuildToolsApi::class)
internal fun setupConvention(project: Project) {
generateQualifiedTypeName.convention(false)
errorCheckingMode.convention(ErrorCheckingMode.ERROR)
Expand Down

0 comments on commit cb314d8

Please sign in to comment.