build.gradle.kts 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. import org.jetbrains.kotlin.gradle.dsl.JvmTarget
  2. import org.jetbrains.kotlin.gradle.tasks.KotlinJvmCompile
  3. import utils.LocalProperties
  4. LocalProperties.init(project.rootProject)
  5. buildscript {
  6. repositories {
  7. google()
  8. mavenCentral()
  9. flatDir { dir("app/libs") }
  10. }
  11. dependencies {
  12. classpath(libs.kotlin.gradle)
  13. classpath(libs.android.gradle)
  14. // Huawei agconnect plugin
  15. classpath("com.huawei.agconnect:agcp-1.9.1.303")
  16. classpath("com.huawei.agconnect:agconnect-crash-symbol-lib-1.9.1.301")
  17. classpath("com.huawei.agconnect:agconnect-apms-plugin-1.6.2.300")
  18. classpath("com.huawei.agconnect:agconnect-core-1.9.1.301@aar")
  19. }
  20. }
  21. plugins {
  22. alias(libs.plugins.jacoco)
  23. alias(libs.plugins.sonarqube)
  24. alias(libs.plugins.ktlint)
  25. alias(libs.plugins.compose.compiler) apply false
  26. }
  27. allprojects {
  28. repositories {
  29. google()
  30. mavenCentral()
  31. maven("https://jitpack.io")
  32. flatDir { dir("libs") }
  33. // Huawei
  34. exclusiveContent {
  35. forRepository {
  36. maven("https://developer.huawei.com/repo/")
  37. }
  38. filter {
  39. // Only matching dependencies will be installed from this repository.
  40. includeGroup("com.huawei.hms")
  41. includeGroup("com.huawei.android.hms")
  42. includeGroup("com.huawei.hmf")
  43. }
  44. }
  45. }
  46. group = "ch.threema"
  47. }
  48. tasks.wrapper {
  49. distributionType = Wrapper.DistributionType.ALL
  50. }
  51. sonarqube {
  52. properties {
  53. property("sonar.projectKey", "android-client")
  54. property("sonar.projectName", "Threema for Android")
  55. }
  56. }
  57. jacoco {
  58. toolVersion = "0.8.7"
  59. }
  60. subprojects {
  61. apply(plugin = "org.jlleitschuh.gradle.ktlint")
  62. tasks.withType<KotlinJvmCompile>().configureEach {
  63. compilerOptions {
  64. jvmTarget.set(JvmTarget.JVM_11)
  65. freeCompilerArgs.add("-Xjvm-default=all")
  66. }
  67. }
  68. configurations.configureEach {
  69. resolutionStrategy {
  70. eachDependency {
  71. if (requested.group == "org.jacoco") {
  72. useVersion("0.8.7")
  73. }
  74. }
  75. }
  76. }
  77. ktlint {
  78. outputToConsole = true
  79. android = true
  80. filter {
  81. exclude { entry ->
  82. entry.file.path.contains("/build/")
  83. }
  84. }
  85. }
  86. }
  87. // task to gather code coverage from multiple subprojects
  88. // NOTE: the `JacocoReport` tasks do *not* depend on the `test` task by default. Meaning you have to ensure
  89. // that `test` (or other tasks generating code coverage) run before generating the report.
  90. tasks.register<JacocoReport>("codeCoverageReport") {
  91. // If a subproject applies the 'jacoco' plugin, add the result it to the report
  92. subprojects {
  93. val subproject = this
  94. plugins.withType<JacocoPlugin>()
  95. .configureEach {
  96. tasks
  97. .matching { it.extensions.findByType<JacocoTaskExtension>() != null }
  98. .configureEach {
  99. sourceSets(
  100. subproject.extensions.getByType(SourceSetContainer::class.java).getByName("main"),
  101. )
  102. }
  103. }
  104. }
  105. reports {
  106. xml.required = true
  107. }
  108. }