build.gradle
///////////////////////////////////////////////////////////////////////////////
// Setup necessary imports
///////////////////////////////////////////////////////////////////////////////
import groovy.json.JsonSlurper
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// Setup Gradle
///////////////////////////////////////////////////////////////////////////////
buildscript {
// Setup necessary repositories to get third party dependencies
repositories {
google()
mavenCentral()
mavenLocal()
gradlePluginPortal()
maven { url = 'https://maven.google.com' }
maven { url = 'https://repo1.maven.org/maven2/' }
maven { url = 'https://plugins.gradle.org/m2/'}
maven { url = 'https://jitpack.io' }
}
// This block encapsulates custom properties and makes them available to all
// modules in the project.
ext {
systemTestType = System.getProperty('testType', 'debug')
final def customAbiFilters = System.getProperty('abiFilters', '["x86","x86_64"]')
systemAbiFilters = new JsonSlurper().parseText(customAbiFilters) as String[]
// The default minimum Android API version possible is 14 due to compatibility with Appcompat dependency.
androidApiVersion = System.getProperty('androidApiVersion', '14')
final def androidApiVersionArray = androidApiVersion.split("\\.").collect()
androidApiVersionValue = androidApiVersionArray[0] as Float
if (androidApiVersionValue >= 21) {
androidX_appcompat_version = '1.7.0'
ndk_version = '27.2.12479018'
}
if (androidApiVersionValue >= 19) {
androidX_test_junit_version = '1.2.1'
androidX_test_runner_version = '1.6.1'
androidX_test_espresso_version = '3.6.1'
androidX_tracing_version = '1.2.0'
if (project.properties["ndk_version"] == null) {
ndk_version = '25.2.9519653'
}
}
if (androidApiVersionValue >= 16) {
gradle_version = '8.8.0'
} else {
gradle_version = '8.2.2'
}
if (project.properties["androidX_test_espresso_version"] == null) {
androidX_test_espresso_version = '3.5.1'
}
if (project.properties["androidX_test_junit_version"] == null) {
androidX_test_junit_version = '1.1.5'
}
if (project.properties["androidX_test_runner_version"] == null) {
androidX_test_runner_version = '1.5.2'
}
if (project.properties["androidX_appcompat_version"] == null) {
androidX_appcompat_version = '1.6.1'
}
if (project.properties["ndk_version"] == null) {
ndk_version = '23.2.8568313'
}
if (project.properties["androidX_tracing_version"] == null) {
androidX_tracing_version = '1.1.0'
}
final def gradleVersionArray = gradle_version.split("\\.").collect()
gradleVersionValue = gradleVersionArray[0] + '.' + gradleVersionArray[1] as Float
// Test dependencies
jacoco_version = '0.8.12'
// Unit tests dependencies
powermock_version = '2.0.9'
}
dependencies {
final def currentOS = System.getProperty("os.name")
println("OS: " + currentOS)
// Compatibility matrix: https://developer.android.com/build/releases/gradle-plugin#android_gradle_plugin_and_android_studio_compatibility
classpath "com.android.tools.build:gradle:${gradle_version}"
classpath 'org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:6.0.1.5171'
classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:2.1.0'
classpath 'com.github.ben-manes:gradle-versions-plugin:0.51.0'
/* To confirm JaCoCo version run: $ sh gradlew buildEnvironment */
/* Resolves issue of incorrect version use in one of jacoco/android plugin inner tasks */
classpath "org.jacoco:org.jacoco.core:${jacoco_version}"
classpath "org.jacoco:org.jacoco.report:${jacoco_version}"
classpath "org.jacoco:org.jacoco.agent:${jacoco_version}"
// Required for sonarqube-gradle-plugin:v6
classpath 'org.bouncycastle:bcutil-jdk18on:1.79'
}
}
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// Setup necessary repositories to get third party dependencies
///////////////////////////////////////////////////////////////////////////////
allprojects {
repositories {
google()
mavenCentral()
mavenLocal()
gradlePluginPortal()
maven { url = 'https://maven.google.com' }
maven { url = 'https://mvnrepository.com' }
maven { url = 'https://dl.google.com/dl/android/maven2/' }
maven { url = 'https://plugins.gradle.org/m2/'}
maven { url = 'https://jitpack.io' }
}
}
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// Allow to use different versions of Gradle depending on the Android API version
///////////////////////////////////////////////////////////////////////////////
tasks.named('wrapper', Wrapper) {it ->
println('Setting Gradle wrapper version')
it.distributionType = Wrapper.DistributionType.BIN
if (androidApiVersionValue >= 16) {
it.gradleVersion = '8.12'
} else {
it.gradleVersion = '8.7'
}
var urlPrefix = 'https://services.gradle.org/distributions/'
it.distributionUrl = urlPrefix + 'gradle-' + it.gradleVersion + '-' + it.distributionType.name().toLowerCase() + '.zip'
println('Gradle wrapper version: ' + it.gradleVersion)
}
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
repositories {
google()
mavenCentral()
mavenLocal()
gradlePluginPortal()
maven { url = 'https://maven.google.com' }
maven { url = 'https://mvnrepository.com' }
maven { url = 'https://dl.google.com/dl/android/maven2/' }
maven { url = 'https://plugins.gradle.org/m2/'}
maven { url = 'https://jitpack.io' }
}