taler-android

Android apps for GNU Taler (wallet, PoS, cashier)
Log | Files | Refs | README | LICENSE

build.gradle (6335B)


      1 import groovy.json.JsonOutput
      2 
      3 plugins {
      4     id 'com.android.application'
      5     id 'kotlin-android'
      6     id 'kotlinx-serialization'
      7     id 'org.jlleitschuh.gradle.ktlint' version '14.2.0'
      8     id "org.jetbrains.kotlin.plugin.compose" version "$kotlin_version"
      9 }
     10 
     11 ktlint {
     12     version = '1.8.0'
     13     filter {
     14         exclude '**/build/**'
     15     }
     16 }
     17 
     18 apply from: 'formatting.gradle'
     19 
     20 tasks.withType(org.jlleitschuh.gradle.ktlint.tasks.KtLintFormatTask).configureEach {
     21     dependsOn 'formatKotlinLayout'
     22 }
     23 
     24 repositories {
     25     maven {
     26         url 'https://maven.sumup.com/releases'
     27         content {
     28             includeGroupByRegex 'com\\.sumup(\\..*)?'
     29             includeGroup 'net.sf.smc'
     30         }
     31     }
     32 }
     33 
     34 def localAffiliateKey = providers.fileContents(rootProject.layout.projectDirectory.file('.env'))
     35     .asText.orElse('').map { content ->
     36         def entry = content.readLines().find { it ==~ /\s*(?:export\s+)?SUMUP_AFFILIATE_KEY\s*=.*/ }
     37         if (entry == null) return ''
     38         def match = entry =~ /\s*(?:export\s+)?SUMUP_AFFILIATE_KEY\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s#]*))\s*(?:#.*)?/
     39         if (!match.matches()) throw new GradleException('Invalid SUMUP_AFFILIATE_KEY entry in .env')
     40         return match[0][1] ?: match[0][2] ?: match[0][3] ?: ''
     41     }
     42 def sumupAffiliateKey = providers.environmentVariable('SUMUP_AFFILIATE_KEY')
     43     .orElse(localAffiliateKey).get()
     44 
     45 android {
     46     namespace 'net.taler.merchantpos'
     47     compileSdkVersion 37
     48 
     49     defaultConfig {
     50         applicationId "net.taler.merchantpos"
     51         minSdkVersion 26
     52         targetSdkVersion 37
     53         versionCode 30
     54         versionName "1.7.0"
     55         testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
     56 
     57         buildConfigField("String", "BACKEND_API_VERSION", "\"20:0:8\"")
     58         buildConfigField('String', 'SUMUP_AFFILIATE_KEY', JsonOutput.toJson(sumupAffiliateKey))
     59     }
     60 
     61     // The androidTest variant is only created for the testBuildType, and
     62     // enableAndroidTestCoverage only instruments the app's classes when such a
     63     // variant exists -- so the simulator's build type has to be the one.
     64     // Nothing else in this module has instrumented tests, so this costs
     65     // nothing but moves which unit-test task :merchant-terminal:check runs.
     66     testBuildType "sim"
     67 
     68     buildTypes {
     69         release {
     70             minifyEnabled true
     71             proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
     72         }
     73         debug {
     74             minifyEnabled minify_debug
     75             proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
     76         }
     77         // Build type for pos-simulator/, the emulator-driven exploration
     78         // harness.  Same application id as debug -- the simulator drives the
     79         // same package a developer would install -- plus JaCoCo
     80         // instrumentation and the hooks in src/sim.  Never published.
     81         sim {
     82             initWith debug
     83             signingConfig signingConfigs.debug
     84             minifyEnabled false
     85             enableAndroidTestCoverage true
     86             // The emulator is not the only thing that covers this app: the
     87             // module has ~290 JVM unit tests, and without this their coverage
     88             // is invisible to pos-simulator's report -- so the report invites
     89             // us to spend emulator time re-covering what a unit test already
     90             // reaches.  coverage/report.sh merges both.
     91             enableUnitTestCoverage true
     92             matchingFallbacks = ['debug']
     93         }
     94     }
     95 
     96     compileOptions {
     97         coreLibraryDesugaringEnabled true
     98         sourceCompatibility = JavaVersion.VERSION_17
     99         targetCompatibility = JavaVersion.VERSION_17
    100     }
    101 
    102     kotlinOptions {
    103         jvmTarget = "17"
    104     }
    105 
    106     buildFeatures {
    107         buildConfig = true
    108         compose = true
    109     }
    110 
    111     testOptions {
    112         unitTests {
    113             includeAndroidResources = true
    114         }
    115     }
    116     packagingOptions {
    117         resources {
    118             excludes += ['META-INF/common.kotlin_module', 'META-INF/*.kotlin_module']
    119         }
    120     }
    121 
    122     lint {
    123         abortOnError true
    124         disable 'WrongConstant'
    125         ignoreWarnings false
    126     }
    127 }
    128 
    129 dependencies {
    130     coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:2.1.5'
    131     implementation 'com.sumup:merchant-sdk:7.1.0'
    132     implementation project(":merchant-lib")
    133     implementation project(":taler-kotlin-android")
    134 
    135     implementation "com.google.android.material:material:$material_version"
    136     implementation "androidx.constraintlayout:constraintlayout:$constraintlayout_version"
    137     implementation platform('androidx.compose:compose-bom:2026.06.01')
    138     implementation 'androidx.compose.material3:material3'
    139     implementation 'androidx.compose.material:material-icons-extended'
    140     implementation 'androidx.compose.ui:ui'
    141     implementation 'androidx.compose.ui:ui-tooling-preview'
    142     implementation "androidx.compose.runtime:runtime-livedata"
    143     implementation 'androidx.activity:activity-compose:1.13.0'
    144     implementation "androidx.navigation:navigation-compose:$nav_version"
    145     implementation "androidx.fragment:fragment-ktx:1.9.0"
    146     implementation "androidx.recyclerview:recyclerview:1.4.0"
    147     implementation "androidx.recyclerview:recyclerview-selection:1.2.0"
    148 
    149     // CameraX
    150     implementation "androidx.camera:camera-camera2:1.6.2"
    151     implementation "androidx.camera:camera-lifecycle:1.6.2"
    152     implementation "androidx.camera:camera-view:1.6.2"
    153 
    154     // ZXING core – on-device barcode/QR detector
    155     implementation "com.google.zxing:core:3.5.4"
    156 
    157     implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.2.0"
    158 
    159     testImplementation 'androidx.test.ext:junit:1.3.0'
    160     testImplementation 'org.robolectric:robolectric:4.16.1'
    161 
    162     debugImplementation 'androidx.compose.ui:ui-tooling'
    163     simImplementation 'androidx.compose.ui:ui-tooling'
    164 
    165     // Only the "sim" build type has instrumented tests; see
    166     // src/androidTestSim and pos-simulator/README.md.  They exist so that AGP
    167     // creates an androidTest variant, which is what makes
    168     // enableAndroidTestCoverage instrument the app's classes.
    169     androidTestSimImplementation 'junit:junit:4.13.2'
    170     androidTestSimImplementation 'androidx.test:runner:1.7.0'
    171     androidTestSimImplementation 'androidx.test.ext:junit:1.3.0'
    172 }