Skip to content

Commit

Permalink
AND-81: extract common build-logic to convention plugins in buildSrc
Browse files Browse the repository at this point in the history
  • Loading branch information
sonulen committed Apr 27, 2024
1 parent c945e9c commit b664ae9
Show file tree
Hide file tree
Showing 13 changed files with 123 additions and 62 deletions.
46 changes: 1 addition & 45 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,49 +1,5 @@
import com.redmadrobot.build.dsl.*

plugins {
alias(libs.plugins.gradle.android) apply false
alias(stack.plugins.kotlin.android) apply false

alias(rmr.plugins.android.config)
alias(rmr.plugins.publish.config)
alias(rmr.plugins.detekt)
alias(stack.plugins.versions)
`maven-publish`
}

redmadrobot {
android.minSdk.set(14)

publishing {
signArtifacts.set(!isRunningOnCi)
pom {
setGitHubProject("RedMadRobot/redmadrobot-android-ktx")

licenses {
mit()
}

developers {
developer(id = "osipxd", name = "Osip Fatkullin", email = "[email protected]")
}
}
}
}

subprojects {
apply(plugin = "io.gitlab.arturbosch.detekt")
group = "com.redmadrobot.extensions"

kotlinCompile {
// Fix module-name conflicts with Android KTX
kotlinOptions.moduleName = "redmadrobot.${project.name}"
}

apply(plugin = "maven-publish")
publishing {
repositories {
if (isRunningOnCi) githubPackages("RedMadRobot/redmadrobot-android-ktx")
if (isReleaseVersion && credentialsExist("ossrh")) ossrh()
}
}
convention.detekt
}
13 changes: 9 additions & 4 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@ plugins {
`kotlin-dsl`
}

repositories {
mavenCentral()
}

tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
kotlinOptions.jvmTarget = JavaVersion.VERSION_11.toString()
}
Expand All @@ -14,3 +10,12 @@ java {
targetCompatibility = JavaVersion.VERSION_11
sourceCompatibility = JavaVersion.VERSION_11
}

dependencies {
implementation(rmr.infrastructure.publish)
implementation(rmr.infrastructure.android)
implementation(stack.gradle.android.cacheFixGradlePlugin)
implementation(stack.kotlin.gradlePlugin)
implementation(stack.detekt.gradlePlugin)
implementation(libs.android.gradlePlugin)
}
38 changes: 38 additions & 0 deletions buildSrc/settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
pluginManagement {
repositories {
gradlePluginPortal()
google()
mavenCentral()
}
}

@Suppress("UnstableApiUsage")
dependencyResolutionManagement {
repositories {
google {
content {
includeGroupByRegex("com\\.android.*")
includeGroupByRegex("com\\.google.*")
includeGroupByRegex("androidx.*")
}
}

mavenCentral()
gradlePluginPortal()
}

versionCatalogs {
val version = "2024.04.10"
create("rmr") {
from("com.redmadrobot.versions:versions-redmadrobot:$version")
}

create("stack") {
from("com.redmadrobot.versions:versions-stack:$version")
}

create("libs") {
from(files("../gradle/libs.versions.toml"))
}
}
}
20 changes: 20 additions & 0 deletions buildSrc/src/main/kotlin/convention.detekt.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import io.gitlab.arturbosch.detekt.Detekt
import io.gitlab.arturbosch.detekt.DetektCreateBaselineTask

plugins {
id("io.gitlab.arturbosch.detekt")
}

tasks.withType<Detekt>().configureEach {
jvmTarget = JavaVersion.VERSION_11.toString()
}
tasks.withType<DetektCreateBaselineTask>().configureEach {
jvmTarget = JavaVersion.VERSION_11.toString()
}

dependencies {
//noinspection UseTomlInstead
detektPlugins("io.gitlab.arturbosch.detekt:detekt-rules-libraries:1.23.6")
//noinspection UseTomlInstead
detektPlugins("io.gitlab.arturbosch.detekt:detekt-formatting:1.23.6")
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
plugins {
id("com.redmadrobot.android-library")
id("convention.publishing")
id("convention.detekt")
}

redmadrobot {
android.minSdk = 19
}
39 changes: 39 additions & 0 deletions buildSrc/src/main/kotlin/convention.publishing.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import com.redmadrobot.build.dsl.*

plugins {
id("com.redmadrobot.publish-config")
id("com.redmadrobot.publish")
}

group = "com.redmadrobot.extensions"

redmadrobot {
publishing {
signArtifacts.set(!isRunningOnCi)
pom {
setGitHubProject("RedMadRobot/redmadrobot-android-ktx")

licenses {
mit()
}

developers {
developer(id = "osipxd", name = "Osip Fatkullin", email = "[email protected]")
}
}
}
}

publishing {
repositories {
if (isRunningOnCi) githubPackages("RedMadRobot/redmadrobot-android-ktx")
if (isReleaseVersion && credentialsExist("ossrh")) ossrh()
}
}

kotlinCompile {
kotlinOptions {
moduleName = "redmadrobot.${project.name}"
}
}

3 changes: 1 addition & 2 deletions core-ktx/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
plugins {
id("com.redmadrobot.android-library")
id("com.redmadrobot.publish")
convention.library.android
}

version = "1.6.0-2"
Expand Down
3 changes: 1 addition & 2 deletions fragment-args-ktx/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
plugins {
id("com.redmadrobot.android-library")
id("com.redmadrobot.publish")
convention.library.android
}

version = "1.3.6-1"
Expand Down
3 changes: 1 addition & 2 deletions fragment-ktx/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
plugins {
id("com.redmadrobot.android-library")
id("com.redmadrobot.publish")
convention.library.android
}

version = "1.3.6-0"
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
3 changes: 1 addition & 2 deletions lifecycle-livedata-ktx/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
plugins {
id("com.redmadrobot.android-library")
id("com.redmadrobot.publish")
convention.library.android
}

version = "2.3.1-0"
Expand Down
3 changes: 1 addition & 2 deletions resources-ktx/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
plugins {
id("com.redmadrobot.android-library")
id("com.redmadrobot.publish")
convention.library.android
id("kotlin-parcelize")
}

Expand Down
3 changes: 1 addition & 2 deletions viewbinding-ktx/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
plugins {
id("com.redmadrobot.android-library")
id("com.redmadrobot.publish")
convention.library.android
}

version = "4.2.1-0"
Expand Down

0 comments on commit b664ae9

Please sign in to comment.