0
0
mirror of https://github.com/ankidroid/Anki-Android.git synced 2024-09-20 03:52:15 +02:00
Anki-Android/build.gradle
Mike Hardy d4ed62de72
Dependency updates 20231031 (#14626)
* build(deps): bump org.robolectric:robolectric from 4.10.3 to 4.11 (#14617)

* build(deps): bump org.robolectric:robolectric from 4.10.3 to 4.11

Bumps [org.robolectric:robolectric](https://github.com/robolectric/robolectric) from 4.10.3 to 4.11.
- [Release notes](https://github.com/robolectric/robolectric/releases)
- [Commits](https://github.com/robolectric/robolectric/compare/robolectric-4.10.3...robolectric-4.11)

---
updated-dependencies:
- dependency-name: org.robolectric:robolectric
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

* build(deps): remove robolectric SDK pin so it auto-tracks, alter SDK downloads

this was only necessary before because there was an upstream bug in robolectric 4.10.3,
now that 4.11.0 is out, we can use robolectric SDK 33 and in fact move forwrd to 34

this implies that our SDK pre-downloads should be altered as well, these are the ones
downloaded now on clean runs

* test: adjust to match robolectric 4.11 needs

- one test disable: API longer responds correctly, but manual test was successful
- one test adjustement to reflect typo fix in robolectric APIs

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Mike Hardy <github@mikehardy.net>

* build(deps): bump kotlin_version from 1.9.10 to 1.9.20

Bumps `kotlin_version` from 1.9.10 to 1.9.20.

Updates `org.jetbrains.kotlin.jvm` from 1.9.10 to 1.9.20
- [Release notes](https://github.com/JetBrains/kotlin/releases)
- [Changelog](https://github.com/JetBrains/kotlin/blob/master/ChangeLog.md)
- [Commits](https://github.com/JetBrains/kotlin/commits)

Updates `org.jetbrains.kotlin.android` from 1.9.10 to 1.9.20
- [Release notes](https://github.com/JetBrains/kotlin/releases)
- [Changelog](https://github.com/JetBrains/kotlin/blob/master/ChangeLog.md)
- [Commits](https://github.com/JetBrains/kotlin/commits)

Updates `org.jetbrains.kotlin.plugin.parcelize` from 1.9.10 to 1.9.20
- [Release notes](https://github.com/JetBrains/kotlin/releases)
- [Changelog](https://github.com/JetBrains/kotlin/blob/master/ChangeLog.md)
- [Commits](https://github.com/JetBrains/kotlin/commits)

Updates `org.jetbrains.kotlin.plugin.serialization` from 1.9.10 to 1.9.20
- [Release notes](https://github.com/JetBrains/kotlin/releases)
- [Changelog](https://github.com/JetBrains/kotlin/blob/master/ChangeLog.md)
- [Commits](https://github.com/JetBrains/kotlin/commits)

Updates `org.jetbrains.kotlin:kotlin-reflect` from 1.9.10 to 1.9.20
- [Release notes](https://github.com/JetBrains/kotlin/releases)
- [Changelog](https://github.com/JetBrains/kotlin/blob/master/ChangeLog.md)
- [Commits](https://github.com/JetBrains/kotlin/commits)

Updates `org.jetbrains.kotlin:kotlin-test` from 1.9.10 to 1.9.20
- [Release notes](https://github.com/JetBrains/kotlin/releases)
- [Changelog](https://github.com/JetBrains/kotlin/blob/master/ChangeLog.md)
- [Commits](https://github.com/JetBrains/kotlin/commits)

Updates `org.jetbrains.kotlin:kotlin-test-junit5` from 1.9.10 to 1.9.20
- [Release notes](https://github.com/JetBrains/kotlin/releases)
- [Changelog](https://github.com/JetBrains/kotlin/blob/master/ChangeLog.md)
- [Commits](https://github.com/JetBrains/kotlin/commits)

Updates `org.jetbrains.kotlin:kotlin-test-junit` from 1.9.10 to 1.9.20
- [Release notes](https://github.com/JetBrains/kotlin/releases)
- [Changelog](https://github.com/JetBrains/kotlin/blob/master/ChangeLog.md)
- [Commits](https://github.com/JetBrains/kotlin/commits)

---
updated-dependencies:
- dependency-name: org.jetbrains.kotlin.jvm
  dependency-type: direct:production
  update-type: version-update:semver-patch
- dependency-name: org.jetbrains.kotlin.android
  dependency-type: direct:production
  update-type: version-update:semver-patch
- dependency-name: org.jetbrains.kotlin.plugin.parcelize
  dependency-type: direct:production
  update-type: version-update:semver-patch
- dependency-name: org.jetbrains.kotlin.plugin.serialization
  dependency-type: direct:production
  update-type: version-update:semver-patch
- dependency-name: org.jetbrains.kotlin:kotlin-reflect
  dependency-type: direct:production
  update-type: version-update:semver-patch
- dependency-name: org.jetbrains.kotlin:kotlin-test
  dependency-type: direct:production
  update-type: version-update:semver-patch
- dependency-name: org.jetbrains.kotlin:kotlin-test-junit5
  dependency-type: direct:production
  update-type: version-update:semver-patch
- dependency-name: org.jetbrains.kotlin:kotlin-test-junit
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-10-31 10:51:28 -05:00

152 lines
7.4 KiB
Groovy

import org.gradle.internal.jvm.Jvm
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
// The version for the Kotlin plugin and dependencies
// If changing this, make sure to update org.jetbrains.kotlin.plugin.serialization version too
ext.kotlin_version = '1.9.20'
ext.lint_version = '31.1.1'
ext.acra_version = '5.11.3'
ext.ankidroid_backend_version = '0.1.26-anki23.10beta'
ext.hamcrest_version = '2.2'
ext.junit_version = '5.10.0'
ext.coroutines_version = '1.7.3'
ext.fragments_version = "1.6.1"
ext.espresso_version = '3.5.1'
ext.androidx_test_version = '1.5.0'
ext.androidx_test_junit_version = '1.1.5'
ext.robolectric_version = '4.11'
ext.android_gradle_plugin = "8.2.0-rc01"
ext.dokka_version = "1.9.10" // not the same with kotlin version!
configurations.all {
resolutionStrategy.eachDependency { details ->
if (details.requested.group == 'org.jetbrains.kotlinx'
&& details.requested.name.contains('kotlinx-serialization-runtime')
&& details.requested.version.contains('0.11.0')) {
details.useVersion "0.14.0"
}
}
}
}
plugins {
id 'com.android.application' version "$android_gradle_plugin" apply false
id 'com.android.library' version "$android_gradle_plugin" apply false
id 'org.jetbrains.kotlin.jvm' version "$kotlin_version" apply false
id 'org.jetbrains.kotlin.android' version "$kotlin_version" apply false
id 'org.jetbrains.kotlin.plugin.parcelize' version "$kotlin_version" apply false
id 'org.jetbrains.kotlin.plugin.serialization' version "$kotlin_version" apply false
id 'org.jlleitschuh.gradle.ktlint' version '11.6.1' apply false
id 'org.jetbrains.dokka' version "$dokka_version" apply false
}
Properties localProperties = new Properties()
if (project.rootProject.file('local.properties').exists()) {
localProperties.load(project.rootProject.file('local.properties').newDataInputStream())
}
Boolean fatalWarnings = !(localProperties['fatal_warnings'] == "false")
// Here we extract per-module "best practices" settings to a single top-level evaluation
subprojects {
apply plugin: "org.jlleitschuh.gradle.ktlint"
afterEvaluate { project ->
if (project.hasProperty('android')) {
project.android.testOptions.unitTests {
includeAndroidResources = true
}
project.android.testOptions.unitTests.all {
// tell backend to avoid rollover time, and disable interval fuzzing
environment "ANKI_TEST_MODE", "1"
useJUnitPlatform()
testLogging {
events "failed", "skipped"
showStackTraces = true
exceptionFormat = "full"
}
maxParallelForks = gradleTestMaxParallelForks
forkEvery = 40
systemProperties['junit.jupiter.execution.parallel.enabled'] = true
systemProperties['junit.jupiter.execution.parallel.mode.default'] = "concurrent"
}
}
/**
Kotlin allows concrete function implementations inside interfaces.
For those to work when Kotlin compilation targets the JVM backend, you have to enable the interoperability via
'freeCompilerArgs' in your gradle file, and you have to choose one of the appropriate '-Xjvm-default' modes.
https://kotlinlang.org/docs/java-to-kotlin-interop.html#default-methods-in-interfaces
and we used "all" because we don't have downstream consumers
https://docs.gradle.org/current/userguide/task_configuration_avoidance.html
Related to ExperimentalCoroutinesApi: this opt-in is added to enable usage of experimental
coroutines API, this targets all project modules with the exception of the "api" module,
which doesn't use coroutines so the annotation isn't not available. This would normally
result in a warning but we treat warnings as errors.
(see https://youtrack.jetbrains.com/issue/KT-28777/Using-experimental-coroutines-api-causes-unresolved-dependency)
*/
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all {
kotlinOptions {
allWarningsAsErrors = fatalWarnings
def compilerArgs = ['-Xjvm-default=all']
if (project.name != "api") {
compilerArgs += ['-opt-in=kotlinx.coroutines.ExperimentalCoroutinesApi']
}
freeCompilerArgs = compilerArgs
}
}
}
}
ext {
jvmVersion = Jvm.current().javaVersion.majorVersion
if (jvmVersion != "17" && jvmVersion != "18") {
println "\n\n\n"
println "**************************************************************************************************************"
println "\n\n\n"
println "ERROR: AnkiDroid builds with JVM version 17 or 18."
println " Incompatible major version detected: '" + jvmVersion + "'"
println "\n\n\n"
println " If you receive this error because you want to use a newer JDK, we may accept PRs to support new versions."
println " Edit the main build.gradle file, find this message in the file, and add support for the new version."
println " Please make sure the `jacocoTestReport` target works on an emulator with our minSdkVersion (currently 21)."
println "\n\n\n"
println "**************************************************************************************************************"
println "\n\n\n"
System.exit(1)
}
ciBuild = System.getenv("CI") == "true" // works for Travis CI or Github Actions
// allows for -Dpre-dex=false to be set
preDexEnabled = "true" == System.getProperty("pre-dex", "true")
// allows for universal APKs to be generated
universalApkEnabled = "true" == System.getProperty("universal-apk", "false")
if (System.getProperty("os.name") == "Mac OS X") {
// macOS reports hardware cores. This is accurate for CI, Intel (halved due to SMT) and Apple Silicon
gradleTestMaxParallelForks = "sysctl -n hw.physicalcpu".execute().text.toInteger()
} else if (ciBuild) {
// GitHub Actions (Standard_DS2_v2) are 1:1 on Linux/Windows with two vCPU cores
// Sources:
// Standard_DS2_v2 https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners#cloud-hosts-for-github-hosted-runners
// Which is 1:1 https://docs.microsoft.com/en-gb/azure/virtual-machines/acu : DS1_v2 - DS15_v2 | 1:1
gradleTestMaxParallelForks = 2
// separate gradle compile process is a major speed improvement, but consumes 2x RAM
// the CI machines don't have enough RAM to do that without going in to swap quite a bit
// so for CI machines only - to improve reliability despite compilation speed hit, compile kotlin in process
println "CI build detected: setting compiler execution strategy to IN_PROCESS"
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).configureEach {
compilerExecutionStrategy.set(org.jetbrains.kotlin.gradle.tasks.KotlinCompilerExecutionStrategy.IN_PROCESS)
}
} else {
// Use 50% of cores to account for SMT which doesn't help this workload
gradleTestMaxParallelForks = Runtime.runtime.availableProcessors().intdiv(2) ?: 1
}
}