diff --git a/android-core/build.gradle b/android-core/build.gradle index 3943a17f5..f3230652f 100644 --- a/android-core/build.gradle +++ b/android-core/build.gradle @@ -13,8 +13,8 @@ android { exclude 'META-INF/LICENSE' } compileOptions { - sourceCompatibility JavaVersion.VERSION_1_8 - targetCompatibility JavaVersion.VERSION_1_8 + sourceCompatibility JavaVersion.toVersion(JAVA_VERSION) + targetCompatibility JavaVersion.toVersion(JAVA_VERSION) } String url = '\"\"' diff --git a/android-core/proguard.pro b/android-core/proguard.pro index 6862bc3b1..d522ffa4a 100644 --- a/android-core/proguard.pro +++ b/android-core/proguard.pro @@ -252,11 +252,33 @@ public static final ** CREATOR; } --keepclassmembers class com.mparticle.Rokt { - (...); - void *(...); - void *$default(...); - ; +# Firebase and GMS CloudMessaging +-dontwarn com.google.android.gms.cloudmessaging.** +-dontwarn com.google.firebase.messaging.** +-keep class com.google.firebase.messaging.** { *; } + +# Java 9+ StringConcatFactory +-dontwarn java.lang.invoke.StringConcatFactory +-keep class java.lang.invoke.StringConcatFactory { *; } + +# Keep lambdas +-keepclassmembers class * { + private static synthetic *** lambda$*(...); +} +# Additional rules to prevent minification errors with Kotlin +-keepattributes *Annotation*, InnerClasses, Signature, EnclosingMethod +-keepclassmembers class kotlin.Metadata { + public ; +} +-keepclassmembers class * { + @kotlin.Metadata ; +} + +-keep public class com.mparticle.Rokt { + public (...); + public void *(...); + public void *$default(...); + public ; } -keep interface com.mparticle.MpRoktEventCallback { *; } diff --git a/android-kit-base/build.gradle b/android-kit-base/build.gradle index 3115550af..2a1cdcc97 100644 --- a/android-kit-base/build.gradle +++ b/android-kit-base/build.gradle @@ -14,7 +14,7 @@ android { testBuildType 'debug' defaultConfig { - minSdkVersion 14 + minSdk 14 targetSdk 33 testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner' } @@ -37,8 +37,8 @@ android { } compileOptions { - sourceCompatibility JavaVersion.VERSION_1_8 - targetCompatibility JavaVersion.VERSION_1_8 + sourceCompatibility JavaVersion.toVersion(JAVA_VERSION) + targetCompatibility JavaVersion.toVersion(JAVA_VERSION) } } diff --git a/build.gradle b/build.gradle index 90a83d47a..4aa43063c 100644 --- a/build.gradle +++ b/build.gradle @@ -1,6 +1,6 @@ buildscript { ext.kotlin_version = '1.9.0' - ext.gradle_version = '7.3.1' + ext.gradle_version = '8.1.4' repositories { mavenCentral() @@ -14,7 +14,7 @@ buildscript { plugins { id "org.sonarqube" version "3.5.0.2730" - id "org.jlleitschuh.gradle.ktlint" version "11.2.0" + id "org.jlleitschuh.gradle.ktlint" version "13.0.0" } sonarqube { @@ -26,6 +26,15 @@ sonarqube { } subprojects { + afterEvaluate { project -> + if (project.hasProperty('android')) { + project.android { + if (namespace == null) { + namespace project.group + } + } + } + } apply plugin: 'org.sonarqube' sonarqube { androidVariant "release" diff --git a/gradle.properties b/gradle.properties index b2e5897e7..2e22ec6d1 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,4 +2,7 @@ android.useAndroidX=true org.gradle.daemon=true org.gradle.jvmargs=-Xmx2560m -#-XX:ThreadStackSize=4096 -XX:CompilerThreadStackSize=4096 \ No newline at end of file +#-XX:ThreadStackSize=4096 -XX:CompilerThreadStackSize=4096 +android.defaults.buildfeatures.buildconfig=true +systemProp.org.gradle.kotlin.dsl.precompiled.accessors.strict=true +JAVA_VERSION=17 diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 60639c745..bdc9a83b1 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Mon Oct 04 12:58:48 PDT 2021 distributionBase=GRADLE_USER_HOME -distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip distributionPath=wrapper/dists -zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.2-bin.zip +networkTimeout=10000 zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/kit-plugin/build.gradle b/kit-plugin/build.gradle index 5d78bc289..1dd5660b1 100644 --- a/kit-plugin/build.gradle +++ b/kit-plugin/build.gradle @@ -9,13 +9,13 @@ apply from: '../scripts/maven.gradle' dependencies { implementation gradleApi() implementation localGroovy() - compileOnly "com.android.tools.build:gradle:7.3.1" - testImplementation "com.android.tools.build:gradle:4.1.3" + compileOnly "com.android.tools.build:gradle:$gradle_version" + testImplementation "com.android.tools.build:gradle:$gradle_version" } compileGroovy { - sourceCompatibility = JavaVersion.VERSION_1_8 - targetCompatibility = JavaVersion.VERSION_1_8 + sourceCompatibility = JavaVersion.toVersion(JAVA_VERSION) + targetCompatibility = JavaVersion.toVersion(JAVA_VERSION) } dependencies { diff --git a/kit-plugin/src/main/groovy/com/mparticle/kits/KitPlugin.groovy b/kit-plugin/src/main/groovy/com/mparticle/kits/KitPlugin.groovy index f2bf43eb9..c1a3db46d 100644 --- a/kit-plugin/src/main/groovy/com/mparticle/kits/KitPlugin.groovy +++ b/kit-plugin/src/main/groovy/com/mparticle/kits/KitPlugin.groovy @@ -139,17 +139,13 @@ class KitPlugin implements Plugin { url = 'https://ossrh-staging-api.central.sonatype.com/service/local/staging/deploy/maven2/' } - def signingKey = System.getenv("mavenSigningKeyId") - def signingPassword = System.getenv("mavenSigningKeyPassword") - - if (signingKey != null) { - target.extensions.add('signing.keyId', signingKey) - target.extensions.add('signing.password', signingPassword) - - SigningExtension signing = new SigningExtension(target) - signing.required = { target.gradle.taskGraph.hasTask("publishReleasePublicationToMavenRepository") } - signing.useInMemoryPgpKeys(signingKey, signingPassword) - signing.sign publishing.publications.findByName("release") + target.extensions.configure(SigningExtension) { signing -> + signing.required = { target.gradle.taskGraph.hasTask('publishReleasePublicationToMavenRepository') } + def signingKey = target.findProperty('signingKey') ?: System.getenv('mavenSigningKeyId') + def signingPassword = target.findProperty('signingPassword') ?: System.getenv('mavenSigningKeyPassword') + if (signingKey && signingPassword) { + signing.useInMemoryPgpKeys(target.property('signingKey'), target.property('signingPassword')) + } } } diff --git a/scripts/maven.gradle b/scripts/maven.gradle index 365510932..d1b191c7d 100644 --- a/scripts/maven.gradle +++ b/scripts/maven.gradle @@ -6,7 +6,16 @@ allprojects { ext."signing.secretKeyRingFile" = System.getenv("mavenSigningKeyRingFile") ext."signing.password" = System.getenv("mavenSigningKeyPassword") } - +// For AGP 8.x compatibility, configure Android library projects +if (project.plugins.findPlugin("com.android.library")) { + android { + publishing { + // Configure publishing for both variants + singleVariant("release") + singleVariant("debug") + } + } +} afterEvaluate { publishing { publications { @@ -115,5 +124,5 @@ afterEvaluate { } //Publishing task aliases for simpler local development -task publishLocal { dependsOn "publishDebugPublicationToMavenLocal" } -task publishReleaseLocal { dependsOn "publishReleasePublicationToMavenLocal" } +task publishLocal { dependsOn "publishDebugPublicationToMavenLocal"} +task publishReleaseLocal { dependsOn "publishReleasePublicationToMavenLocal"} diff --git a/testutils/build.gradle b/testutils/build.gradle index 707ee2dcd..2f34899c8 100644 --- a/testutils/build.gradle +++ b/testutils/build.gradle @@ -5,7 +5,14 @@ android { namespace 'com.mparticle.testutils' testNamespace 'com.mparticle.legacyTest' compileSdk 33 + compileOptions { + sourceCompatibility = JavaVersion.toVersion(JAVA_VERSION) + targetCompatibility = JavaVersion.toVersion(JAVA_VERSION) + } + kotlinOptions { + jvmTarget = JAVA_VERSION + } defaultConfig { //This is set to 21 to avoid slow multidex. minSdk 21 diff --git a/tooling/android-plugin/build.gradle b/tooling/android-plugin/build.gradle index ee4b47d35..1e5dce121 100644 --- a/tooling/android-plugin/build.gradle +++ b/tooling/android-plugin/build.gradle @@ -1,8 +1,8 @@ apply plugin: 'groovy' apply plugin: 'kotlin' -sourceCompatibility = JavaVersion.VERSION_1_8 -targetCompatibility = JavaVersion.VERSION_1_8 +sourceCompatibility = JavaVersion.toVersion(JAVA_VERSION) +targetCompatibility = JavaVersion.toVersion(JAVA_VERSION) ext { @@ -26,7 +26,7 @@ configurations { dependencies { fatJar project(':tooling:common') - compileOnly configurations.fatJar + compileOnly files(configurations.fatJar) implementation gradleApi() implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" implementation files('libs/java-json.jar') diff --git a/tooling/common/build.gradle b/tooling/common/build.gradle index d1419a6bc..3969cecc4 100644 --- a/tooling/common/build.gradle +++ b/tooling/common/build.gradle @@ -16,6 +16,10 @@ dependencies { } java { - sourceCompatibility = JavaVersion.VERSION_1_8 - targetCompatibility = JavaVersion.VERSION_1_8 + sourceCompatibility = JavaVersion.toVersion(JAVA_VERSION) + targetCompatibility = JavaVersion.toVersion(JAVA_VERSION) +} + +kotlin { + jvmToolchain(Integer.parseInt(JAVA_VERSION)) } \ No newline at end of file diff --git a/tooling/custom-lint-rules/build.gradle b/tooling/custom-lint-rules/build.gradle index 99af1017b..991a16e38 100755 --- a/tooling/custom-lint-rules/build.gradle +++ b/tooling/custom-lint-rules/build.gradle @@ -4,8 +4,8 @@ apply plugin: 'java-library' apply plugin: 'kotlin' apply plugin: 'com.android.lint' -sourceCompatibility = 1.8 -targetCompatibility = 1.8 +sourceCompatibility = 17 +targetCompatibility = 17 buildscript { ext { @@ -39,7 +39,7 @@ dependencies { lintBuild files(jar) lintJar files('libs/mparticle-min.jar') lintJar project(':tooling:common') - implementation configurations.lintJar + implementation files(configurations.lintJar) compileOnly "com.android.tools.lint:lint-api:$lintVersion" compileOnly "com.android.tools.lint:lint-checks:$lintVersion" compileOnly 'org.codehaus.groovy:groovy-all:3.0.13' @@ -51,7 +51,7 @@ dependencies { jar { dependsOn(":tooling:common:jar") - archiveName 'lint.jar' + archiveFileName = 'lint.jar' manifest { attributes 'Manifest-Version': 1.0 attributes 'Lint-Registry-v2': 'com.mparticle.lints.MParticleIssueRegistry' @@ -74,10 +74,9 @@ rootProject.project('android-core').android.buildTypes.all { task zipSources(type: Jar) { def fileName = "$project.rootDir/android-core/build/intermediates/javac/${targetBuildType}/classes" - from(fileTree(dir: fileName)) { - destinationDir new File("$project.projectDir/libs") - archiveName "mparticle.jar" - } + from(fileTree(dir: fileName)) + destinationDirectory.set(new File("$project.projectDir/libs")) + archiveFileName.set("mparticle.jar") outputs.upToDateWhen { false } }