2020-06-11 00:23:41 +02:00
|
|
|
import org.gradle.internal.jvm.Jvm
|
|
|
|
|
2014-11-09 18:02:29 +01:00
|
|
|
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
|
|
|
|
|
|
|
buildscript {
|
2021-06-24 03:35:01 +02:00
|
|
|
// The version for the Kotlin plugin and dependencies
|
2022-04-25 18:07:21 +02:00
|
|
|
ext.kotlin_version = '1.6.21'
|
2022-04-11 20:54:42 +02:00
|
|
|
ext.lint_version = '30.1.3'
|
2021-10-31 19:27:32 +01:00
|
|
|
ext.acra_version = '5.7.0'
|
2022-03-25 16:53:05 +01:00
|
|
|
ext.ankidroid_backend_version = '0.1.10'
|
2022-04-25 19:57:21 +02:00
|
|
|
ext.hamcrest_version = '2.2'
|
2021-06-24 03:35:01 +02:00
|
|
|
|
2014-11-09 18:02:29 +01:00
|
|
|
repositories {
|
2018-06-10 17:27:18 +02:00
|
|
|
google()
|
2020-06-17 23:51:47 +02:00
|
|
|
maven {
|
|
|
|
url "https://plugins.gradle.org/m2/"
|
|
|
|
}
|
2014-11-09 18:02:29 +01:00
|
|
|
}
|
|
|
|
dependencies {
|
2022-04-11 20:54:42 +02:00
|
|
|
classpath 'com.android.tools.build:gradle:7.1.3'
|
2014-11-09 18:02:29 +01:00
|
|
|
// NOTE: Do not place your application dependencies here; they belong
|
|
|
|
// in the individual module build.gradle files
|
2020-06-17 23:51:47 +02:00
|
|
|
classpath "app.brant:amazonappstorepublisher:0.1.0"
|
2021-05-26 21:24:24 +02:00
|
|
|
|
2021-06-24 03:35:01 +02:00
|
|
|
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
2022-01-02 21:12:04 +01:00
|
|
|
classpath "org.jlleitschuh.gradle:ktlint-gradle:10.2.1"
|
2014-11-09 18:02:29 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-27 07:41:13 +02:00
|
|
|
repositories {
|
|
|
|
mavenCentral()
|
|
|
|
}
|
|
|
|
|
|
|
|
allprojects {
|
|
|
|
apply plugin: "org.jlleitschuh.gradle.ktlint"
|
|
|
|
}
|
|
|
|
|
2022-04-25 22:02:16 +02:00
|
|
|
// 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 {
|
2022-04-26 01:24:54 +02:00
|
|
|
// 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"
|
2022-04-25 22:02:16 +02:00
|
|
|
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']
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-03-11 23:45:45 +01:00
|
|
|
ext {
|
2019-01-26 21:41:41 +01:00
|
|
|
|
2020-06-11 00:23:41 +02:00
|
|
|
jvmVersion = Jvm.current().javaVersion.majorVersion
|
2021-04-16 20:26:10 +02:00
|
|
|
if (jvmVersion != "11" && jvmVersion != "14" && jvmVersion != "16") {
|
2020-06-11 00:23:41 +02:00
|
|
|
println "\n\n\n"
|
|
|
|
println "**************************************************************************************************************"
|
|
|
|
println "\n\n\n"
|
2021-04-16 20:26:10 +02:00
|
|
|
println "ERROR: AnkiDroid builds with JVM version 11, 14, or 16."
|
2020-06-11 00:23:41 +02:00
|
|
|
println " Incompatible major version detected: '" + jvmVersion + "'"
|
|
|
|
println "\n\n\n"
|
|
|
|
println "**************************************************************************************************************"
|
|
|
|
println "\n\n\n"
|
|
|
|
System.exit(1)
|
|
|
|
}
|
2020-12-20 18:47:37 +01:00
|
|
|
ciBuild = System.getenv("CI") == "true" // works for Travis CI or Github Actions
|
2016-03-11 23:45:45 +01:00
|
|
|
// allows for -Dpre-dex=false to be set
|
2019-11-18 16:21:48 +01:00
|
|
|
preDexEnabled = "true" == System.getProperty("pre-dex", "true")
|
2020-06-15 22:11:12 +02:00
|
|
|
// allows for universal APKs to be generated
|
|
|
|
universalApkEnabled = "true" == System.getProperty("universal-apk", "false")
|
2018-11-24 21:11:48 +01:00
|
|
|
|
2020-12-20 18:47:37 +01:00
|
|
|
// Virtualized Environment like CI may report host CPU counts vs guest, but runs 2 cores
|
2019-11-04 04:42:37 +01:00
|
|
|
// everyone else gets 50% of cores to account for SMT which doesn't help this workload
|
2018-11-24 21:11:48 +01:00
|
|
|
gradleTestMaxParallelForks = 1
|
2020-12-20 18:47:37 +01:00
|
|
|
if (!ciBuild) {
|
2018-11-24 21:11:48 +01:00
|
|
|
gradleTestMaxParallelForks = Runtime.runtime.availableProcessors().intdiv(2) ?: 1
|
|
|
|
}
|
2016-10-23 10:55:19 +02:00
|
|
|
}
|
2018-11-24 21:11:48 +01:00
|
|
|
|