build.gradle.kts 3.2 KB

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