Skip to content

Commit

Permalink
Migrate to Gradle's new plugin declaration solution
Browse files Browse the repository at this point in the history
  • Loading branch information
mars885 committed Aug 15, 2024
1 parent 163f5ca commit c7d1a42
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 49 deletions.
26 changes: 9 additions & 17 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -21,26 +21,19 @@ import org.jetbrains.kotlin.gradle.plugin.KaptExtension
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
androidApplication() apply false
androidLibrary() apply false
kotlinAndroid() apply false
protobuf() apply false

jetpackCompose() version versions.kotlin apply false
ksp() version versions.kspPlugin apply false
daggerHilt() version versions.daggerHilt apply false
gradleVersions()
detekt()
ktlint()
}
kotlinxSerialization() version versions.kotlin apply false

buildscript {
repositories {
mavenCentral()
google()
}

dependencies {
classpath(deps.plugins.androidGradle)
classpath(deps.plugins.kotlinGradle)
classpath(deps.plugins.protobuf)
classpath(deps.plugins.gradleVersions)
}
gradleVersions() version versions.gradleVersionsPlugin apply true
detekt() version versions.detektPlugin apply true
ktlint() version versions.ktlintPlugin apply true
}

detekt {
Expand Down Expand Up @@ -96,7 +89,6 @@ allprojects {
}

subprojects {

plugins.withId(PLUGIN_KOTLIN) {
extensions.findByType<KotlinProjectExtension>()?.run {
jvmToolchain(appConfig.jvmToolchainVersion)
Expand Down
13 changes: 1 addition & 12 deletions buildSrc/src/main/java/Dependencies.kt
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ object appConfig {
object versions {

const val kotlin = "2.0.10" // also in buildSrc build.gradle.kts file
const val gradleVersionsPlugin = "0.51.0"
const val kspPlugin = "2.0.10-1.0.24"
const val daggerHilt = "2.52"
const val gradleVersionsPlugin = "0.51.0"
const val detektPlugin = "1.23.6"
const val ktlintPlugin = "12.1.1"
const val ktlint = "1.3.1"
Expand All @@ -48,17 +48,6 @@ object versions {

object deps {

object plugins {

private const val androidPluginVersion = "8.3.1" // also in buildSrc build.gradle.kts file
private const val protobufPluginVersion = "0.9.4" // also in buildSrc build.gradle.kts file

const val androidGradle = "com.android.tools.build:gradle:${androidPluginVersion}"
const val kotlinGradle = "org.jetbrains.kotlin:kotlin-gradle-plugin:${versions.kotlin}"
const val protobuf = "com.google.protobuf:protobuf-gradle-plugin:$protobufPluginVersion"
const val gradleVersions = "com.github.ben-manes:gradle-versions-plugin:${versions.gradleVersionsPlugin}"
}

object local {

const val core = ":core"
Expand Down
39 changes: 19 additions & 20 deletions buildSrc/src/main/java/Plugins.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,33 +14,24 @@
* limitations under the License.
*/

import org.gradle.kotlin.dsl.version
import org.gradle.plugin.use.PluginDependenciesSpec
import org.gradle.plugin.use.PluginDependencySpec

const val PLUGIN_GAMEDGE_ANDROID = "com.paulrybitskyi.gamedge.android"
const val PLUGIN_GAMEDGE_PROTOBUF = "com.paulrybitskyi.gamedge.protobuf"
const val PLUGIN_ANDROID_APPLICATION = "com.android.application"
const val PLUGIN_ANDROID_LIBRARY = "com.android.library"
const val PLUGIN_KOTLIN = "kotlin"
const val PLUGIN_KOTLIN_ANDROID = "kotlin-android"
const val PLUGIN_PROTOBUF = "com.google.protobuf"
const val PLUGIN_JETPACK_COMPOSE = "org.jetbrains.kotlin.plugin.compose"
const val PLUGIN_KOTLIN_KAPT = "kotlin-kapt"
const val PLUGIN_KSP = "com.google.devtools.ksp"
const val PLUGIN_DAGGER_HILT = "com.google.dagger.hilt.android"
const val PLUGIN_PROTOBUF = "com.google.protobuf"
const val PLUGIN_KOTLINX_SERIALIZATION = "org.jetbrains.kotlin.plugin.serialization"
const val PLUGIN_GRADLE_VERSIONS = "com.github.ben-manes.versions"
const val PLUGIN_DETEKT = "io.gitlab.arturbosch.detekt"
const val PLUGIN_KTLINT = "org.jlleitschuh.gradle.ktlint"

fun PluginDependenciesSpec.gamedgeAndroid(): PluginDependencySpec {
return id(PLUGIN_GAMEDGE_ANDROID)
}

fun PluginDependenciesSpec.gamedgeProtobuf(): PluginDependencySpec {
return id(PLUGIN_GAMEDGE_PROTOBUF)
}
const val PLUGIN_GAMEDGE_ANDROID = "com.paulrybitskyi.gamedge.android"
const val PLUGIN_GAMEDGE_PROTOBUF = "com.paulrybitskyi.gamedge.protobuf"

fun PluginDependenciesSpec.androidApplication(): PluginDependencySpec {
return id(PLUGIN_ANDROID_APPLICATION)
Expand All @@ -58,6 +49,10 @@ fun PluginDependenciesSpec.kotlinAndroid(): PluginDependencySpec {
return id(PLUGIN_KOTLIN_ANDROID)
}

fun PluginDependenciesSpec.protobuf(): PluginDependencySpec {
return id(PLUGIN_PROTOBUF)
}

fun PluginDependenciesSpec.jetpackCompose(): PluginDependencySpec {
return id(PLUGIN_JETPACK_COMPOSE)
}
Expand All @@ -74,22 +69,26 @@ fun PluginDependenciesSpec.daggerHilt(): PluginDependencySpec {
return id(PLUGIN_DAGGER_HILT)
}

fun PluginDependenciesSpec.protobuf(): PluginDependencySpec {
return id(PLUGIN_PROTOBUF)
}

fun PluginDependenciesSpec.kotlinxSerialization(): PluginDependencySpec {
return (id(PLUGIN_KOTLINX_SERIALIZATION) version versions.kotlin)
return id(PLUGIN_KOTLINX_SERIALIZATION)
}

fun PluginDependenciesSpec.gradleVersions(): PluginDependencySpec {
return (id(PLUGIN_GRADLE_VERSIONS) version versions.gradleVersionsPlugin)
return id(PLUGIN_GRADLE_VERSIONS)
}

fun PluginDependenciesSpec.detekt(): PluginDependencySpec {
return (id(PLUGIN_DETEKT) version versions.detektPlugin)
return id(PLUGIN_DETEKT)
}

fun PluginDependenciesSpec.ktlint(): PluginDependencySpec {
return (id(PLUGIN_KTLINT) version versions.ktlintPlugin)
return id(PLUGIN_KTLINT)
}

fun PluginDependenciesSpec.gamedgeAndroid(): PluginDependencySpec {
return id(PLUGIN_GAMEDGE_ANDROID)
}

fun PluginDependenciesSpec.gamedgeProtobuf(): PluginDependencySpec {
return id(PLUGIN_GAMEDGE_PROTOBUF)
}

0 comments on commit c7d1a42

Please sign in to comment.