From 81988b57cacd1be5ba7f6144fe9f4ff8b04ca295 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hunyady=20Mih=C3=A1ly?= Date: Tue, 20 Feb 2024 16:10:37 +0100 Subject: [PATCH] chore(gradle): migrate build.gradle to KTS based gradle files SUITEDEV-35237 Co-authored-by: davidSchuppa <32750715+davidSchuppa@users.noreply.github.com> Co-authored-by: LasOri <24588073+LasOri@users.noreply.github.com> Co-authored-by: matusekma <36794575+matusekma@users.noreply.github.com> --- .env.example | 22 ++++++ .gitignore | 3 +- build.gradle | 42 ----------- build.gradle.kts | 62 ++++++++++++++++ buildSrc/src/main/java/Config.kt | 5 -- buildSrc/src/main/java/Dependency.kt | 73 ------------------- buildSrc/src/main/java/GitVersion.kt | 1 + common/build.gradle | 10 ++- core-api/build.gradle | 14 ---- core-api/build.gradle.kts | 20 +++++ core/build.gradle | 11 --- core/build.gradle.kts | 21 ++++++ core/proguard-rules.pro | 2 +- .../{build.gradle => build.gradle.kts} | 24 ++++-- emarsys-firebase/build.gradle | 26 +++++-- emarsys-huawei/build.gradle | 14 ---- emarsys-huawei/build.gradle.kts | 24 ++++++ emarsys-sdk/build.gradle | 32 -------- emarsys-sdk/build.gradle.kts | 28 +++++++ emarsys-sdk/proguard-rules.pro | 2 +- emarsys/build.gradle | 16 ---- emarsys/build.gradle.kts | 26 +++++++ gradle/common.gradle | 62 ---------------- gradle/dev.gradle | 12 --- gradle/libs.versions.toml | 10 ++- gradle/version.gradle | 42 ----------- mobile-engage-api/build.gradle | 11 --- mobile-engage-api/build.gradle.kts | 22 ++++++ mobile-engage/build.gradle | 18 ----- mobile-engage/build.gradle.kts | 24 ++++++ mobile-engage/proguard-rules.pro | 2 +- predict-api/build.gradle | 9 --- predict-api/build.gradle.kts | 17 +++++ predict/build.gradle | 11 --- predict/build.gradle.kts | 22 ++++++ sample/build.gradle | 34 ++------- settings.gradle.kts | 12 ++- testUtils/build.gradle | 61 ---------------- testUtils/build.gradle.kts | 61 ++++++++++++++++ 39 files changed, 426 insertions(+), 482 deletions(-) create mode 100644 .env.example delete mode 100644 build.gradle create mode 100644 build.gradle.kts delete mode 100644 buildSrc/src/main/java/Config.kt delete mode 100644 buildSrc/src/main/java/Dependency.kt create mode 100644 buildSrc/src/main/java/GitVersion.kt delete mode 100644 core-api/build.gradle create mode 100644 core-api/build.gradle.kts delete mode 100644 core/build.gradle create mode 100644 core/build.gradle.kts rename emarsys-e2e-test/{build.gradle => build.gradle.kts} (67%) delete mode 100644 emarsys-huawei/build.gradle create mode 100644 emarsys-huawei/build.gradle.kts delete mode 100644 emarsys-sdk/build.gradle create mode 100644 emarsys-sdk/build.gradle.kts delete mode 100644 emarsys/build.gradle create mode 100644 emarsys/build.gradle.kts delete mode 100644 gradle/common.gradle delete mode 100644 gradle/dev.gradle delete mode 100644 gradle/version.gradle delete mode 100644 mobile-engage-api/build.gradle create mode 100644 mobile-engage-api/build.gradle.kts delete mode 100644 mobile-engage/build.gradle create mode 100644 mobile-engage/build.gradle.kts delete mode 100644 predict-api/build.gradle create mode 100644 predict-api/build.gradle.kts delete mode 100644 predict/build.gradle create mode 100644 predict/build.gradle.kts delete mode 100644 testUtils/build.gradle create mode 100644 testUtils/build.gradle.kts diff --git a/.env.example b/.env.example new file mode 100644 index 000000000..f4e5f2caa --- /dev/null +++ b/.env.example @@ -0,0 +1,22 @@ +USE_LOCAL_DEPENDENCY= +GOOGLE_SERVICES_API_KEY= +RELEASE_MODE= +ANDROID_RELEASE_STORE_FILE_BASE64= +ANDROID_RELEASE_STORE_PASSWORD= +ANDROID_RELEASE_KEY_ALIAS= +ANDROID_RELEASE_KEY_PASSWORD= +FIREBASE_PROJECT_ID= +FIREBASE_SERVICE_ACCOUNT_JSON= +GOOGLE_OAUTH_SERVER_CLIENT_ID= +GOOGLE_SERVICES_JSON_BASE64= +OSSRH_USERNAME= +OSSRH_PASSWORD= +SONATYPE_STAGING_PROFILE_ID= +SONATYPE_SIGNING_KEY_ID= +SONATYPE_SIGNING_PASSWORD= +SONATYPE_SIGNING_SECRET_KEY_RING_FILE= +DETECT_LATEST_RELEASE_VERSION= +DETECT_PROJECT_USER_GROUPS= +DETECT_PROJECT_VERSION_DISTRIBUTION= +BLACKDUCK_ACCESS_TOKEN= +BLACKDUCK_URL= \ No newline at end of file diff --git a/.gitignore b/.gitignore index d8513c4ed..455e1ce24 100644 --- a/.gitignore +++ b/.gitignore @@ -7,4 +7,5 @@ local.properties localConfig.properties sample/google-services.json sample/agconnect-services.json -.fleet \ No newline at end of file +.fleet +.env \ No newline at end of file diff --git a/build.gradle b/build.gradle deleted file mode 100644 index 076fcc2f2..000000000 --- a/build.gradle +++ /dev/null @@ -1,42 +0,0 @@ -ext.modules = [':core-api', ':core', ':common', ':mobile-engage-api', ':mobile-engage', ':emarsys-firebase', ':emarsys-huawei', ':predict-api', ':predict', ':emarsys', ':emarsys-sdk', ':emarsys-e2e-test'] - -buildscript { - repositories { - google() - maven { url "https://plugins.gradle.org/m2/" } - maven { - url 'https://developer.huawei.com/repo/' - } - maven { - url "https://androidx.dev/storage/compose-compiler/repository/" - } - gradlePluginPortal() - } - dependencies { - classpath 'com.android.tools.build:gradle:8.1.4' - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$Versions.kotlin_version" - classpath "org.jetbrains.kotlin:kotlin-allopen:$Versions.kotlin_version" - classpath "com.github.ben-manes:gradle-versions-plugin:0.51.0" - classpath "androidx.navigation:navigation-safe-args-gradle-plugin:2.7.6" - classpath "io.github.gradle-nexus:publish-plugin:1.3.0" - } -} - -// for blackduck: -// sourceCompatibility = 17 - -apply from: 'gradle/dev.gradle' -apply from: 'gradle/version.gradle' -apply from: 'gradle/common.gradle' -apply from: 'gradle/release.gradle' -apply plugin: "com.github.ben-manes.versions" - -dependencyUpdates.resolutionStrategy { - componentSelection { rules -> - rules.all { ComponentSelection selection -> - if (!(selection.candidate.version ==~ /\d+\.\d+(\.\d+)?/)) { - selection.reject('Not release candidate!') - } - } - } -} \ No newline at end of file diff --git a/build.gradle.kts b/build.gradle.kts new file mode 100644 index 000000000..bae1dca80 --- /dev/null +++ b/build.gradle.kts @@ -0,0 +1,62 @@ +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.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) + 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) { + git.fetch() + } + if (git.describe() == null) { + throw RuntimeException("Couldn't get Version Name") + } + val v = GitVersion( + versionName = + if (System.getenv("RELEASE_VERSION") == null) git.describe() else System.getenv( + "RELEASE_VERSION" + ), + versionCode = ((System.currentTimeMillis() - 1602845230) / 10000).toInt(), + versionCodeTime = git.head().time + ) + ext["gitVersionName"] = v.versionName + ext["gitVersionCode"] = v.versionCode + ext["gitVersionCodeTime"] = v.versionCodeTime + + println("versionName: ${v.versionName}") + println("versionCode: ${v.versionCode}") + +} \ No newline at end of file diff --git a/buildSrc/src/main/java/Config.kt b/buildSrc/src/main/java/Config.kt deleted file mode 100644 index 6f3bc7d0f..000000000 --- a/buildSrc/src/main/java/Config.kt +++ /dev/null @@ -1,5 +0,0 @@ -object Config { - const val minApiLevel = 24 - const val targetApiLevel = 34 - const val buildToolsVersion = Versions.buildToolsVersion -} diff --git a/buildSrc/src/main/java/Dependency.kt b/buildSrc/src/main/java/Dependency.kt deleted file mode 100644 index b41e576ab..000000000 --- a/buildSrc/src/main/java/Dependency.kt +++ /dev/null @@ -1,73 +0,0 @@ -object Versions { - const val kotlin_version = "1.9.0" - const val kotlin_coroutines_version = "1.7.3" - const val kotlin_test_version = "3.4.2" - const val mockito_version = "4.9.0" - const val mockito_core_version = "4.9.0" - const val firebase_messaging_version = "23.4.0" - const val support_test_version = "1.5.2" - const val support_rules_test_version = "1.5.0" - const val support_library = "1.6.1" - const val support_test_extensions = "1.1.5" - const val support_test_fragment = "1.6.2" - const val support_annotations = "1.7.1" - const val buildToolsVersion = "34.0.0" - const val multiDexVersion = "2.0.0" - const val kotlinMockito = "4.1.0" - const val location_services_version = "21.1.0" - const val espresso_idling_resources = "3.5.1" - const val archLifecycleVersion = "2.7.0" - const val java8LifecycleVersion = "2.7.0" - const val securityCryptoVersion = "1.1.0-alpha06" - const val byte_buddy_version = "1.14.4" - const val google_tink_version = "1.9.0" - const val huawei_agconnect_core_version = "1.9.1.300" - const val huawei_hms_push_version = "6.11.0.300" - const val mockkVersion = "1.13.3" - const val webkit = "1.7.0" -} - -object Libs { - const val support_annotations = "androidx.annotation:annotation:${Versions.support_annotations}" - const val support_appcompat = "androidx.appcompat:appcompat:${Versions.support_library}" - const val firebase_messaging = - "com.google.firebase:firebase-messaging:${Versions.firebase_messaging_version}" - const val espresso_idling_resources = - "androidx.test.espresso:espresso-idling-resource:${Versions.espresso_idling_resources}" - const val kotlin = "org.jetbrains.kotlin:kotlin-stdlib:${Versions.kotlin_version}" - const val kotlin_reflect = "org.jetbrains.kotlin:kotlin-reflect:${Versions.kotlin_version}" - const val kotlin_stdlib = - "org.jetbrains.kotlin:kotlin-stdlib:${Versions.kotlin_version}" - const val kotlin_coroutines = - "org.jetbrains.kotlinx:kotlinx-coroutines-android:${Versions.kotlin_coroutines_version}" - const val location_services = - "com.google.android.gms:play-services-location:${Versions.location_services_version}" - const val lifecycle_process = - "androidx.lifecycle:lifecycle-process:${Versions.archLifecycleVersion}" - const val lifecycle_extension_java_8 = - "androidx.lifecycle:lifecycle-common-java8:${Versions.java8LifecycleVersion}" - const val security_crypto = - "androidx.security:security-crypto:${Versions.securityCryptoVersion}" - const val google_tink = "com.google.crypto.tink:tink-android:${Versions.google_tink_version}" - const val webkit = "androidx.webkit:webkit:${Versions.webkit}" - const val huawei_agconnect_core = - "com.huawei.agconnect:agconnect-core:${Versions.huawei_agconnect_core_version}" - const val huawei_hms_push = "com.huawei.hms:push:${Versions.huawei_hms_push_version}" -} - -object TestLibs { - const val kotlin_test = "io.kotlintest:kotlintest-runner-junit4:${Versions.kotlin_test_version}" - const val mockito_android = "org.mockito:mockito-android:${Versions.mockito_version}" - const val mockito_core = "org.mockito:mockito-core:${Versions.mockito_core_version}" - const val kotlin_mockito = "org.mockito.kotlin:mockito-kotlin:${Versions.kotlinMockito}" - const val byte_buddy = "net.bytebuddy:byte-buddy:${Versions.byte_buddy_version}" - const val support_test_runner = "androidx.test:runner:${Versions.support_test_version}" - const val support_test_rules = "androidx.test:rules:${Versions.support_rules_test_version}" - const val support_test_extensions = - "androidx.test.ext:junit:${Versions.support_test_extensions}" - const val support_test_fragment = - "androidx.fragment:fragment-testing:${Versions.support_test_fragment}" - const val multiDex = "androidx.multidex:multidex-instrumentation:${Versions.multiDexVersion}" - const val mockk = "io.mockk:mockk-android:${Versions.mockkVersion}" - const val mockk_agent = "io.mockk:mockk-agent-jvm:${Versions.mockkVersion}" -} \ No newline at end of file diff --git a/buildSrc/src/main/java/GitVersion.kt b/buildSrc/src/main/java/GitVersion.kt new file mode 100644 index 000000000..1819f936d --- /dev/null +++ b/buildSrc/src/main/java/GitVersion.kt @@ -0,0 +1 @@ +data class GitVersion(val versionName: String, val versionCode: Int, val versionCodeTime: Long) diff --git a/common/build.gradle b/common/build.gradle index 476491216..8b7b88d73 100644 --- a/common/build.gradle +++ b/common/build.gradle @@ -1,6 +1,12 @@ +plugins { + alias(libs.plugins.androidLibrary) + alias(libs.plugins.kotlin) + alias(libs.plugins.kapt) + alias(libs.plugins.kotlinAllOpen) +} dependencies { - implementation project(':core-api') - androidTestImplementation project(':testUtils') + implementation project(":core-api") + androidTestImplementation project(":testUtils") } android { namespace "com.emarsys.common" diff --git a/core-api/build.gradle b/core-api/build.gradle deleted file mode 100644 index 099968cfb..000000000 --- a/core-api/build.gradle +++ /dev/null @@ -1,14 +0,0 @@ -dependencies { - api Libs.support_annotations - api Libs.support_appcompat - api Libs.kotlin - api Libs.espresso_idling_resources - api Libs.lifecycle_extension_java_8 - api Libs.lifecycle_process - api Libs.security_crypto - androidTestImplementation project(':testUtils') -} -android { - namespace "com.emarsys.core.api" - sourceCompatibility = 17 -} \ No newline at end of file diff --git a/core-api/build.gradle.kts b/core-api/build.gradle.kts new file mode 100644 index 000000000..8ece3b811 --- /dev/null +++ b/core-api/build.gradle.kts @@ -0,0 +1,20 @@ +plugins { + alias(libs.plugins.androidLibrary) + alias(libs.plugins.kotlin) + alias(libs.plugins.kapt) + alias(libs.plugins.kotlinAllOpen) +} +dependencies { + api(libs.androidx.annotation) + api(libs.androidx.appcompat) + api(libs.kotlin.stdlib) + api(libs.androidx.espresso.idling.resource) + api(libs.androidx.lifecycle.common.java8) + api(libs.androidx.lifecycle.process) + api(libs.androidx.security.crypto) + androidTestImplementation(project(":testUtils")) +} +android { + namespace = "com.emarsys.core.api" +} +kotlin { jvmToolchain(17) } \ No newline at end of file diff --git a/core/build.gradle b/core/build.gradle deleted file mode 100644 index 663e7a59e..000000000 --- a/core/build.gradle +++ /dev/null @@ -1,11 +0,0 @@ -dependencies { - implementation project(':core-api') - implementation Libs.google_tink - implementation Libs.kotlin_coroutines - - androidTestImplementation project(':testUtils') -} -android { - namespace "com.emarsys.core" - sourceCompatibility = 17 -} \ No newline at end of file diff --git a/core/build.gradle.kts b/core/build.gradle.kts new file mode 100644 index 000000000..d825ed07f --- /dev/null +++ b/core/build.gradle.kts @@ -0,0 +1,21 @@ +plugins { + alias(libs.plugins.androidLibrary) + alias(libs.plugins.kotlin) + alias(libs.plugins.kapt) + alias(libs.plugins.kotlinAllOpen) +} + +dependencies { + implementation(project(":core-api")) + implementation(libs.google.tink) + implementation(libs.kotlinx.coroutines.core) + + androidTestImplementation(project(":testUtils")) +} +android { + namespace = "com.emarsys.core" +} + +kotlin { + jvmToolchain(17) +} \ No newline at end of file diff --git a/core/proguard-rules.pro b/core/proguard-rules.pro index 162d8da73..e580a0b86 100644 --- a/core/proguard-rules.pro +++ b/core/proguard-rules.pro @@ -2,7 +2,7 @@ # By default, the flags in this file are appended to flags specified # in /Users/jpollak/Library/Android/sdk/tools/proguard/proguard-android.txt # You can edit the include path and order by changing the proguardFiles -# directive in build.gradle. +# directive in build.gradle.kts. # # For more details, see # http://developer.android.com/guide/developing/tools/proguard.html diff --git a/emarsys-e2e-test/build.gradle b/emarsys-e2e-test/build.gradle.kts similarity index 67% rename from emarsys-e2e-test/build.gradle rename to emarsys-e2e-test/build.gradle.kts index 7ce26b786..e7bd5bb08 100644 --- a/emarsys-e2e-test/build.gradle +++ b/emarsys-e2e-test/build.gradle.kts @@ -1,14 +1,24 @@ +plugins { + alias(libs.plugins.androidLibrary) + alias(libs.plugins.kotlin) + alias(libs.plugins.kapt) + alias(libs.plugins.kotlinAllOpen) +} + dependencies { - implementation project(':emarsys-sdk') - implementation project(':core') - implementation project(':mobile-engage') - implementation project(':predict') + implementation(project(":emarsys-sdk")) + implementation(project(":core")) + implementation(project(":mobile-engage")) + implementation(project(":predict")) - androidTestImplementation project(':testUtils') + androidTestImplementation(project(":testUtils")) } android { - namespace "com.emarsys.test.e2e" - sourceCompatibility = 17 + namespace = "com.emarsys.test.e2e" +} + +kotlin { + jvmToolchain(17) } //task enableMockLocationForTestsOnDevice(type: Exec, dependsOn: 'installDebugAndroidTest') { diff --git a/emarsys-firebase/build.gradle b/emarsys-firebase/build.gradle index 028f72560..8657b8693 100644 --- a/emarsys-firebase/build.gradle +++ b/emarsys-firebase/build.gradle @@ -1,14 +1,24 @@ +plugins { + alias(libs.plugins.androidLibrary) + alias(libs.plugins.kotlin) + alias(libs.plugins.kapt) + alias(libs.plugins.kotlinAllOpen) +} + dependencies { - implementation project(':core-api') - implementation project(':core') - implementation project(':mobile-engage') - implementation project(':mobile-engage-api') + implementation(project(":core-api")) + implementation(project(":core")) + implementation(project(":mobile-engage")) + implementation(project(":mobile-engage-api")) - api Libs.firebase_messaging, { exclude group: 'androidx' } + api(libs.google.fcm, { exclude group: 'androidx' }) - androidTestImplementation project(':testUtils') + androidTestImplementation(project(":testUtils")) } android { - namespace "com.emarsys.firebase" - sourceCompatibility = 17 + namespace = "com.emarsys.firebase" +} + +kotlin { + jvmToolchain(17) } \ No newline at end of file diff --git a/emarsys-huawei/build.gradle b/emarsys-huawei/build.gradle deleted file mode 100644 index b7dae9baa..000000000 --- a/emarsys-huawei/build.gradle +++ /dev/null @@ -1,14 +0,0 @@ -dependencies { - implementation project(':core-api') - implementation project(':core') - implementation project(':mobile-engage') - implementation project(':mobile-engage-api') - - api Libs.huawei_agconnect_core - api Libs.huawei_hms_push - androidTestImplementation project(':testUtils') -} -android { - namespace "com.emarsys.huawei" - sourceCompatibility = 17 -} \ No newline at end of file diff --git a/emarsys-huawei/build.gradle.kts b/emarsys-huawei/build.gradle.kts new file mode 100644 index 000000000..8c3ab26e5 --- /dev/null +++ b/emarsys-huawei/build.gradle.kts @@ -0,0 +1,24 @@ +plugins { + alias(libs.plugins.androidLibrary) + alias(libs.plugins.kotlin) + alias(libs.plugins.kapt) + alias(libs.plugins.kotlinAllOpen) +} + +dependencies { + implementation(project(":core-api")) + implementation(project(":core")) + implementation(project(":mobile-engage")) + implementation(project(":mobile-engage-api")) + + api(libs.huawei.agconnect.core) + api(libs.huawei.hms.push) + androidTestImplementation(project(":testUtils")) +} +android { + namespace = "com.emarsys.huawei" +} + +kotlin { + jvmToolchain(17) +} diff --git a/emarsys-sdk/build.gradle b/emarsys-sdk/build.gradle deleted file mode 100644 index 0f7b63e43..000000000 --- a/emarsys-sdk/build.gradle +++ /dev/null @@ -1,32 +0,0 @@ -dependencies { - api project(':core-api') - api project(':mobile-engage-api') - api project(':predict-api') - - implementation project(':common') - implementation project(':core') - implementation project(':mobile-engage') - implementation project(':predict') - implementation project(':emarsys') - - androidTestImplementation project(':testUtils') -} - -android { - namespace "com.emarsys" - sourceCompatibility = 17 - - defaultConfig { - def api_key = null - def localConfigPropertiesFile = rootProject.file('localConfig.properties') - def localConfigProperties = new Properties() - if (localConfigPropertiesFile.exists()) { - localConfigProperties.load(new FileInputStream(localConfigPropertiesFile)) - api_key = localConfigProperties.getProperty("googleServicesApiKey") - } - - if (!System.env.EXCLUDE_GOOGLE_SERVICES_API_KEY) { - buildConfigField "String", "GOOGLE_SERVICES_API_KEY", "\"${System.env.GOOGLE_SERVICES_API_KEY ?: api_key}\"" - } - } -} \ No newline at end of file diff --git a/emarsys-sdk/build.gradle.kts b/emarsys-sdk/build.gradle.kts new file mode 100644 index 000000000..30005d8de --- /dev/null +++ b/emarsys-sdk/build.gradle.kts @@ -0,0 +1,28 @@ +plugins { + alias(libs.plugins.androidLibrary) + alias(libs.plugins.kotlin) + alias(libs.plugins.kapt) + alias(libs.plugins.kotlinAllOpen) +} + +dependencies { + api(project(":core-api")) + api(project(":mobile-engage-api")) + api(project(":predict-api")) + + implementation(project(":common")) + implementation(project(":core")) + implementation(project(":mobile-engage")) + implementation(project(":predict")) + implementation(project(":emarsys")) + + androidTestImplementation(project(":testUtils")) +} + +android { + namespace = "com.emarsys" +} + +kotlin { + jvmToolchain(17) +} diff --git a/emarsys-sdk/proguard-rules.pro b/emarsys-sdk/proguard-rules.pro index 856d56b7d..0ddc77f14 100644 --- a/emarsys-sdk/proguard-rules.pro +++ b/emarsys-sdk/proguard-rules.pro @@ -2,7 +2,7 @@ # By default, the flags in this file are appended to flags specified # in /Users/jpollak/Library/Android/sdk/tools/proguard/proguard-android.txt # You can edit the include path and order by changing the proguardFiles -# directive in build.gradle. +# directive in build.gradle.kts. # # For more details, see # http://developer.android.com/guide/developing/tools/proguard.html diff --git a/emarsys/build.gradle b/emarsys/build.gradle deleted file mode 100644 index 2e393317d..000000000 --- a/emarsys/build.gradle +++ /dev/null @@ -1,16 +0,0 @@ -dependencies { - api project(':core-api') - api project(':mobile-engage-api') - api project(':predict-api') - - implementation project(':common') - implementation project(':core') - implementation project(':mobile-engage') - implementation project(':predict') - - androidTestImplementation project(':testUtils') -} -android { - namespace "com.emarsys.inner" - sourceCompatibility = 17 -} \ No newline at end of file diff --git a/emarsys/build.gradle.kts b/emarsys/build.gradle.kts new file mode 100644 index 000000000..6778a3b50 --- /dev/null +++ b/emarsys/build.gradle.kts @@ -0,0 +1,26 @@ +plugins { + alias(libs.plugins.androidLibrary) + alias(libs.plugins.kotlin) + alias(libs.plugins.kapt) + alias(libs.plugins.kotlinAllOpen) +} + +dependencies { + api(project(":core-api")) + api(project(":mobile-engage-api")) + api(project(":predict-api")) + + implementation(project(":common")) + implementation(project(":core")) + implementation(project(":mobile-engage")) + implementation(project(":predict")) + + androidTestImplementation(project(":testUtils")) +} +android { + namespace = "com.emarsys.inner" +} + +kotlin { + jvmToolchain(17) +} \ No newline at end of file diff --git a/gradle/common.gradle b/gradle/common.gradle deleted file mode 100644 index 684fc3fa6..000000000 --- a/gradle/common.gradle +++ /dev/null @@ -1,62 +0,0 @@ -allprojects { - version = gitVersionName - group = 'com.emarsys' -} - -modules.each { - project(it) { - apply plugin: 'com.android.library' - apply plugin: 'kotlin-android' - apply plugin: "kotlin-allopen" - apply plugin: 'kotlin-kapt' - - android { - buildToolsVersion Config.buildToolsVersion - compileSdkVersion Config.targetApiLevel - defaultConfig { - minSdkVersion Config.minApiLevel - targetSdkVersion Config.targetApiLevel - buildConfigField "int", "VERSION_CODE", "$gitVersionCode" - buildConfigField "String", "VERSION_NAME", "\"$gitVersionName\"" - testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" - } - lintOptions { - checkDependencies true - } - compileOptions { - coreLibraryDesugaringEnabled true - } - - kotlin { - jvmToolchain(17) - } - - dependencies { - coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.2.0' - } - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' - } - debug { - multiDexKeepProguard file("$rootDir/proguard-multidex-rules.pro") - multiDexEnabled true - } - } - - packagingOptions { - exclude 'README.txt' - exclude 'META-INF/LICENSE.md' - exclude 'META-INF/LICENSE-notice.md' - } - useLibrary 'android.test.runner' - - useLibrary 'android.test.base' - useLibrary 'android.test.mock' - } - allOpen { - annotation("com.emarsys.core.Mockable") - } - } -} \ No newline at end of file diff --git a/gradle/dev.gradle b/gradle/dev.gradle deleted file mode 100644 index 102e02c76..000000000 --- a/gradle/dev.gradle +++ /dev/null @@ -1,12 +0,0 @@ -project.ext.devConfig = new Properties() - -try { - new FileInputStream("$projectDir/localConfig.properties").withStream { - project.ext.devConfig.load(it) - } -} catch (ignore) { -} - -if (project.ext.devConfig) { - println "Using devConfig: $project.ext.devConfig" -} diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 8ba366c02..753bd8dd6 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -15,6 +15,7 @@ androidx-test-junit = "1.1.5" 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" @@ -33,6 +34,8 @@ location-services = "21.1.0" webkit = "1.7.0" mockito = "4.9.0" mockito-kotlin = "4.1.0" +grGit = "5.0.0-rc.3" +byte-buddy = "1.14.11" [libraries] kotlin-reflect = { module = "org.jetbrains.kotlin:kotlin-reflect", version.ref = "kotlin" } @@ -70,7 +73,8 @@ mockk-android = { module = "io.mockk:mockk-android", version.ref = "mockk" } mockk-agent = { module = "io.mockk:mockk-agent-jvm", version.ref = "mockk" } mockito-android = { module = "org.mockito:mockito-android", version.ref = "mockito" } mockito-kotlin = { module = "org.mockito.kotlin:mockito-kotlin", version.ref = "mockito-kotlin" } -#byte-buddy = { module = "net.bytebuddy:byte-buddy", version.ref = "byte-buddy" } +mockito-core = { module = "org.mockito.kotlin:mockito-core", version.ref = "mockito" } +byte-buddy = { module = "net.bytebuddy:byte-buddy", version.ref = "byte-buddy" } androidx-test-runner = { module = "androidx.test:runner", version.ref = "androidx-test-runner" } androidx-test-rules = { module = "androidx.test:rules", version.ref = "androidx-test-runner" } androidx-test-extensions = { module = "androidx.test.ext:junit", version.ref = "androidx-test-runner" } @@ -82,8 +86,12 @@ 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" } +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" } 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" } diff --git a/gradle/version.gradle b/gradle/version.gradle deleted file mode 100644 index b17f56a27..000000000 --- a/gradle/version.gradle +++ /dev/null @@ -1,42 +0,0 @@ -buildscript { - repositories { - mavenCentral() - maven { - name = 'ajoberstar-backup' - url = 'https://ajoberstar.org/bintray-backup/' - } - } - dependencies { - classpath "org.ajoberstar.grgit:grgit-gradle:4.1.0" - } -} - -import org.ajoberstar.grgit.Grgit - -ext { - git = Grgit.open(currentDir: projectDir) - - try { - if ((System.env.BLACKDUCK == null ? false : System.env.BLACKDUCK) == false) { - git.fetch() - } - } catch(Exception e) { - println("GrGit fetch failed ${e.printStackTrace()}") - } - - gitVersionName = System.env.RELEASE_VERSION == null ? git.describe() : System.env.RELEASE_VERSION - gitVersionCode = gitVersionCode = (int) ((new Date().getTime() - 1602845230) / 10000) - gitVersionCodeTime = git.head().time - git = Grgit.open(currentDir: projectDir) - - gitVersionCodeTime = git.head().time - if (git.describe() == null) { - throw new RuntimeException("Couldn't get Version Name") - } -} - -task printVersion() { - println("Version Name: $gitVersionName") - println("Version Code: $gitVersionCode") - println("Version Code Time: $gitVersionCodeTime") -} \ No newline at end of file diff --git a/mobile-engage-api/build.gradle b/mobile-engage-api/build.gradle deleted file mode 100644 index 0c2d6ef11..000000000 --- a/mobile-engage-api/build.gradle +++ /dev/null @@ -1,11 +0,0 @@ -dependencies { - implementation project(':core-api') - - api Libs.location_services - - androidTestImplementation project(':testUtils') -} -android { - namespace "com.emarsys.mobileengage.api" - sourceCompatibility = 17 -} \ No newline at end of file diff --git a/mobile-engage-api/build.gradle.kts b/mobile-engage-api/build.gradle.kts new file mode 100644 index 000000000..367d166d1 --- /dev/null +++ b/mobile-engage-api/build.gradle.kts @@ -0,0 +1,22 @@ +plugins { + alias(libs.plugins.androidLibrary) + alias(libs.plugins.kotlin) + alias(libs.plugins.kapt) + alias(libs.plugins.kotlinAllOpen) +} + +dependencies { + implementation(project(":core-api")) + + api(libs.google.location) + + androidTestImplementation(project(":testUtils")) +} + +android { + namespace = "com.emarsys.mobileengage.api" +} + +kotlin { + jvmToolchain(17) +} diff --git a/mobile-engage/build.gradle b/mobile-engage/build.gradle deleted file mode 100644 index 18963ab47..000000000 --- a/mobile-engage/build.gradle +++ /dev/null @@ -1,18 +0,0 @@ -plugins { - id("kotlin-parcelize") -} - -dependencies { - implementation project(':common') - implementation project(':core') - implementation project(':core-api') - implementation project(':mobile-engage-api') - - implementation Libs.webkit - - androidTestImplementation project(':testUtils') -} -android { - namespace "com.emarsys.mobileengage" - sourceCompatibility = 17 -} \ No newline at end of file diff --git a/mobile-engage/build.gradle.kts b/mobile-engage/build.gradle.kts new file mode 100644 index 000000000..855380f78 --- /dev/null +++ b/mobile-engage/build.gradle.kts @@ -0,0 +1,24 @@ +plugins { + alias(libs.plugins.androidLibrary) + alias(libs.plugins.kotlin) + alias(libs.plugins.kapt) + alias(libs.plugins.kotlinAllOpen) +} + +dependencies { + implementation(project(":common")) + implementation(project(":core")) + implementation(project(":core-api")) + implementation(project(":mobile-engage-api")) + + implementation(libs.androidx.webkit) + + androidTestImplementation(project(":testUtils")) +} +android { + namespace = "com.emarsys.mobileengage" +} + +kotlin { + jvmToolchain(17) +} \ No newline at end of file diff --git a/mobile-engage/proguard-rules.pro b/mobile-engage/proguard-rules.pro index 3f37f6244..29b8540ee 100644 --- a/mobile-engage/proguard-rules.pro +++ b/mobile-engage/proguard-rules.pro @@ -2,7 +2,7 @@ # By default, the flags in this file are appended to flags specified # in /Users/jpollak/Library/Android/sdk/tools/proguard/proguard-android.txt # You can edit the include path and order by changing the proguardFiles -# directive in build.gradle. +# directive in build.gradle.kts. # # For more details, see # http://developer.android.com/guide/developing/tools/proguard.html diff --git a/predict-api/build.gradle b/predict-api/build.gradle deleted file mode 100644 index 4ceb5d9ed..000000000 --- a/predict-api/build.gradle +++ /dev/null @@ -1,9 +0,0 @@ -dependencies { - implementation project(':core') - api project(':core-api') - androidTestImplementation project(':testUtils') -} -android { - namespace "com.emarsys.predict.api" - sourceCompatibility = 17 -} \ No newline at end of file diff --git a/predict-api/build.gradle.kts b/predict-api/build.gradle.kts new file mode 100644 index 000000000..80282bc84 --- /dev/null +++ b/predict-api/build.gradle.kts @@ -0,0 +1,17 @@ +plugins { + alias(libs.plugins.androidLibrary) + alias(libs.plugins.kotlin) +} + +dependencies { + implementation(project(":core")) + api(project(":core-api")) + androidTestImplementation(project(":testUtils")) +} +android { + namespace = "com.emarsys.predict.api" +} + +kotlin { + jvmToolchain(17) +} \ No newline at end of file diff --git a/predict/build.gradle b/predict/build.gradle deleted file mode 100644 index 1c1f2b425..000000000 --- a/predict/build.gradle +++ /dev/null @@ -1,11 +0,0 @@ -dependencies { - implementation project(':core') - implementation project(':core-api') - implementation project(':predict-api') - - androidTestImplementation project(':testUtils') -} -android { - namespace "com.emarsys.predict" - sourceCompatibility = 17 -} \ No newline at end of file diff --git a/predict/build.gradle.kts b/predict/build.gradle.kts new file mode 100644 index 000000000..f0cef5464 --- /dev/null +++ b/predict/build.gradle.kts @@ -0,0 +1,22 @@ +plugins { + alias(libs.plugins.androidLibrary) + alias(libs.plugins.kotlin) + alias(libs.plugins.kapt) + alias(libs.plugins.kotlinAllOpen) +} + +dependencies { + implementation(project(":core")) + implementation(project(":core-api")) + implementation(project(":predict-api")) + + androidTestImplementation(project(":testUtils")) +} + +android { + namespace = "com.emarsys.predict" +} + +kotlin { + jvmToolchain(17) +} diff --git a/sample/build.gradle b/sample/build.gradle index 27d485b6c..a89b521c9 100644 --- a/sample/build.gradle +++ b/sample/build.gradle @@ -1,14 +1,16 @@ -apply plugin: 'com.android.application' -apply plugin: 'kotlin-android' -apply plugin: 'androidx.navigation.safeargs' +plugins { + alias(libs.plugins.androidApplication) + alias(libs.plugins.kotlin) + alias(libs.plugins.kapt) + alias(libs.plugins.navigationSafeArgs) + alias(libs.plugins.kotlinAllOpen) +} group = 'com.emarsys.sample' android { namespace = "com.emarsys.sample" - buildToolsVersion Config.buildToolsVersion - compileSdkVersion Config.targetApiLevel - sourceCompatibility = 17 + compileSdkVersion 34 defaultConfig { applicationId "com.emarsys.sample" minSdkVersion 24 @@ -74,19 +76,6 @@ android { } } -buildscript { - repositories { - mavenLocal() - google() - mavenCentral() - maven { url 'https://developer.huawei.com/repo/' } - } - dependencies { - classpath 'com.google.gms:google-services:4.4.0' - classpath 'com.huawei.agconnect:agcp:1.9.1.303' - } -} - dependencies { if (project.devConfig.useLocalDependency == true || System.env.DEVELOPMENT_MODE == true) { implementation project(':emarsys-sdk') @@ -127,10 +116,3 @@ dependencies { implementation "com.google.code.gson:gson:2.10.1" debugImplementation "androidx.compose.ui:ui-tooling:1.6.0" } - -task startApp(type: Exec, dependsOn: 'installDebug') { - commandLine 'adb', 'shell', 'am', 'start', '-n', 'com.emarsys.sample/.main.MainActivity' -} - -apply plugin: 'com.google.gms.google-services' -apply plugin: 'com.huawei.agconnect' diff --git a/settings.gradle.kts b/settings.gradle.kts index ed654217d..58298fdde 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -7,16 +7,26 @@ pluginManagement { maven(url = "https://developer.huawei.com/repo/") maven(url = "https://ajoberstar.org/bintray-backup/") } + resolutionStrategy { + eachPlugin { + if (requested.id.namespace == "com.huawei") { + if (requested.id.id == "com.huawei.agconnect") { + useModule("com.huawei.agconnect:agcp:${requested.version}") + } + } + } + } } dependencyResolutionManagement { - repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) repositories { google() mavenCentral() maven(url = "https://maven.google.com") maven(url = "https://developer.huawei.com/repo/") + maven(url = "https://ajoberstar.org/bintray-backup/") } } +rootProject.name = "Android Emarsys SDK" include( ":common", diff --git a/testUtils/build.gradle b/testUtils/build.gradle deleted file mode 100644 index a27be5bf7..000000000 --- a/testUtils/build.gradle +++ /dev/null @@ -1,61 +0,0 @@ -apply plugin: 'com.android.library' -apply plugin: 'kotlin-android' - -android { - namespace = "com.emarsys.testUtil" - compileSdk Config.targetApiLevel - sourceCompatibility = 17 - defaultConfig { - minSdkVersion Config.minApiLevel - targetSdkVersion Config.targetApiLevel - testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" - } - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' - } - debug { - multiDexEnabled true - } - } - packagingOptions { - resources { - excludes += ['README.txt', 'META-INF/LICENSE.md', 'META-INF/LICENSE-notice.md'] - } - } - - lint { - abortOnError false - } - kotlin { - jvmToolchain(17) - } -} - -group = 'com.emarsys.testUtil' - -dependencies { - implementation Libs.support_appcompat - api TestLibs.support_test_extensions - debugApi TestLibs.support_test_fragment - - api Libs.kotlin - implementation Libs.kotlin_stdlib - implementation Libs.kotlin_reflect - api TestLibs.kotlin_test - api TestLibs.mockito_android - api TestLibs.mockito_core - api TestLibs.kotlin_mockito - api TestLibs.byte_buddy - api TestLibs.support_test_runner - api TestLibs.support_test_rules - api TestLibs.multiDex - api TestLibs.mockk - api TestLibs.mockk_agent -} -configurations{ - api { - exclude group: 'io.mockk',module:'mockk-agent-jvm' - } -} \ No newline at end of file diff --git a/testUtils/build.gradle.kts b/testUtils/build.gradle.kts new file mode 100644 index 000000000..45ed1c353 --- /dev/null +++ b/testUtils/build.gradle.kts @@ -0,0 +1,61 @@ +plugins { + alias(libs.plugins.androidLibrary) + alias(libs.plugins.kotlin) +} + +android { + namespace = "com.emarsys.testUtil" + compileSdk = 34 + defaultConfig { + minSdkVersion(24) + targetSdkVersion(34) + testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" + } + buildTypes { + release { + isMinifyEnabled = false + proguardFiles(getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro") + } + debug { + multiDexEnabled = true + } + } + packagingOptions { + resources { + excludes += arrayOf("README.txt", "META-INF/LICENSE.md", "META-INF/LICENSE-notice.md") + } + } + + lint { + abortOnError = false + } + kotlin { + jvmToolchain(17) + } +} + +group = "com.emarsys.testUtil" + +dependencies { + implementation(libs.androidx.appcompat) + api(libs.androidx.test.extensions) + debugApi(libs.androidx.test.fragment) + + api(libs.kotlin.stdlib) + implementation(libs.kotlin.reflect) + api(libs.kotest.assertions.core) + api(libs.mockito.android) + api(libs.mockito.core) + api(libs.mockito.kotlin) + api(libs.byte.buddy) + api(libs.androidx.test.runner) + api(libs.androidx.test.rules) + api(libs.androidx.test.multidex) + api(libs.mockk.android) + api(libs.mockk.agent) +} +configurations { + api { + exclude(group = "io.mockk", module = "mockk-agent-jvm") + } +} \ No newline at end of file