Skip to content

Commit

Permalink
feat(build): use versions catalog for convention plugins (#1)
Browse files Browse the repository at this point in the history
* feat(build): use versions catalog for Gradle plugins

---------

Authored-by: @piloudu
  • Loading branch information
piloudu authored Jul 28, 2023
1 parent 45ab2f4 commit 0ca20df
Show file tree
Hide file tree
Showing 19 changed files with 91 additions and 59 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import org.gradle.kotlin.dsl.withType

class NibelAndroidCommonPlugin : NibelConventionPlugin({
with(pluginManager) {
apply("org.jetbrains.kotlin.android")
apply(libs.plugins.kotlin.android.get().pluginId)
}

android<CommonExtension> {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import com.android.build.api.dsl.LibraryExtension
import com.turo.nibel.buildtools.NibelConventionPlugin
import com.turo.nibel.buildtools.android
import com.turo.nibel.buildtools.libs

class NibelAndroidLibraryPlugin : NibelConventionPlugin({
with(pluginManager) {
apply("com.android.library")
apply("nibel.android.common")
apply(libs.plugins.android.library.get().pluginId)
apply(libs.plugins.nibel.android.common.get().pluginId)
}

android<LibraryExtension> {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import com.turo.nibel.buildtools.NibelConventionPlugin
import com.turo.nibel.buildtools.libs
import org.gradle.api.tasks.compile.JavaCompile
import org.gradle.kotlin.dsl.withType
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

class NibelKotlinJvmLibraryPlugin : NibelConventionPlugin({
with(pluginManager) {
apply("org.jetbrains.kotlin.jvm")
apply(libs.plugins.kotlin.jvm.get().pluginId)
}

tasks.withType<KotlinCompile>().configureEach {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import com.turo.nibel.buildtools.NibelConventionPlugin
import com.turo.nibel.buildtools.libs
import com.turo.nibel.buildtools.mavenPublishing
import com.turo.nibel.buildtools.sourceSets
import com.vanniktech.maven.publish.SonatypeHost
import org.gradle.jvm.tasks.Jar

class NibelMavenPublishPlugin : NibelConventionPlugin({
with(pluginManager) {
apply("com.vanniktech.maven.publish")
apply(libs.plugins.vanniktech.maven.publish.get().pluginId)
}

mavenPublishing {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import com.android.build.api.dsl.ApplicationExtension
import com.turo.nibel.buildtools.NibelConventionPlugin
import com.turo.nibel.buildtools.android
import com.turo.nibel.buildtools.libs

class SampleAndroidApplicationPlugin : NibelConventionPlugin({
with(pluginManager) {
apply("com.android.application")
apply("nibel.android.common")
apply(libs.plugins.android.application.get().pluginId)
apply(libs.plugins.nibel.android.common.get().pluginId)
}

android<ApplicationExtension> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import org.gradle.kotlin.dsl.dependencies

class SampleAndroidComposePlugin : NibelConventionPlugin({
with(pluginManager) {
apply("nibel.android.compose")
apply(libs.plugins.nibel.android.compose.get().pluginId)
}

dependencies {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import com.turo.nibel.buildtools.CommonExtension
import com.turo.nibel.buildtools.NibelConventionPlugin
import com.turo.nibel.buildtools.android
import com.turo.nibel.buildtools.libs

class SampleAndroidLibraryPlugin : NibelConventionPlugin({
with(pluginManager) {
apply("com.android.library")
apply("nibel.android.common")
apply(libs.plugins.android.library.get().pluginId)
apply(libs.plugins.nibel.android.common.get().pluginId)
}

android<CommonExtension> {
Expand Down
17 changes: 10 additions & 7 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
id("com.android.application") version libs.versions.androidGradlePlugin apply false
id("com.android.library") version libs.versions.androidGradlePlugin apply false
id("org.jetbrains.kotlin.android") version libs.versions.kotlin apply false
id("com.google.devtools.ksp") version libs.versions.ksp apply false
id("com.google.dagger.hilt.android") version libs.versions.dagger apply false
id("org.jetbrains.dokka") version libs.versions.dokka apply false
id("com.vanniktech.maven.publish") version libs.versions.mavenPublish apply false
alias(libs.plugins.android.application) apply false
alias(libs.plugins.android.library) apply false
alias(libs.plugins.kotlin.android) apply false
alias(libs.plugins.ksp) apply false
alias(libs.plugins.dagger.hilt.android) apply false
alias(libs.plugins.dokka) apply false
alias(libs.plugins.vanniktech.maven.publish) apply false
alias(libs.plugins.kotlin.parcelize) apply false
alias(libs.plugins.kotlin.kapt) apply false
alias(libs.plugins.kotlin.jvm) apply false
}
24 changes: 24 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ dagger = "2.46.1"
lifecycle = "2.6.1"
dokka = "1.8.20"
mavenPublish = "0.25.3"
nibelConventionPlugin = "ignored"

[libraries]
# ===== Nibel =====
Expand Down Expand Up @@ -54,3 +55,26 @@ gradlePlugin-android-api = { module = "com.android.tools.build:gradle-api", vers
gradlePlugin-kotlin = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlin" }
gradlePlugin-ksp = { module = "com.google.devtools.ksp:com.google.devtools.ksp.gradle.plugin", version.ref = "ksp" }
gradlePlugin-mavenPublish = { module = "com.vanniktech:gradle-maven-publish-plugin", version.ref = "mavenPublish" }

[plugins]
android-application = { id = "com.android.application", version.ref = "androidGradlePlugin" }
android-library = { id = "com.android.library", version.ref = "androidGradlePlugin" }
kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
ksp = { id = "com.google.devtools.ksp", version.ref = "ksp" }
dagger-hilt-android = { id = "com.google.dagger.hilt.android", version.ref = "dagger" }
dokka = { id = "org.jetbrains.dokka", version.ref = "dokka" }
vanniktech-maven-publish = { id = "com.vanniktech.maven.publish", version.ref = "mavenPublish" }
kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
kotlin-kapt = { id = "org.jetbrains.kotlin.kapt", version.ref = "kotlin" }
kotlin-parcelize = { id = "org.jetbrains.kotlin.plugin.parcelize", version.ref = "kotlin" }

# ===== Convention Plugins =====
nibel-metadata = { id = "nibel.metadata", version.ref = "nibelConventionPlugin" }
nibel-android-library = { id = "nibel.android.library", version.ref = "nibelConventionPlugin" }
nibel-android-compose = { id = "nibel.android.compose", version.ref = "nibelConventionPlugin" }
nibel-android-common = { id = "nibel.android.common", version.ref = "nibelConventionPlugin" }
nibel-kotlin-jvm-library = { id = "nibel.kotlin.jvm.library", version.ref = "nibelConventionPlugin" }
nibel-maven-publish = { id = "nibel.maven.publish", version.ref = "nibelConventionPlugin" }
sample-android-application = { id = "sample.android.application", version.ref = "nibelConventionPlugin" }
sample-android-library = { id = "sample.android.library", version.ref = "nibelConventionPlugin" }
sample-android-compose = { id = "sample.android.compose", version.ref = "nibelConventionPlugin" }
6 changes: 3 additions & 3 deletions nibel-annotations/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
plugins {
id("nibel.kotlin.jvm.library")
id("nibel.maven.publish")
id("org.jetbrains.dokka")
alias(libs.plugins.nibel.kotlin.jvm.library)
alias(libs.plugins.nibel.maven.publish)
alias(libs.plugins.dokka)
}

dependencies {
Expand Down
10 changes: 5 additions & 5 deletions nibel-compiler/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
plugins {
id("nibel.metadata")
id("nibel.maven.publish")
kotlin("jvm")
id("com.google.devtools.ksp")
id("org.jetbrains.dokka")
alias(libs.plugins.nibel.metadata)
alias(libs.plugins.nibel.maven.publish)
alias(libs.plugins.kotlin.jvm)
alias(libs.plugins.ksp)
alias(libs.plugins.dokka)
}

dependencies {
Expand Down
10 changes: 5 additions & 5 deletions nibel-runtime/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
plugins {
id("nibel.android.library")
id("nibel.android.compose")
id("nibel.maven.publish")
id("kotlin-parcelize")
id("org.jetbrains.dokka")
alias(libs.plugins.nibel.android.library)
alias(libs.plugins.nibel.android.compose)
alias(libs.plugins.nibel.maven.publish)
alias(libs.plugins.kotlin.parcelize)
alias(libs.plugins.dokka)
}

android {
Expand Down
4 changes: 2 additions & 2 deletions nibel-stub/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
plugins {
id("nibel.kotlin.jvm.library")
id("nibel.maven.publish")
alias(libs.plugins.nibel.kotlin.jvm.library)
alias(libs.plugins.nibel.maven.publish)
}
10 changes: 5 additions & 5 deletions sample/app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
plugins {
id("sample.android.application")
id("sample.android.compose")
id("kotlin-parcelize")
kotlin("kapt")
id("com.google.dagger.hilt.android")
alias(libs.plugins.sample.android.application)
alias(libs.plugins.sample.android.compose)
alias(libs.plugins.kotlin.parcelize)
alias(libs.plugins.kotlin.kapt)
alias(libs.plugins.dagger.hilt.android)
}

android {
Expand Down
4 changes: 2 additions & 2 deletions sample/common/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
plugins {
id("sample.android.library")
id("sample.android.compose")
alias(libs.plugins.sample.android.library)
alias(libs.plugins.sample.android.compose)
}

android {
Expand Down
12 changes: 6 additions & 6 deletions sample/feature-A/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
plugins {
id("sample.android.library")
id("sample.android.compose")
id("kotlin-parcelize")
id("com.google.devtools.ksp")
kotlin("kapt")
id("com.google.dagger.hilt.android")
alias(libs.plugins.sample.android.library)
alias(libs.plugins.sample.android.compose)
alias(libs.plugins.kotlin.parcelize)
alias(libs.plugins.ksp)
alias(libs.plugins.kotlin.kapt)
alias(libs.plugins.dagger.hilt.android)
}

android {
Expand Down
12 changes: 6 additions & 6 deletions sample/feature-B/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
plugins {
id("sample.android.library")
id("sample.android.compose")
id("kotlin-parcelize")
id("com.google.devtools.ksp")
kotlin("kapt")
id("com.google.dagger.hilt.android")
alias(libs.plugins.sample.android.library)
alias(libs.plugins.sample.android.compose)
alias(libs.plugins.kotlin.parcelize)
alias(libs.plugins.ksp)
alias(libs.plugins.kotlin.kapt)
alias(libs.plugins.dagger.hilt.android)
}

android {
Expand Down
12 changes: 6 additions & 6 deletions sample/feature-C/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
plugins {
id("sample.android.library")
id("sample.android.compose")
id("kotlin-parcelize")
id("com.google.devtools.ksp")
kotlin("kapt")
id("com.google.dagger.hilt.android")
alias(libs.plugins.sample.android.library)
alias(libs.plugins.sample.android.compose)
alias(libs.plugins.kotlin.parcelize)
alias(libs.plugins.ksp)
alias(libs.plugins.kotlin.kapt)
alias(libs.plugins.dagger.hilt.android)
}

android {
Expand Down
4 changes: 2 additions & 2 deletions sample/navigation/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
plugins {
id("sample.android.library")
id("kotlin-parcelize")
alias(libs.plugins.sample.android.library)
alias(libs.plugins.kotlin.parcelize)
}

android {
Expand Down

0 comments on commit 0ca20df

Please sign in to comment.