diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml index e1e3820a..cf84f84a 100644 --- a/.github/workflows/android.yml +++ b/.github/workflows/android.yml @@ -86,9 +86,10 @@ jobs: - name: checkout uses: actions/checkout@v4 - name: set up JDK 17 - uses: actions/setup-java@v1 + uses: actions/setup-java@v4 with: java-version: '17' + distribution: 'temurin' - name: Enable KVM run: | echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules diff --git a/android-sdk/build.gradle b/android-sdk/build.gradle index 28d89a39..1ed3a587 100644 --- a/android-sdk/build.gradle +++ b/android-sdk/build.gradle @@ -18,7 +18,8 @@ apply plugin: 'com.android.library' apply plugin: 'kotlin-android' android { - compileSdkVersion compile_sdk_version + namespace "com.optimizely.ab.android.sdk" + compileSdk compile_sdk_version buildToolsVersion build_tools_version defaultConfig { @@ -32,6 +33,10 @@ android { // these rules will be merged to app's proguard rules consumerProguardFiles '../proguard-rules.txt' } + + buildFeatures { + buildConfig true + } testOptions { unitTests.returnDefaultValues = true unitTests.all { @@ -52,11 +57,6 @@ android { testCoverageEnabled true } } - - compileOptions { - sourceCompatibility JavaVersion.VERSION_17 - targetCompatibility JavaVersion.VERSION_17 - } } repositories { @@ -95,12 +95,13 @@ dependencies { androidTestImplementation "androidx.test:core:$androidx_test_core" androidTestImplementation "androidx.test:core-ktx:$androidx_test_core" - androidTestImplementation "org.mockito:mockito-core:$mockito_ver" - androidTestImplementation "org.mockito:mockito-android:$mockito_ver" + androidTestImplementation "org.mockito:mockito-core:$mockito_ver_sdk_module" + androidTestImplementation "org.mockito:mockito-android:$mockito_ver_sdk_module" androidTestImplementation "com.noveogroup.android:android-logger:$android_logger_ver" androidTestImplementation "com.google.code.gson:gson:$gson_ver" androidTestImplementation "com.fasterxml.jackson.core:jackson-databind:$jacksonversion" - implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" + + implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" } diff --git a/android-sdk/src/androidTest/java/com/optimizely/ab/android/sdk/OptimizelyClientTest.java b/android-sdk/src/androidTest/java/com/optimizely/ab/android/sdk/OptimizelyClientTest.java index b7f2f7b4..1c65ff9a 100644 --- a/android-sdk/src/androidTest/java/com/optimizely/ab/android/sdk/OptimizelyClientTest.java +++ b/android-sdk/src/androidTest/java/com/optimizely/ab/android/sdk/OptimizelyClientTest.java @@ -82,7 +82,7 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.spy; import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyNoInteractions; +import static org.mockito.Mockito.verifyZeroInteractions; import static org.mockito.Mockito.when; @RunWith(Parameterized.class) @@ -431,7 +431,7 @@ public void testGoodForcedTrack() { optimizelyClient.track("test_event", GENERIC_USER_ID); - verifyNoInteractions(logger); + verifyZeroInteractions(logger); ArgumentCaptor logEventArgumentCaptor = ArgumentCaptor.forClass(LogEvent.class); try { @@ -462,7 +462,7 @@ public void testGoodTrack() { OptimizelyClient optimizelyClient = new OptimizelyClient(optimizely, logger); optimizelyClient.track("test_event", GENERIC_USER_ID); - verifyNoInteractions(logger); + verifyZeroInteractions(logger); } @Test @@ -484,7 +484,7 @@ public void onTrack(@Nonnull String eventKey, @Nonnull String userId, @Nonnull M assertTrue(notificationId <= 0); assertFalse(optimizelyClient.getNotificationCenter().removeNotificationListener(notificationId)); assertEquals(false, numberOfCalls[0]); - verifyNoInteractions(logger); + verifyZeroInteractions(logger); } @@ -512,7 +512,7 @@ public void onTrack(@Nonnull String eventKey, @Nonnull String userId, @Nonnull M else { assertEquals(true, numberOfCalls[0]); } - verifyNoInteractions(logger); + verifyZeroInteractions(logger); } @@ -524,7 +524,7 @@ public void testGoodTrackBucketing() { Experiment experiment = optimizelyClient.getProjectConfig().getExperimentsForEventKey("test_event").get(0); attributes.put(BUCKETING_ATTRIBUTE, bucketingId); optimizelyClient.track("test_event", "userId", attributes); - verifyNoInteractions(logger); + verifyZeroInteractions(logger); } @Test @@ -569,7 +569,7 @@ public void testGoodForcedTrackAttribute() { optimizelyClient.track("test_event", GENERIC_USER_ID, attributes); - verifyNoInteractions(logger); + verifyZeroInteractions(logger); ArgumentCaptor logEventArgumentCaptor = ArgumentCaptor.forClass(LogEvent.class); @@ -611,7 +611,7 @@ public void testGoodTrackAttribute() { optimizelyClient.track("test_event", GENERIC_USER_ID, attributes); - verifyNoInteractions(logger); + verifyZeroInteractions(logger); Variation v = optimizelyClient.getForcedVariation(FEATURE_ANDROID_EXPERIMENT_KEY, GENERIC_USER_ID); assertEquals(v.getKey(), "var_2"); @@ -671,7 +671,7 @@ public void testGoodForcedTrackEventVal() { Collections.emptyMap(), Collections.singletonMap(ReservedEventKey.REVENUE.toString(), 1L)); - verifyNoInteractions(logger); + verifyZeroInteractions(logger); ArgumentCaptor logEventArgumentCaptor = ArgumentCaptor.forClass(LogEvent.class); @@ -705,7 +705,7 @@ public void testGoodTrackEventVal() { GENERIC_USER_ID, Collections.emptyMap(), Collections.singletonMap(ReservedEventKey.REVENUE.toString(), 1L)); - verifyNoInteractions(logger); + verifyZeroInteractions(logger); } @Test @@ -750,7 +750,7 @@ public void testGoodTrackAttributeEventVal() { final HashMap attributes = new HashMap<>(); optimizelyClient.track("test_event", GENERIC_USER_ID, attributes, Collections.singletonMap(ReservedEventKey.REVENUE.toString(), 1L)); - verifyNoInteractions(logger); + verifyZeroInteractions(logger); } @Test @@ -770,7 +770,7 @@ public void testGoodForcedTrackAttributeEventVal() { attributes, Collections.singletonMap(ReservedEventKey.REVENUE.toString(), 1L)); - verifyNoInteractions(logger); + verifyZeroInteractions(logger); ArgumentCaptor logEventArgumentCaptor = ArgumentCaptor.forClass(LogEvent.class); @@ -839,7 +839,7 @@ public void testTrackWithEventTags() { final HashMap eventTags = new HashMap<>(); eventTags.put("foo", 843); optimizelyClient.track("test_event", GENERIC_USER_ID, attributes, eventTags); - verifyNoInteractions(logger); + verifyZeroInteractions(logger); } @Test @@ -875,7 +875,7 @@ public void testForcedTrackWithEventTags() { // id of var_2 assertTrue(logEvent.getBody().contains("\"enrich_decisions\":true")); - verifyNoInteractions(logger); + verifyZeroInteractions(logger); Variation v = optimizelyClient.getForcedVariation(FEATURE_ANDROID_EXPERIMENT_KEY, GENERIC_USER_ID); assertEquals(v.getKey(), "var_2"); @@ -979,7 +979,7 @@ public void testGoodGetVariationAttribute() { logger); final HashMap attributes = new HashMap<>(); optimizelyClient.getVariation(FEATURE_ANDROID_EXPERIMENT_KEY, GENERIC_USER_ID, attributes); - verifyNoInteractions(logger); + verifyZeroInteractions(logger); } @Test @@ -996,7 +996,7 @@ public void testGoodForcedGetVariationAttribute() { v = optimizelyClient.getVariation(FEATURE_ANDROID_EXPERIMENT_KEY, GENERIC_USER_ID, attributes); - verifyNoInteractions(logger); + verifyZeroInteractions(logger); assertEquals(v.getKey(), "var_2"); @@ -1180,7 +1180,7 @@ public void testGoodIsFeatureEnabledWithAttribute() { Collections.singletonMap("house", "Gryffindor") )); - verifyNoInteractions(logger); + verifyZeroInteractions(logger); assertFalse(optimizelyClient.isFeatureEnabled( "InvalidFeatureKey", @@ -1301,7 +1301,7 @@ public void testIsFeatureEnabledWithFeatureEnabledTrue(){ Collections.singletonMap("house", "Gryffindor") )); - verifyNoInteractions(logger); + verifyZeroInteractions(logger); } @@ -1398,7 +1398,7 @@ public void testGoodGetFeatureVariableBooleanWithAttr() { GENERIC_USER_ID, Collections.singletonMap("key", "value") )); - verifyNoInteractions(logger); + verifyZeroInteractions(logger); } @@ -1505,7 +1505,7 @@ public void testGoodGetFeatureVariableDoubleWithAttr() { GENERIC_USER_ID, Collections.singletonMap("house", "Gryffindor") )); - verifyNoInteractions(logger); + verifyZeroInteractions(logger); } //FeatureVariableDouble Scenario#3 if feature not found @@ -1616,7 +1616,7 @@ public void testGoodGetFeatureVariableIntegerWithAttr() { GENERIC_USER_ID, Collections.singletonMap("house", "Gryffindor") )); - verifyNoInteractions(logger); + verifyZeroInteractions(logger); } //FeatureVariableInteger Scenario#3 if feature not found @@ -1723,7 +1723,7 @@ public void testGoodGetFeatureVariableStringWithAttr() { GENERIC_USER_ID, Collections.singletonMap("house", "Gryffindor") )); - verifyNoInteractions(logger); + verifyZeroInteractions(logger); } //FeatureVariableString Scenario#3 if feature not found @@ -1837,7 +1837,7 @@ public void testGetFeatureVariableJsonWithAttr() { ); assertTrue(compareJsonStrings(json.toString(), defaultValueOfStringVar)); - verifyNoInteractions(logger); + verifyZeroInteractions(logger); } //FeatureVariableJSON Scenario#3 if feature not found @@ -1949,7 +1949,7 @@ public void testGetAllFeatureVariablesWithAttr() { ); assertTrue(compareJsonStrings(json.toString(), defaultValueOfStringVar)); - verifyNoInteractions(logger); + verifyZeroInteractions(logger); } //GetAllFeatureVariables Scenario#3 if feature not found diff --git a/build.gradle b/build.gradle index 5c8c6e0d..ad912630 100644 --- a/build.gradle +++ b/build.gradle @@ -17,7 +17,7 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { - ext.kotlin_version = '1.7.0' + ext.kotlin_version = '1.9.10' ext.version_name = System.getenv('GITHUB_TAG') if (version_name == null || version_name.isEmpty()) { @@ -30,7 +30,7 @@ buildscript { mavenCentral() } dependencies { - classpath 'com.android.tools.build:gradle:7.2.2' + classpath 'com.android.tools.build:gradle:8.6.0' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" // NOTE: Do not place your application dependencies here; they belong @@ -39,10 +39,23 @@ buildscript { } plugins { - id "org.jlleitschuh.gradle.ktlint" version "11.0.0" + id "org.jlleitschuh.gradle.ktlint" version "11.0.0" id 'io.github.gradle-nexus.publish-plugin' version '2.0.0' } +subprojects { + tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).configureEach { + kotlinOptions { + jvmTarget = "17" + } + } + + tasks.withType(JavaCompile).configureEach { + sourceCompatibility = "17" + targetCompatibility = "17" + } +} + allprojects { tasks.withType(Test).configureEach { maxParallelForks = Runtime.runtime.availableProcessors().intdiv(2) ?: 1 @@ -63,21 +76,32 @@ allprojects { configurations.all { // no cache for SNAPSHOT dependency resolutionStrategy.cacheChangingModulesFor 0, 'seconds' + + // Exclude conflicting kotlin stdlib versions + resolutionStrategy.eachDependency { details -> + if (details.requested.group == 'org.jetbrains.kotlin') { + if (details.requested.name == 'kotlin-stdlib-jdk8' || + details.requested.name == 'kotlin-stdlib-jdk7') { + details.useTarget "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" + details.because 'Unified kotlin stdlib to avoid conflicts' + } + } + } } } ext { - compile_sdk_version = 33 - build_tools_version = "30.0.3" + compile_sdk_version = 35 + build_tools_version = "35.0.0" min_sdk_version = 21 - target_sdk_version = 33 + target_sdk_version = 35 java_core_ver = "4.2.2" android_logger_ver = "1.3.6" jacksonversion= "2.11.2" annotations_ver = "1.2.0" junit_ver = "4.12" mockito_ver = "4.11.0" - mockito_ver_sdk_module = "3.6.28" + mockito_ver_sdk_module = "2.28.2" powermock_ver = "2.0.9" support_test_runner_ver = "0.5" dexmaker_ver = "1.4" @@ -127,7 +151,7 @@ nexusPublishing { password = System.getenv('MAVEN_CENTRAL_PASSWORD') } } - + } task ship() { @@ -192,6 +216,9 @@ configure(publishedProjects) { title = docTitle + // Set unique output directory for each variant + destinationDir = file("${project.buildDir}/docs/javadoc/${variant.name}") + options.links("http://docs.oracle.com/javase/7/docs/api/"); // First add all of your dependencies to the classpath, then add the android jars @@ -209,7 +236,7 @@ configure(publishedProjects) { android.libraryVariants.all { variant -> task("${variant.name}JavadocJar", type: Jar, dependsOn: "${variant.name}Javadoc") { - classifier = 'javadoc' + archiveClassifier = 'javadoc' from tasks["${variant.name}Javadoc"].destinationDir } @@ -219,13 +246,24 @@ configure(publishedProjects) { android.libraryVariants.all { variant -> task("${variant.name}SourcesJar", type: Jar) { - classifier = 'sources' + archiveClassifier = 'sources' from variant.javaCompileProvider.get().source } project.artifacts.add("archives", tasks["${variant.name}SourcesJar"]); } android { + compileOptions { + sourceCompatibility JavaVersion.VERSION_17 + targetCompatibility JavaVersion.VERSION_17 + } + + lint { + disable 'GradleDependency', 'VisibleForTesting', 'UnsafeProtectedBroadcastReceiver' + abortOnError true + warningsAsErrors false + } + publishing { singleVariant("release") { withSourcesJar() diff --git a/datafile-handler/build.gradle b/datafile-handler/build.gradle index 4e4d592d..43cfd62f 100644 --- a/datafile-handler/build.gradle +++ b/datafile-handler/build.gradle @@ -18,7 +18,8 @@ apply plugin: 'com.android.library' apply plugin: 'kotlin-android' android { - compileSdkVersion compile_sdk_version + namespace "com.optimizely.ab.android.datafile_handler" + compileSdk compile_sdk_version buildToolsVersion build_tools_version defaultConfig { @@ -38,10 +39,6 @@ android { testCoverageEnabled true } } - compileOptions { - sourceCompatibility JavaVersion.VERSION_17 - targetCompatibility JavaVersion.VERSION_17 - } } dependencies { @@ -63,9 +60,9 @@ dependencies { androidTestImplementation "androidx.test:core:$androidx_test_core" androidTestImplementation "androidx.test:core-ktx:$androidx_test_core" - androidTestImplementation "org.mockito:mockito-core:$mockito_ver" - androidTestImplementation "org.mockito:mockito-android:$mockito_ver" + androidTestImplementation "org.mockito:mockito-core:$mockito_ver_sdk_module" + androidTestImplementation "org.mockito:mockito-android:$mockito_ver_sdk_module" androidTestImplementation "com.noveogroup.android:android-logger:$android_logger_ver" androidTestImplementation "com.fasterxml.jackson.core:jackson-databind:$jacksonversion" - implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" + implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" } diff --git a/event-handler/build.gradle b/event-handler/build.gradle index 1684d7c1..6a01bc6d 100644 --- a/event-handler/build.gradle +++ b/event-handler/build.gradle @@ -18,7 +18,8 @@ apply plugin: 'com.android.library' apply plugin: 'kotlin-android' android { - compileSdkVersion compile_sdk_version + namespace "com.optimizely.ab.android.event_handler" + compileSdk compile_sdk_version buildToolsVersion build_tools_version defaultConfig { @@ -43,10 +44,7 @@ android { testCoverageEnabled true } } - compileOptions { - sourceCompatibility JavaVersion.VERSION_17 - targetCompatibility JavaVersion.VERSION_17 - } + buildToolsVersion build_tools_version } @@ -70,10 +68,10 @@ dependencies { androidTestImplementation "androidx.test:core:$androidx_test_core" androidTestImplementation "androidx.test:core-ktx:$androidx_test_core" - androidTestImplementation "org.mockito:mockito-core:$mockito_ver" - androidTestImplementation "org.mockito:mockito-android:$mockito_ver" + androidTestImplementation "org.mockito:mockito-core:$mockito_ver_sdk_module" + androidTestImplementation "org.mockito:mockito-android:$mockito_ver_sdk_module" androidTestImplementation "com.noveogroup.android:android-logger:$android_logger_ver" androidTestImplementation "com.fasterxml.jackson.core:jackson-databind:$jacksonversion" - implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" + implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" } diff --git a/event-handler/src/androidTest/java/com/optimizely/ab/android/event_handler/EventSQLiteOpenHelperTest.java b/event-handler/src/androidTest/java/com/optimizely/ab/android/event_handler/EventSQLiteOpenHelperTest.java index 6a3367ca..aaaf021e 100644 --- a/event-handler/src/androidTest/java/com/optimizely/ab/android/event_handler/EventSQLiteOpenHelperTest.java +++ b/event-handler/src/androidTest/java/com/optimizely/ab/android/event_handler/EventSQLiteOpenHelperTest.java @@ -47,6 +47,8 @@ public class EventSQLiteOpenHelperTest { public void setup() { context = InstrumentationRegistry.getInstrumentation().getTargetContext(); logger = mock(Logger.class); + // Delete any existing database to ensure onCreate is called + context.deleteDatabase(String.format(EventSQLiteOpenHelper.DB_NAME, "1")); } @After diff --git a/event-handler/src/main/java/com/optimizely/ab/android/event_handler/EventDispatcher.java b/event-handler/src/main/java/com/optimizely/ab/android/event_handler/EventDispatcher.java index 5efef77e..4ef98e62 100644 --- a/event-handler/src/main/java/com/optimizely/ab/android/event_handler/EventDispatcher.java +++ b/event-handler/src/main/java/com/optimizely/ab/android/event_handler/EventDispatcher.java @@ -39,7 +39,7 @@ * * This abstraction makes unit testing much simpler */ -@VisibleForTesting(otherwise = VisibleForTesting.PROTECTED) +@VisibleForTesting(otherwise = VisibleForTesting.PACKAGE_PRIVATE) public class EventDispatcher { @NonNull private final Context context; diff --git a/gradle.properties b/gradle.properties index f2a434a1..ffde98ef 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,3 @@ android.enableJetifier=true android.useAndroidX=true org.gradle.jvmargs=-Xmx1g -android.disableAutomaticComponentCreation=true \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 7ce850e5..e52d7fba 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -4,4 +4,4 @@ distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME org.gradle.jvmargs=-Xmx1g zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip diff --git a/odp/build.gradle b/odp/build.gradle index fc7b85de..98aba716 100644 --- a/odp/build.gradle +++ b/odp/build.gradle @@ -19,7 +19,8 @@ apply plugin: 'kotlin-android' apply plugin: 'org.jlleitschuh.gradle.ktlint' android { - compileSdkVersion compile_sdk_version + namespace "com.optimizely.ab.android.odp" + compileSdk compile_sdk_version buildToolsVersion build_tools_version defaultConfig { @@ -41,21 +42,13 @@ android { testCoverageEnabled true } } - compileOptions { - sourceCompatibility JavaVersion.VERSION_17 - targetCompatibility JavaVersion.VERSION_17 - } buildToolsVersion build_tools_version - - kotlinOptions { - jvmTarget = '1.8' - } } dependencies { api project(':shared') implementation "androidx.annotation:annotation:$annotations_ver" - implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" + implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" implementation "androidx.work:work-runtime:$work_runtime" // Add SLF4J API for Logger interface implementation "org.slf4j:slf4j-api:$slf4j_ver" @@ -74,7 +67,7 @@ dependencies { androidTestImplementation "androidx.test:core:$androidx_test_core" androidTestImplementation "androidx.test:core-ktx:$androidx_test_core" - androidTestImplementation "org.mockito:mockito-core:$mockito_ver" - androidTestImplementation "org.mockito:mockito-android:$mockito_ver" + androidTestImplementation "org.mockito:mockito-core:$mockito_ver_sdk_module" + androidTestImplementation "org.mockito:mockito-android:$mockito_ver_sdk_module" androidTestImplementation "org.slf4j:slf4j-api:$slf4j_ver" } diff --git a/shared/build.gradle b/shared/build.gradle index 2bab5c6d..1f47deca 100644 --- a/shared/build.gradle +++ b/shared/build.gradle @@ -18,7 +18,8 @@ apply plugin: 'com.android.library' apply plugin: 'kotlin-android' android { - compileSdkVersion compile_sdk_version + namespace "com.optimizely.ab.android.shared" + compileSdk compile_sdk_version buildToolsVersion build_tools_version defaultConfig { @@ -40,10 +41,6 @@ android { testCoverageEnabled true } } - compileOptions { - sourceCompatibility JavaVersion.VERSION_17 - targetCompatibility JavaVersion.VERSION_17 - } buildToolsVersion build_tools_version } @@ -53,7 +50,7 @@ dependencies { } implementation "androidx.annotation:annotation:$annotations_ver" - implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" + implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" implementation "androidx.work:work-runtime:$work_runtime" // the default json parser for java-sdk core-api (app can exclude it to replace with other parsers) implementation "com.google.code.gson:gson:$gson_ver" @@ -74,8 +71,8 @@ dependencies { androidTestImplementation "androidx.test:core:$androidx_test_core" androidTestImplementation "androidx.test:core-ktx:$androidx_test_core" - androidTestImplementation "org.mockito:mockito-core:$mockito_ver" - androidTestImplementation "org.mockito:mockito-android:$mockito_ver" + androidTestImplementation "org.mockito:mockito-core:$mockito_ver_sdk_module" + androidTestImplementation "org.mockito:mockito-android:$mockito_ver_sdk_module" androidTestImplementation "com.noveogroup.android:android-logger:$android_logger_ver" androidTestImplementation "com.fasterxml.jackson.core:jackson-databind:$jacksonversion" } diff --git a/test-app/build.gradle b/test-app/build.gradle index 86653c09..f242fc60 100644 --- a/test-app/build.gradle +++ b/test-app/build.gradle @@ -2,6 +2,7 @@ apply plugin: 'com.android.application' apply plugin: 'kotlin-android' android { + namespace "com.optimizely.ab.android.test_app" compileSdkVersion compile_sdk_version buildToolsVersion build_tools_version @@ -11,7 +12,6 @@ android { targetSdkVersion target_sdk_version versionCode 1 versionName "1.0.2" - testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner' } testOptions { unitTests.returnDefaultValues = true @@ -22,6 +22,8 @@ android { minifyEnabled true debuggable false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'test-app-proguard-rules.pro' + // Disable minification for Android tests to avoid missing class issues with mockito + testProguardFiles getDefaultProguardFile('proguard-android.txt'), 'test-app-proguard-rules.pro' } release { minifyEnabled true @@ -29,10 +31,16 @@ android { signingConfig signingConfigs.debug } } + compileOptions { sourceCompatibility JavaVersion.VERSION_17 targetCompatibility JavaVersion.VERSION_17 } + + kotlinOptions { + jvmTarget = '17' + } + packagingOptions { resources { excludes += ['META-INF/LICENSE.txt', 'META-INF/NOTICE.txt', 'META-INF/LICENSE', 'META-INF/NOTICE'] @@ -70,25 +78,8 @@ dependencies { testImplementation "junit:junit:$junit_ver" testImplementation "org.mockito:mockito-core:$mockito_ver" testImplementation "com.noveogroup.android:android-logger:$android_logger_ver" - // testImplementation 'com.optimizely.ab:android-sdk:1.0.0' testImplementation project(':android-sdk') - androidTestImplementation "androidx.work:work-testing:$work_runtime" - androidTestImplementation "androidx.test.ext:junit:$androidx_test_junit" - androidTestImplementation "androidx.test.espresso:espresso-core:$espresso_ver" - // Set this dependency to use JUnit 4 rules - androidTestImplementation "androidx.test:rules:$androidx_test_rules" - androidTestImplementation "androidx.test:core:$androidx_test_core" - androidTestImplementation "androidx.test:core-ktx:$androidx_test_core" - - androidTestImplementation "org.mockito:mockito-core:$mockito_ver" - androidTestImplementation "com.crittercism.dexmaker:dexmaker:$dexmaker_ver" - androidTestImplementation "com.crittercism.dexmaker:dexmaker-dx:$dexmaker_ver" - androidTestImplementation "com.crittercism.dexmaker:dexmaker-mockito:$dexmaker_ver" - // androidTestImplementation 'com.optimizely.ab:android-sdk:1.0.0' - androidTestImplementation project(':android-sdk') - androidTestImplementation project(path: ':shared') - androidTestImplementation "com.fasterxml.jackson.core:jackson-databind:$jacksonversion" - implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" + implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" } diff --git a/user-profile/build.gradle b/user-profile/build.gradle index 238263fe..d501c8ed 100644 --- a/user-profile/build.gradle +++ b/user-profile/build.gradle @@ -18,7 +18,8 @@ apply plugin: 'com.android.library' apply plugin: 'kotlin-android' android { - compileSdkVersion compile_sdk_version + namespace "com.optimizely.ab.android.user_profile" + compileSdk compile_sdk_version buildToolsVersion build_tools_version defaultConfig { @@ -38,17 +39,13 @@ android { testCoverageEnabled true } } - compileOptions { - sourceCompatibility JavaVersion.VERSION_17 - targetCompatibility JavaVersion.VERSION_17 - } } dependencies { api project(':shared') implementation "androidx.annotation:annotation:$annotations_ver" - implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" + implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" compileOnly "com.noveogroup.android:android-logger:$android_logger_ver" @@ -64,8 +61,8 @@ dependencies { androidTestImplementation "androidx.test:core:$androidx_test_core" androidTestImplementation "androidx.test:core-ktx:$androidx_test_core" - androidTestImplementation "org.mockito:mockito-core:$mockito_ver" - androidTestImplementation "org.mockito:mockito-android:$mockito_ver" + androidTestImplementation "org.mockito:mockito-core:$mockito_ver_sdk_module" + androidTestImplementation "org.mockito:mockito-android:$mockito_ver_sdk_module" androidTestImplementation "com.noveogroup.android:android-logger:$android_logger_ver" androidTestImplementation "com.fasterxml.jackson.core:jackson-databind:$jacksonversion" }