build.gradle.kts 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. /* _____ _
  2. * |_ _| |_ _ _ ___ ___ _ __ __ _
  3. * | | | ' \| '_/ -_) -_) ' \/ _` |_
  4. * |_| |_||_|_| \___\___|_|_|_\__,_(_)
  5. *
  6. * Threema for Android
  7. * Copyright (c) 2014-2025 Threema GmbH
  8. *
  9. * This program is free software: you can redistribute it and/or modify
  10. * it under the terms of the GNU Affero General Public License, version 3,
  11. * as published by the Free Software Foundation.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU Affero General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU Affero General Public License
  19. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  20. */
  21. import org.jetbrains.kotlin.gradle.dsl.JvmTarget
  22. import org.jetbrains.kotlin.gradle.tasks.KotlinJvmCompile
  23. buildscript {
  24. repositories {
  25. google()
  26. mavenCentral()
  27. flatDir { dir("app/libs") }
  28. }
  29. dependencies {
  30. classpath(libs.kotlin.gradle)
  31. classpath(libs.android.gradle)
  32. // Huawei agconnect plugin
  33. classpath("com.huawei.agconnect:agcp-1.9.1.303")
  34. classpath("com.huawei.agconnect:agconnect-crash-symbol-lib-1.9.1.301")
  35. classpath("com.huawei.agconnect:agconnect-apms-plugin-1.6.2.300")
  36. classpath("com.huawei.agconnect:agconnect-core-1.9.1.301@aar")
  37. }
  38. }
  39. plugins {
  40. alias(libs.plugins.jacoco)
  41. alias(libs.plugins.sonarqube)
  42. alias(libs.plugins.ktlint)
  43. alias(libs.plugins.compose.compiler) apply false
  44. }
  45. allprojects {
  46. repositories {
  47. google()
  48. mavenCentral()
  49. maven("https://jitpack.io")
  50. flatDir { dir("libs") }
  51. // Huawei
  52. exclusiveContent {
  53. forRepository {
  54. maven("https://developer.huawei.com/repo/")
  55. }
  56. filter {
  57. // Only matching dependencies will be installed from this repository.
  58. includeGroup("com.huawei.hms")
  59. includeGroup("com.huawei.android.hms")
  60. includeGroup("com.huawei.hmf")
  61. }
  62. }
  63. }
  64. group = "ch.threema"
  65. }
  66. tasks.wrapper {
  67. distributionType = Wrapper.DistributionType.ALL
  68. }
  69. sonarqube {
  70. properties {
  71. property("sonar.projectKey", "android-client")
  72. property("sonar.projectName", "Threema for Android")
  73. }
  74. }
  75. jacoco {
  76. toolVersion = "0.8.7"
  77. }
  78. subprojects {
  79. apply(plugin = "org.jlleitschuh.gradle.ktlint")
  80. tasks.withType<KotlinJvmCompile>().configureEach {
  81. compilerOptions {
  82. jvmTarget.set(JvmTarget.JVM_11)
  83. freeCompilerArgs.add("-Xjvm-default=all")
  84. }
  85. }
  86. configurations.configureEach {
  87. resolutionStrategy {
  88. eachDependency {
  89. if (requested.group == "org.jacoco") {
  90. useVersion("0.8.7")
  91. }
  92. }
  93. }
  94. }
  95. ktlint {
  96. outputToConsole = true
  97. android = true
  98. filter {
  99. exclude { entry ->
  100. entry.file.path.contains("/build/")
  101. }
  102. }
  103. }
  104. }
  105. // task to gather code coverage from multiple subprojects
  106. // NOTE: the `JacocoReport` tasks do *not* depend on the `test` task by default. Meaning you have to ensure
  107. // that `test` (or other tasks generating code coverage) run before generating the report.
  108. tasks.register<JacocoReport>("codeCoverageReport") {
  109. // If a subproject applies the 'jacoco' plugin, add the result it to the report
  110. subprojects {
  111. val subproject = this
  112. plugins.withType<JacocoPlugin>()
  113. .configureEach {
  114. tasks
  115. .matching { it.extensions.findByType<JacocoTaskExtension>() != null }
  116. .configureEach {
  117. sourceSets(
  118. subproject.extensions.getByType(SourceSetContainer::class.java).getByName("main"),
  119. )
  120. }
  121. }
  122. }
  123. reports {
  124. xml.required = true
  125. }
  126. }