mirror of
https://github.com/ankidroid/Anki-Android.git
synced 2024-09-20 20:03:05 +02:00
1f2dc019d5
It appears upstream has fixed the leak as of 0.45.0, so workaround not needed, and ktlint is now on 0.45.2 anyway, so use that Can't remove the actual version override that gets us 0.45.x until the ktlint gradle plugin has a new release but that hasn't happened yet
127 lines
5.0 KiB
Groovy
127 lines
5.0 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
|
|
ext.kotlin_version = '1.6.21'
|
|
ext.lint_version = '30.1.3'
|
|
ext.acra_version = '5.7.0'
|
|
ext.ankidroid_backend_version = '0.1.10'
|
|
ext.hamcrest_version = '2.2'
|
|
|
|
repositories {
|
|
google()
|
|
maven {
|
|
url "https://plugins.gradle.org/m2/"
|
|
}
|
|
}
|
|
dependencies {
|
|
classpath 'com.android.tools.build:gradle:7.1.3'
|
|
// NOTE: Do not place your application dependencies here; they belong
|
|
// in the individual module build.gradle files
|
|
classpath "app.brant:amazonappstorepublisher:0.1.0"
|
|
|
|
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
|
classpath "org.jlleitschuh.gradle:ktlint-gradle:10.2.1"
|
|
}
|
|
}
|
|
|
|
repositories {
|
|
mavenCentral()
|
|
}
|
|
|
|
allprojects {
|
|
apply plugin: "org.jlleitschuh.gradle.ktlint"
|
|
}
|
|
|
|
// Here we extract per-module "best practices" settings to a single top-level evaluation
|
|
subprojects {
|
|
afterEvaluate { project ->
|
|
|
|
if (project.hasProperty('android')) {
|
|
project.android.testOptions.unitTests {
|
|
includeAndroidResources = true
|
|
}
|
|
project.android.testOptions.unitTests.all {
|
|
testLogging {
|
|
events "failed", "skipped"
|
|
showStackTraces = true
|
|
exceptionFormat = "full"
|
|
}
|
|
|
|
maxParallelForks = gradleTestMaxParallelForks
|
|
forkEvery = 40
|
|
maxHeapSize = "2048m"
|
|
minHeapSize = "1024m"
|
|
systemProperties['junit.jupiter.execution.parallel.enabled'] = true
|
|
systemProperties['junit.jupiter.execution.parallel.mode.default'] = "concurrent"
|
|
}
|
|
}
|
|
|
|
// Deprecation is an error. Use @SuppressWarnings("deprecation") and justify in the PR if you must
|
|
project.tasks.withType(JavaCompile) {
|
|
options.compilerArgs << "-Xlint:deprecation" << "-Xlint:fallthrough" << "-Xmaxwarns" << "1000" << "-Werror"
|
|
|
|
// https://guides.gradle.org/performance/#compiling_java
|
|
// 1- fork improves things over time with repeated builds, doesn't harm CI single builds
|
|
options.fork = true
|
|
// 2- incremental will be the default in the future and can help now
|
|
options.incremental = true
|
|
}
|
|
|
|
ktlint {
|
|
// remove version override when ktlint gradle plugin releases with 0.45+ transitive
|
|
// check here https://github.com/JLLeitschuh/ktlint-gradle/blob/ddd465e28d77b879384886e1eef5666ebe518b4d/plugin/gradle/libs.versions.toml#L3
|
|
version = "0.45.2"
|
|
disabledRules = ["no-wildcard-imports"]
|
|
}
|
|
|
|
/**
|
|
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
|
|
*/
|
|
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all {
|
|
kotlinOptions {
|
|
allWarningsAsErrors = true
|
|
freeCompilerArgs = ['-Xjvm-default=all']
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
ext {
|
|
|
|
jvmVersion = Jvm.current().javaVersion.majorVersion
|
|
if (jvmVersion != "11" && jvmVersion != "14" && jvmVersion != "16") {
|
|
println "\n\n\n"
|
|
println "**************************************************************************************************************"
|
|
println "\n\n\n"
|
|
println "ERROR: AnkiDroid builds with JVM version 11, 14, or 16."
|
|
println " Incompatible major version detected: '" + jvmVersion + "'"
|
|
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")
|
|
|
|
// Virtualized Environment like CI may report host CPU counts vs guest, but runs 2 cores
|
|
// everyone else gets 50% of cores to account for SMT which doesn't help this workload
|
|
gradleTestMaxParallelForks = 1
|
|
if (!ciBuild) {
|
|
gradleTestMaxParallelForks = Runtime.runtime.availableProcessors().intdiv(2) ?: 1
|
|
}
|
|
}
|
|
|