-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Clean up Kotlin's compiler flags (#239)
- Loading branch information
Showing
13 changed files
with
102 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
buildSrc/src/main/java/com/paulrybitskyi/gamedge/plugins/GamedgeKotlinCoroutinesPlugin.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package com.paulrybitskyi.gamedge.plugins | ||
|
||
import com.paulrybitskyi.gamedge.extensions.libs | ||
import org.gradle.api.Plugin | ||
import org.gradle.api.Project | ||
import org.gradle.kotlin.dsl.withType | ||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile | ||
|
||
class GamedgeKotlinCoroutinesPlugin : Plugin<Project> { | ||
|
||
override fun apply(project: Project) = with(project) { | ||
addDependencies() | ||
configureTasks() | ||
} | ||
|
||
private fun Project.addDependencies(): Unit = with(dependencies) { | ||
add("implementation", libs.coroutines.get()) | ||
} | ||
|
||
private fun Project.configureTasks() { | ||
tasks.withType<KotlinCompile>().all { | ||
compilerOptions { | ||
freeCompilerArgs.add("-opt-in=kotlinx.coroutines.ExperimentalCoroutinesApi") | ||
} | ||
} | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
buildSrc/src/main/java/com/paulrybitskyi/gamedge/plugins/GamedgeKotlinKaptPlugin.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package com.paulrybitskyi.gamedge.plugins | ||
|
||
import com.paulrybitskyi.gamedge.extensions.libs | ||
import org.gradle.api.Plugin | ||
import org.gradle.api.Project | ||
import org.gradle.kotlin.dsl.configure | ||
import org.gradle.kotlin.dsl.withType | ||
import org.jetbrains.kotlin.gradle.plugin.KaptExtension | ||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile | ||
|
||
class GamedgeKotlinKaptPlugin : Plugin<Project> { | ||
|
||
override fun apply(project: Project) = with(project) { | ||
setupPlugins() | ||
configurePlugin() | ||
configureTasks() | ||
} | ||
|
||
private fun Project.setupPlugins(): Unit = with(plugins) { | ||
apply(libs.plugins.kotlinKapt.get().pluginId) | ||
} | ||
|
||
private fun Project.configurePlugin() { | ||
configure<KaptExtension> { | ||
correctErrorTypes = true | ||
} | ||
} | ||
|
||
private fun Project.configureTasks() { | ||
tasks.withType<KotlinCompile>().all { | ||
compilerOptions { | ||
// w: Kapt currently doesn't support language version 2.0+. Falling back to 1.9. | ||
freeCompilerArgs.add("-Xsuppress-version-warnings") | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters