Skip to content

Commit

Permalink
chore(gradle): migrate build.gradle to KTS based gradle files
Browse files Browse the repository at this point in the history
SUITEDEV-35237

Co-authored-by: davidSchuppa <[email protected]>
Co-authored-by: LasOri <[email protected]>
Co-authored-by: matusekma <[email protected]>
  • Loading branch information
4 people committed Feb 20, 2024
1 parent 81988b5 commit b2a21fa
Show file tree
Hide file tree
Showing 21 changed files with 291 additions and 206 deletions.
44 changes: 13 additions & 31 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,45 +1,29 @@
import org.ajoberstar.grgit.Grgit
import java.io.FileInputStream
import java.util.Properties

plugins {
alias(libs.plugins.androidLibrary) apply false
alias(libs.plugins.androidApplication) apply false
alias(libs.plugins.android.library) apply false
alias(libs.plugins.android.application) apply false
alias(libs.plugins.kotlin) apply false
alias(libs.plugins.kapt) apply false
alias(libs.plugins.navigationSafeArgs) apply false
alias(libs.plugins.googleServices) apply false
alias(libs.plugins.kotlinAllOpen) apply false
alias(libs.plugins.grGit)
alias(libs.plugins.androidx.navigation.safeargs) apply false
alias(libs.plugins.google.services) apply false
// alias(libs.plugins.huawei.agconnect) apply false
alias(libs.plugins.kotlin.allopen) apply false
alias(libs.plugins.grgit)
alias(libs.plugins.dotenv)
alias(libs.plugins.kotlin.parcelize) apply false
id("com.github.ben-manes.versions") version "0.46.0"
}

versionData()
loadDevConfig()

fun loadDevConfig() {

ext["devConfig"] = Properties()

try {
val inputStream = FileInputStream("$projectDir/localConfig.properties")
(ext["devConfig"] as Properties).load(inputStream)

} catch (ignore: Exception) {
}

if (ext["devConfig"] != null) {
println("Using devConfig: ${ext["devConfig"]}")
}
}

