build.gradle.kts 4.1 KB

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