/****************************************************************************** * Corona-Warn-App * * * * SAP SE and all other contributors / * * copyright owners license this file to you under the Apache * * License, Version 2.0 (the "License"); you may not use this * * file except in compliance with the License. * * You may obtain a copy of the License at * * * * http://www.apache.org/licenses/LICENSE-2.0 * * * * Unless required by applicable law or agreed to in writing, * * software distributed under the License is distributed on an * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * * KIND, either express or implied. See the License for the * * specific language governing permissions and limitations * * under the License. * ******************************************************************************/ apply plugin: 'com.android.application' apply plugin: 'kotlin-android' apply plugin: 'kotlin-android-extensions' apply plugin: 'kotlin-kapt' apply plugin: "androidx.navigation.safeargs.kotlin" apply plugin: 'jacoco' def environmentExtractor = { File path -> def rawJson = path.text def escapedJson = rawJson.replace("\"", "\\\"").replace("\n", "").replace("\r", "") return "\"${escapedJson}\"" } android { compileSdkVersion 29 buildToolsVersion "29.0.3" defaultConfig { applicationId 'de.rki.coronawarnapp' minSdkVersion 23 targetSdkVersion 29 versionCode 45 versionName "1.5.0" testInstrumentationRunner "testhelpers.TestApplicationUIRunner" resConfigs "de", "en", "tr", "bg", "pl", "ro" def prodEnvJson = environmentExtractor(file("../prod_environments.json")) buildConfigField "String", "ENVIRONMENT_JSONDATA", prodEnvJson def devEnvironmentFile = file("../test_environments.json") if (devEnvironmentFile.exists()) { def devEnvJson = environmentExtractor(devEnvironmentFile) buildConfigField "String", "ENVIRONMENT_JSONDATA", devEnvJson } javaCompileOptions { annotationProcessorOptions { arguments += ["room.schemaLocation": "$projectDir/schemas".toString()] } } } def signingPropFile = file("../keystore.properties") if (signingPropFile.canRead()) { Properties signingProps = new Properties() signingProps.load(new FileInputStream(signingPropFile)) signingConfigs { release { storeFile file(signingProps['release.storePath']) keyAlias signingProps['release.keyAlias'] storePassword signingProps['release.storePassword'] keyPassword signingProps['release.keyPassword'] } } } buildTypes { debug { } release { minifyEnabled true shrinkResources true proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' if (signingPropFile.canRead()) { signingConfig signingConfigs.release } } } flavorDimensions "version" productFlavors { device { dimension "version" resValue "string", "app_name", "Corona-Warn" ext { envTypeDefault = [debug: "INT", release: "PROD"] } } deviceForTesters { // Contains test fragments dimension "version" resValue "string", "app_name", "CWA TEST" applicationIdSuffix '.dev' ext { envTypeDefault = [debug: "INT", release: "WRU-XD"] } } } applicationVariants.all { variant -> def flavor = variant.productFlavors[0] def typeName = variant.buildType.name // debug/release variant.buildConfigField "String", "ENVIRONMENT_TYPE_DEFAULT", "\"${flavor.envTypeDefault[typeName]}\"" } buildFeatures { dataBinding true viewBinding true } compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } kotlinOptions { jvmTarget = "1.8" } def jvmCompilerArgs = ["-Xno-kotlin-nothing-value-exception"] tasks.withType(org.jetbrains.kotlin.gradle.dsl.KotlinJvmCompile) { kotlinOptions { freeCompilerArgs = jvmCompilerArgs } } lintOptions { checkAllWarnings = true } testOptions { unitTests.all { useJUnitPlatform() if (project.hasProperty('testFilter')) { List<String> props = project.getProperties().get("testFilter").split("\\s+") props.each { def replaced = it .replaceFirst("^(Corona-Warn-App/src/test.*/java/)(.+)\$", "**/\$2") .replace(".kt", ".class") project.logger.lifecycle("testFilter File: before=$it, after=$replaced") include(replaced) } } } unitTests { includeAndroidResources = true returnDefaultValues = true } } kapt { useBuildCache true includeCompileClasspath = false } dexOptions { preDexLibraries true } packagingOptions { exclude "**/module-info.class" exclude 'NOTICE' exclude 'LICENSE' exclude 'CODEOWNERS' exclude 'README.md' exclude 'CODE_OF_CONDUCT.md' } sourceSets { deviceForTesters { kotlin { srcDirs = ['src/deviceForTesters'] } res { srcDirs 'src/deviceForTesters/res', 'src/deviceForTesters/res/navigation' } } device { kotlin { srcDirs = ['src/device'] } } test { java.srcDirs += "$projectDir/src/testShared/java" } androidTest { java.srcDirs += "$projectDir/src/testShared/java" } } } task jacocoTestReportDeviceRelease(type: JacocoReport, dependsOn: 'testDeviceReleaseUnitTest') { group = "Reporting" description = "Generate Jacoco coverage reports for the DeviceRelease build." reports { html.enabled = false xml { enabled = true destination file("$buildDir/reports/jacoco/deviceRelease/jacoco.xml") } } def excludes = [ '**/R.class', '**/R$*.class', '**/BuildConfig.*', '**/Manifest*.*', '**/*Test*.*', 'android/**/*.*', '**/*$$*', ] def classPaths = [ "**/intermediates/classes/deviceRelease/**", "**/intermediates/javac/deviceRelease/*/classes/**", // Android Gradle Plugin 3.2.x support. "**/intermediates/javac/deviceRelease/classes/**", // Android Gradle Plugin 3.4 and 3.5 support. "**/tmp/kotlin-classes/deviceRelease/**" ] def debugTree = fileTree(dir: "$buildDir", includes: classPaths, excludes: excludes) def mainSrc = "src/main/java" getSourceDirectories().from(files([mainSrc])) getClassDirectories().from(files([debugTree])) getExecutionData().from(fileTree(dir: "$buildDir", includes: ["jacoco/testDeviceReleaseUnitTest.exec"])) } dependencies { // KOTLIN implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.7" implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" // ANDROID STANDARD implementation 'androidx.appcompat:appcompat:1.1.0' implementation 'androidx.core:core-ktx:1.3.0' implementation 'com.google.android.material:material:1.1.0' implementation 'androidx.constraintlayout:constraintlayout:1.1.3' implementation 'androidx.navigation:navigation-fragment-ktx:2.2.2' implementation 'androidx.navigation:navigation-ui-ktx:2.2.2' implementation 'androidx.legacy:legacy-support-v4:1.0.0' implementation 'androidx.preference:preference:1.1.1' implementation 'androidx.work:work-runtime-ktx:2.3.4' implementation 'androidx.lifecycle:lifecycle-common-java8:2.2.0' implementation 'androidx.lifecycle:lifecycle-process:2.2.0' implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.2.0' implementation 'androidx.lifecycle:lifecycle-viewmodel-savedstate:2.2.0' implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0' implementation 'androidx.annotation:annotation:1.1.0' implementation "androidx.recyclerview:recyclerview:1.1.0" implementation "androidx.recyclerview:recyclerview-selection:1.1.0-rc02" // DAGGER implementation 'com.google.dagger:dagger:2.28.1' implementation 'com.google.dagger:dagger-android:2.28.1' implementation 'com.google.dagger:dagger-android-support:2.28.1' kapt 'com.google.dagger:dagger-compiler:2.28.1' kapt 'com.google.dagger:dagger-android-processor:2.28.1' kaptAndroidTest 'com.google.dagger:dagger-compiler:2.28.1' compileOnly 'com.squareup.inject:assisted-inject-annotations-dagger2:0.5.2' kapt 'com.squareup.inject:assisted-inject-processor-dagger2:0.5.2' // QR implementation('com.journeyapps:zxing-android-embedded:4.1.0') { transitive = false } // noinspection GradleDependency - needed for SDK 23 compatibility, in combination with com.journeyapps:zxing-android-embedded:4.1.0 implementation 'com.google.zxing:core:3.3.0' //ENA implementation files('libs\\play-services-nearby-exposurenotification-1.6.1-eap.aar') // Testing testImplementation "androidx.arch.core:core-testing:2.1.0" testImplementation('org.robolectric:robolectric:4.4') { exclude group: 'com.google.protobuf' } testImplementation "io.mockk:mockk:1.10.0" testImplementation "com.squareup.okhttp3:mockwebserver:4.8.0" testImplementation 'org.hamcrest:hamcrest-library:2.2' testImplementation 'org.jetbrains.kotlinx:kotlinx-coroutines-test:1.3.9' // Testing - jUnit4 testImplementation 'junit:junit:4.13' testImplementation "org.junit.vintage:junit-vintage-engine:5.6.2" // Testing - jUnit5 testImplementation "org.junit.jupiter:junit-jupiter-api:5.6.2" testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:5.6.2" testImplementation "org.junit.jupiter:junit-jupiter-params:5.6.2" testImplementation "io.kotest:kotest-runner-junit5:4.2.0" testImplementation "io.kotest:kotest-assertions-core-jvm:4.2.0" testImplementation "io.kotest:kotest-property-jvm:4.2.0" androidTestImplementation "io.kotest:kotest-assertions-core-jvm:4.2.0" androidTestImplementation "io.kotest:kotest-property-jvm:4.2.0" // Testing - Instrumentation androidTestImplementation 'junit:junit:4.13' androidTestImplementation 'androidx.test:runner:1.2.0' androidTestImplementation 'androidx.test.ext:junit:1.1.1' androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' androidTestImplementation 'androidx.test:rules:1.2.0' androidTestImplementation 'androidx.test.ext:truth:1.2.0' androidTestImplementation 'androidx.test.ext:junit:1.1.1' androidTestImplementation 'androidx.work:work-testing:2.3.4' androidTestImplementation "io.mockk:mockk-android:1.10.0" debugImplementation 'androidx.fragment:fragment-testing:1.2.5' // Play Services implementation 'com.google.android.play:core:1.7.3' implementation 'com.google.android.gms:play-services-base:17.3.0' implementation 'com.google.android.gms:play-services-basement:17.3.0' implementation 'com.google.android.gms:play-services-safetynet:17.0.0' implementation 'com.google.android.gms:play-services-tasks:17.1.0' // HTTP implementation 'com.squareup.retrofit2:retrofit:2.9.0' implementation 'com.squareup.retrofit2:converter-gson:2.9.0' implementation('com.squareup.retrofit2:converter-protobuf:2.9.0') { exclude group: 'com.google.protobuf', module: 'protobuf-java' } implementation("com.squareup.okhttp3:logging-interceptor:4.7.2") implementation 'com.squareup.okhttp3:okhttp:4.7.2' // PERSISTENCE def room_version = "2.2.5" implementation "androidx.room:room-runtime:$room_version" implementation "androidx.room:room-ktx:$room_version" implementation "androidx.room:room-guava:$room_version" kapt "androidx.room:room-compiler:$room_version" implementation "androidx.sqlite:sqlite:2.1.0" // UTILS implementation project(":Server-Protocol-Buffer") implementation 'com.google.code.gson:gson:2.8.6' implementation 'com.google.guava:guava:29.0-android' implementation 'joda-time:joda-time:2.10.6' // SECURITY implementation "androidx.security:security-crypto:1.0.0-rc03" implementation 'net.zetetic:android-database-sqlcipher:4.4.0' implementation 'org.conscrypt:conscrypt-android:2.4.0' // LOGGING implementation 'com.jakewharton.timber:timber:4.7.1@aar' // ANIMATIONS implementation "com.airbnb.android:lottie:3.4.1" }