Skip to content

Commit 2b83a3b

Browse files
authored
chore: migration gradle scripts to kotlin dsl from groovy (#339)
* migrated sample app build to kotlin * pluto - groovy to kotlin * plugins - groovy to kotlin * datastore & exceptions - groovy to kotlin * layout inspector - groovy to kotlin * logger & rooms - groovy to kotlin * network & share pref - groovy to kotlin * network interceptor - groovy to kotlin * deleted redundant files * refactor * cleanup
1 parent 42998df commit 2b83a3b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+1584
-738
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,6 @@
88
.cxx
99
/.idea/*
1010
/scripts/publish/_credentials.properties
11+
/scripts/publish/_newCreds.properties
12+
*.gpg
13+
/buildSrc/build

build.gradle

Lines changed: 0 additions & 51 deletions
This file was deleted.

build.gradle.kts

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
import org.gradle.api.tasks.Copy
2+
import org.gradle.api.tasks.Delete
3+
import io.gitlab.arturbosch.detekt.Detekt
4+
5+
// Top-level build file where you can add configuration options common to all sub-projects/modules.
6+
plugins {
7+
alias(libs.plugins.dokka)
8+
alias(libs.plugins.android.library) apply false
9+
alias(libs.plugins.android.application) apply false
10+
alias(libs.plugins.kotlin.android) apply false
11+
alias(libs.plugins.kotlin.parcelize) apply false
12+
alias(libs.plugins.ksp) apply false
13+
alias(libs.plugins.detekt) apply false
14+
alias(libs.plugins.ktlint) apply false
15+
}
16+
17+
allprojects {
18+
repositories {
19+
google()
20+
mavenCentral()
21+
// for testing Pluto staged repository
22+
maven("https://s01.oss.sonatype.org/content/groups/staging/")
23+
}
24+
}
25+
26+
subprojects {
27+
// if (project.name != "pluto-no-op") {
28+
pluginManager.withPlugin("kotlin-android") {
29+
apply (from = "$rootDir/scripts/static-analysis/code-analysis.gradle")
30+
}
31+
// }
32+
}
33+
34+
val installGitHook by tasks.registering(Copy::class) {
35+
from(File(rootProject.rootDir, "pre-commit"))
36+
into(File(rootProject.rootDir, ".git/hooks"))
37+
fileMode = "0777".toInt(8)
38+
}
39+
40+
val clean by tasks.registering(Delete::class) {
41+
dependsOn(installGitHook)
42+
delete(rootProject.buildDir)
43+
}
44+
45+
tasks.withType<Detekt>().configureEach {
46+
exclude(".*/resources/.*,.*/build/.*")
47+
}
48+
49+
val prCheck by tasks.registering {
50+
dependsOn(":sample:assembleDebug")
51+
dependsOn(":pluto:validateChanges")
52+
}
53+
54+
apply (from = "$rootDir/scripts/project-dependancy-graph.gradle")
55+
apply (from = "$rootDir/maven-versions.gradle.kts")