fun versionData() {
val git = Grgit.open(
mapOf("currentDir" to project.rootDir)
)

if ((if (System.getenv("BLACKDUCK") == null) false else System.getenv("BLACKDUCK")) == false) {
try {
git.fetch()
} catch (ignored: Exception) {
}
if (git.describe() == null) {
throw RuntimeException("Couldn't get Version Name")
Expand All @@ -52,11 +36,9 @@ fun versionData() {
versionCode = ((System.currentTimeMillis() - 1602845230) / 10000).toInt(),
versionCodeTime = git.head().time
)
ext["gitVersionName"] = v.versionName
ext["gitVersionCode"] = v.versionCode
ext["gitVersionCodeTime"] = v.versionCodeTime

val version by extra(v)

println("versionName: ${v.versionName}")
println("versionCode: ${v.versionCode}")

}
2 changes: 1 addition & 1 deletion buildSrc/src/main/java/GitVersion.kt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
data class GitVersion(val versionName: String, val versionCode: Int, val versionCodeTime: Long)
data class GitVersion(val versionName: String, val versionCode: Int, val versionCodeTime: Long)
14 changes: 0 additions & 14 deletions common/build.gradle

This file was deleted.

24 changes: 24 additions & 0 deletions common/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
plugins {
alias(libs.plugins.android.library)
alias(libs.plugins.kotlin)
alias(libs.plugins.kotlin.allopen)
alias(libs.plugins.kapt)
}
dependencies {
implementation(project(":core-api"))
androidTestImplementation(project(":testUtils"))
}
android {
namespace = "com.emarsys.common"
defaultConfig {
compileSdk = libs.versions.android.compileSdk.get().toInt()
}
}

allOpen {
annotation("com.emarsys.core.Mockable")
}

kotlin {
jvmToolchain(17)
}
12 changes: 10 additions & 2 deletions core-api/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
plugins {
alias(libs.plugins.androidLibrary)
alias(libs.plugins.android.library)
alias(libs.plugins.kotlin)
alias(libs.plugins.kotlin.allopen)
alias(libs.plugins.kapt)
alias(libs.plugins.kotlinAllOpen)
}
dependencies {
api(libs.androidx.annotation)
Expand All @@ -16,5 +16,13 @@ dependencies {
}
android {
namespace = "com.emarsys.core.api"
defaultConfig {
compileSdk = libs.versions.android.compileSdk.get().toInt()
}
}

allOpen {
annotation("com.emarsys.core.Mockable")
}

kotlin { jvmToolchain(17) }
15 changes: 13 additions & 2 deletions core/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
plugins {
alias(libs.plugins.androidLibrary)
alias(libs.plugins.android.library)
alias(libs.plugins.kotlin)
alias(libs.plugins.kotlin.allopen)
alias(libs.plugins.kapt)
alias(libs.plugins.kotlinAllOpen)
}

dependencies {
Expand All @@ -14,6 +14,17 @@ dependencies {
}
android {
namespace = "com.emarsys.core"
defaultConfig {
val version: GitVersion by rootProject.extra

compileSdk = libs.versions.android.compileSdk.get().toInt()
buildConfigField("int", "VERSION_CODE", "${version.versionCode}")
buildConfigField("String", "VERSION_NAME", "\"${version.versionName}\"")
}
}

allOpen {
annotation("com.emarsys.core.Mockable")
}

kotlin {
Expand Down
11 changes: 9 additions & 2 deletions emarsys-e2e-test/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
plugins {
alias(libs.plugins.androidLibrary)
alias(libs.plugins.android.library)
alias(libs.plugins.kotlin)
alias(libs.plugins.kotlin.allopen)
alias(libs.plugins.kapt)
alias(libs.plugins.kotlinAllOpen)
}

dependencies {
Expand All @@ -15,6 +15,13 @@ dependencies {
}
android {
namespace = "com.emarsys.test.e2e"
defaultConfig {
compileSdk = libs.versions.android.compileSdk.get().toInt()
}
}

allOpen {
annotation("com.emarsys.core.Mockable")
}

kotlin {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
plugins {
alias(libs.plugins.androidLibrary)
alias(libs.plugins.android.library)
alias(libs.plugins.kotlin)
alias(libs.plugins.kotlin.allopen)
alias(libs.plugins.kapt)
alias(libs.plugins.kotlinAllOpen)
}

dependencies {
Expand All @@ -11,12 +11,19 @@ dependencies {
implementation(project(":mobile-engage"))
implementation(project(":mobile-engage-api"))

api(libs.google.fcm, { exclude group: 'androidx' })
api(libs.google.fcm, { exclude(group = "androidx") })

androidTestImplementation(project(":testUtils"))
}
android {
namespace = "com.emarsys.firebase"
defaultConfig {
compileSdk = libs.versions.android.compileSdk.get().toInt()
}
}

allOpen {
annotation("com.emarsys.core.Mockable")
}

kotlin {
Expand Down
12 changes: 10 additions & 2 deletions emarsys-huawei/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
plugins {
alias(libs.plugins.androidLibrary)
alias(libs.plugins.android.library)
alias(libs.plugins.kotlin)
alias(libs.plugins.kotlin.allopen)
alias(libs.plugins.kapt)
alias(libs.plugins.kotlinAllOpen)
// alias(libs.plugins.huawei.agconnect)
}

dependencies {
Expand All @@ -17,6 +18,13 @@ dependencies {
}
android {
namespace = "com.emarsys.huawei"
defaultConfig {
compileSdk = libs.versions.android.compileSdk.get().toInt()
}
}

allOpen {
annotation("com.emarsys.core.Mockable")
}

kotlin {
Expand Down
11 changes: 9 additions & 2 deletions emarsys-sdk/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
plugins {
alias(libs.plugins.androidLibrary)
alias(libs.plugins.android.library)
alias(libs.plugins.kotlin)
alias(libs.plugins.kotlin.allopen)
alias(libs.plugins.kapt)
alias(libs.plugins.kotlinAllOpen)
}

dependencies {
Expand All @@ -21,6 +21,13 @@ dependencies {

android {
namespace = "com.emarsys"
defaultConfig {
compileSdk = libs.versions.android.compileSdk.get().toInt()
}
}

allOpen {
annotation("com.emarsys.core.Mockable")
}

kotlin {
Expand Down
11 changes: 9 additions & 2 deletions emarsys/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
plugins {
alias(libs.plugins.androidLibrary)
alias(libs.plugins.android.library)
alias(libs.plugins.kotlin)
alias(libs.plugins.kotlin.allopen)
alias(libs.plugins.kapt)
alias(libs.plugins.kotlinAllOpen)
}

dependencies {
Expand All @@ -19,6 +19,13 @@ dependencies {
}
android {
namespace = "com.emarsys.inner"
defaultConfig {
compileSdk = libs.versions.android.compileSdk.get().toInt()
}
}

allOpen {
annotation("com.emarsys.core.Mockable")
}

kotlin {
Expand Down
30 changes: 15 additions & 15 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
[versions]
agp = "8.2.2"
kotlin = "1.9.21"
kotlinxCoroutines = "1.7.3"
compose = "1.6.1"
compose-compiler = "1.5.6"
compose-plugin = "1.6.0-dev1419"
android-compileSdk = "34"
android-minSdk = "28"
android-targetSdk = "34"
Expand All @@ -16,14 +21,9 @@ androidx-lifecycle = "2.7.0"
androidx-espresso-idling-resource = "3.5.1"
androidx-security-crypto = "1.1.0-alpha06"
androidx-navigation-safe-args = "2.5.0"
compose = "1.6.1"
compose-compiler = "1.5.6"
compose-plugin = "1.6.0-dev1419"
dokka = "1.9.10"
junit = "4.13.2"
tink = "1.9.0"
kotlin = "1.9.0"
kotlinxCoroutines = "1.7.3"
kotest = "5.8.0"
mockk = "1.13.9"
fcm = "23.4.0"
Expand All @@ -36,6 +36,7 @@ mockito = "4.9.0"
mockito-kotlin = "4.1.0"
grGit = "5.0.0-rc.3"
byte-buddy = "1.14.11"
dotEnv = "4.0.0"

[libraries]
kotlin-reflect = { module = "org.jetbrains.kotlin:kotlin-reflect", version.ref = "kotlin" }
Expand Down Expand Up @@ -82,16 +83,15 @@ androidx-test-fragment = { module = "androidx.fragment:fragment-testing", versio
androidx-test-multidex = { module = "androidx.multidex:multidex-instrumentation", version.ref = "androidx-test-runner" }

[plugins]
androidApplication = { id = "com.android.application", version.ref = "agp" }
androidLibrary = { id = "com.android.library", version.ref = "agp" }
jetbrainsCompose = { id = "org.jetbrains.compose", version.ref = "compose-plugin" }
kotlinMultiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" }
navigationSafeArgs = { id = "androidx.navigation.safeargs", version.ref = "androidx-navigation-safe-args" }
android-application = { id = "com.android.application", version.ref = "agp" }
android-library = { id = "com.android.library", version.ref = "agp" }
androidx-navigation-safeargs = { id = "androidx.navigation.safeargs", version.ref = "androidx-navigation-safe-args" }
kapt = { id = "org.jetbrains.kotlin.kapt", version.ref = "kotlin" }
kotlin = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
kotlinAllOpen = { id = "org.jetbrains.kotlin.plugin.allopen", version.ref = "kotlin" }
kotlinSerialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" }
kotlin-parcelize = { id = "org.jetbrains.kotlin.plugin.parcelize", version.ref = "kotlin" }
kotlin-allopen = { id = "org.jetbrains.kotlin.plugin.allopen", version.ref = "kotlin" }
dokka = { id = "org.jetbrains.dokka", version.ref = "dokka" }
agconnect = { id = "com.huawei.agconnect", version.ref = "agconnect_core" }
googleServices = { id = "com.google.gms.google-services", version.ref = "googleServices" }
grGit = { id = "org.ajoberstar.grgit", version.ref = "grGit" }
huawei-agconnect = { id = "com.huawei.agconnect", version.ref = "agconnect_core" }
google-services = { id = "com.google.gms.google-services", version.ref = "googleServices" }
grgit = { id = "org.ajoberstar.grgit", version.ref = "grGit" }
dotenv = { id = "co.uzzu.dotenv.gradle", version.ref = "dotEnv" }
11 changes: 9 additions & 2 deletions mobile-engage-api/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
plugins {
alias(libs.plugins.androidLibrary)
alias(libs.plugins.android.library)
alias(libs.plugins.kotlin)
alias(libs.plugins.kotlin.allopen)
alias(libs.plugins.kapt)
alias(libs.plugins.kotlinAllOpen)
}

dependencies {
Expand All @@ -15,6 +15,13 @@ dependencies {

android {
namespace = "com.emarsys.mobileengage.api"
defaultConfig {
compileSdk = libs.versions.android.compileSdk.get().toInt()
}
}

allOpen {
annotation("com.emarsys.core.Mockable")
}

kotlin {
Expand Down
Loading

0 comments on commit b2a21fa

Please sign in to comment.