From b748eb360eca300955ac3223818f83a4d6cd743e Mon Sep 17 00:00:00 2001 From: Dan Albert Date: Wed, 8 May 2024 15:54:00 -0700 Subject: [PATCH] Migrate unit-test to convention plugin. --- gradle/libs.versions.toml | 4 ++++ unit-test/app/build.gradle | 40 ++++++++++++-------------------------- 2 files changed, 16 insertions(+), 28 deletions(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 42b584663..2bd83e139 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -8,12 +8,14 @@ espressoCore = "3.5.1" androidxConstraintLayout = "2.1.4" androidxCore = "1.9.0" androidxGames = "2.1.0-alpha01" +androidxJUnitGTest = "1.0.0-alpha01" appcompat = "1.6.1" material = "1.12.0" jetbrainsKotlinJvm = "1.7.21" oboe = "1.6.1" curl = "7.79.1-beta-1" +googletest = "1.11.0-beta-1" jsoncpp = "1.9.5-beta-1" openssl = "1.1.1l-beta-1" @@ -24,6 +26,7 @@ espresso-core = { group = "androidx.test.espresso", name = "espresso-core", vers androidx-constraintlayout = { group = "androidx.constraintlayout", name = "constraintlayout", version.ref = "androidxConstraintLayout" } androidx-core = { group = "androidx.core", name = "core", version.ref = "androidxCore" } androidx-games-gameactivity = { group = "androidx.games", name = "games-activity", version.ref = "androidxGames" } +androidx-junit-gtest = { group = "androidx.test.ext", name = "junit-gtest", version.ref = "androidxJUnitGTest" } appcompat = { group = "androidx.appcompat", name = "appcompat", version.ref = "appcompat" } material = { group = "com.google.android.material", name = "material", version.ref = "material" } kotlin-gradlePlugin = { group = "org.jetbrains.kotlin", name = "kotlin-gradle-plugin", version.ref = "kotlin" } @@ -31,6 +34,7 @@ oboe = { group = "com.google.oboe", name = "oboe", version.ref = "oboe" } kotlinx-coroutines-core = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-core", version.ref = "kotlinxCoroutines" } kotlinx-coroutines-android = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-android", version.ref = "kotlinxCoroutines" } curl = { group = "com.android.ndk.thirdparty", name = "curl", version.ref = "curl" } +googletest = { group = "com.android.ndk.thirdparty", name = "googletest", version.ref = "googletest" } jsoncpp = { group = "com.android.ndk.thirdparty", name = "jsoncpp", version.ref = "jsoncpp" } openssl = { group = "com.android.ndk.thirdparty", name = "openssl", version.ref = "openssl" } diff --git a/unit-test/app/build.gradle b/unit-test/app/build.gradle index e55865609..5e6d1480f 100644 --- a/unit-test/app/build.gradle +++ b/unit-test/app/build.gradle @@ -1,44 +1,30 @@ plugins { - id 'com.android.application' - id 'org.jetbrains.kotlin.android' + id "ndksamples.android.application" + id "ndksamples.android.kotlin" } android { namespace 'com.example.unittest' - compileSdk 33 defaultConfig { applicationId "com.example.unittest" - minSdk 21 - targetSdk 33 versionCode 1 versionName "1.0" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' - } - } - compileOptions { - sourceCompatibility JavaVersion.VERSION_1_8 - targetCompatibility JavaVersion.VERSION_1_8 - } - kotlinOptions { - jvmTarget = '1.8' - } externalNativeBuild { cmake { path file('src/main/cpp/CMakeLists.txt') } } + buildFeatures { viewBinding true prefab true } + packagingOptions { // Libraries that are wrongly included in the junit-gtest AAR that will // end up in our APK if we don't explicitly exclude them. @@ -49,14 +35,12 @@ android { } dependencies { - - implementation 'androidx.core:core-ktx:1.7.0' - implementation 'androidx.appcompat:appcompat:1.5.1' - implementation 'com.google.android.material:material:1.5.0' - implementation 'androidx.constraintlayout:constraintlayout:2.1.4' - implementation 'androidx.test.ext:junit-gtest:1.0.0-alpha01' - implementation 'com.android.ndk.thirdparty:googletest:1.11.0-beta-1' - testImplementation 'junit:junit:4.13.2' - androidTestImplementation 'androidx.test.ext:junit:1.1.3' - androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0' + implementation libs.appcompat + implementation libs.material + implementation libs.androidx.constraintlayout + implementation libs.androidx.junit.gtest + implementation libs.googletest + testImplementation libs.junit + androidTestImplementation libs.ext.junit + androidTestImplementation libs.espresso.core } \ No newline at end of file