buildSrc/build.gradle.kts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
plugins {
2+
`kotlin-dsl`
3+
}
4+
5+
repositories {
6+
mavenCentral()
7+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import java.io.File
2+
import java.util.Properties
3+
4+
object Versioning {
5+
fun loadVersioningData(): Map<String, Any> {
6+
val version = mutableMapOf<String, Any>()
7+
8+
val versionProps = Properties().apply {
9+
load(File("${System.getProperty("user.dir")}/version.properties").inputStream())
10+
}
11+
12+
val versionMajor = versionProps["major"]?.toString()?.toInt() ?: 0
13+
val versionMinor = versionProps["minor"]?.toString()?.toInt() ?: 0
14+
val versionPatch = versionProps["patch"]?.toString()?.toInt() ?: 0
15+
val versionBuild = versionProps["build"]?.toString()?.toInt() ?: 0
16+
val versionChannel = versionProps["channel"]?.toString() ?: "release"
17+
18+
version["code"] = (versionMajor * 1_000_000) + (versionMinor * 10_000) + (versionPatch * 100) + versionBuild
19+
version["name"] = "$versionMajor.$versionMinor.$versionPatch-rc$versionBuild"
20+
21+
var publishVersion = "$versionMajor.$versionMinor.$versionPatch"
22+
if (versionChannel != "release") {
23+
publishVersion = "$publishVersion-$versionChannel$versionBuild"
24+
}
25+
version["publish"] = publishVersion
26+
27+
val gitSha = "git rev-parse --short=10 HEAD".runCommand()?.trim() ?: ""
28+
version["gitSha"] = gitSha
29+
30+
return version
31+
}
32+
33+
private fun String.runCommand(): String? {
34+
return try {
35+
ProcessBuilder("/bin/sh", "-c", this).start().inputStream.bufferedReader().readText()
36+
} catch (e: Exception) {
37+
null
38+
}
39+
}
40+
}

maven-versions.gradle

Lines changed: 0 additions & 3 deletions
This file was deleted.

maven-versions.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
extra["plutoVersion"] = "2.0.5"

pluto-plugins/base/lib/build.gradle

Lines changed: 0 additions & 31 deletions
This file was deleted.
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
plugins {
2+
alias(libs.plugins.android.library)
3+
alias(libs.plugins.kotlin.android)
4+
}
5+
6+
val version = Versioning.loadVersioningData()
7+
val verCode = version["code"] as Int
8+
val verPublish = version["publish"] as String
9+
val verGitSHA = version["gitSha"] as String
10+
11+
extra["PUBLISH_GROUP_ID"] = "com.plutolib"
12+
extra["PUBLISH_ARTIFACT_ID"] = "plugin"
13+
extra["PUBLISH_VERSION"] = verPublish
14+
15+
android {
16+
namespace = "com.pluto.plugin"
17+
resourcePrefix = "pluto___"
18+
compileSdk = libs.versions.compileSdk.get().toInt()
19+
buildToolsVersion = libs.versions.buildTools.get()
20+
21+
buildFeatures {
22+
buildConfig = true
23+
viewBinding = true
24+
}
25+
26+
defaultConfig {
27+
minSdk = libs.versions.minSdk.get().toInt()
28+
29+
buildConfigField("String", "VERSION_NAME", "\"$verPublish\"")
30+
buildConfigField("long", "VERSION_CODE", "$verCode")
31+
buildConfigField("String", "GIT_SHA", "\"$verGitSHA\"")
32+
}
33+
34+
buildTypes {
35+
getByName("release") {
36+
// isDebuggable = true
37+
isMinifyEnabled = false
38+
isShrinkResources = false
39+
}
40+
}
41+
42+
compileOptions {
43+
sourceCompatibility = JavaVersion.toVersion(libs.versions.java.get())
44+
targetCompatibility = JavaVersion.toVersion(libs.versions.java.get())
45+
}
46+
47+
kotlinOptions {
48+
jvmTarget = libs.versions.java.get()
49+
}
50+
51+
lint {
52+
abortOnError = false
53+
targetSdk = libs.versions.targetSdk.get().toInt()
54+
}
55+
}
56+
57+
dependencies {
58+
implementation(libs.androidx.core)
59+
implementation(libs.androidx.appcompat)
60+
61+
api(libs.androidx.constraintlayout)
62+
api(libs.androidx.navigation.fragment)
63+
api(libs.androidx.recyclerview)
64+
65+
api(libs.google.material)
66+
67+
api(libs.androidx.cardview)
68+
69+
api(libs.androidx.lifecycle.common)
70+
api(libs.androidx.lifecycle.runtime)
71+
}

pluto-plugins/bundle/lib-no-op/build.gradle

Lines changed: 0 additions & 26 deletions
This file was deleted.

0 commit comments

Comments
 (0)