build.gradle 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. plugins {
  2. id 'org.sonarqube'
  3. id 'java-library'
  4. id 'java-test-fixtures'
  5. id 'org.jetbrains.kotlin.jvm'
  6. id 'maven-publish'
  7. id 'jacoco'
  8. id 'com.google.protobuf'
  9. }
  10. /**
  11. * Return the latest available domain version from git, if git is installed.
  12. */
  13. def getGitVersion = { ->
  14. def domainTagPrefix = 'domain-v'
  15. def stdout = new ByteArrayOutputStream()
  16. def stderr = new ByteArrayOutputStream()
  17. try {
  18. exec {
  19. commandLine 'git', 'describe', '--tags', '--match', domainTagPrefix + '*'
  20. standardOutput = stdout
  21. errorOutput = stderr
  22. ignoreExitValue true
  23. }
  24. def string = stdout.toString().trim()
  25. def versionMatches = (string =~ /^${domainTagPrefix}([0-9.]+).*$/)[0][1]
  26. if(versionMatches.isEmpty()) return null
  27. return versionMatches
  28. } catch (ignored) { return null }
  29. }
  30. dependencies {
  31. api "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
  32. api "org.jetbrains.kotlinx:kotlinx-coroutines-core:$kotlin_coroutines_version"
  33. api 'com.googlecode.libphonenumber:libphonenumber:8.13.23'
  34. api 'androidx.annotation:annotation:1.7.1'
  35. api 'net.sourceforge.streamsupport:streamsupport-flow:1.7.4'
  36. api 'com.google.protobuf:protobuf-kotlin-lite:3.25.1'
  37. implementation "org.slf4j:slf4j-api:$slf4j_version"
  38. // commons-io >2.6 requires android 8
  39. implementation 'commons-io:commons-io:2.6'
  40. implementation 'net.i2p.crypto:eddsa:0.3.0'
  41. implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$kotlin_coroutines_version"
  42. testImplementation "junit:junit:$junit_version"
  43. testImplementation 'org.mockito:mockito-core:4.8.1'
  44. testImplementation "org.powermock:powermock-reflect:2.0.9"
  45. testImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-test:$kotlin_coroutines_version"
  46. testImplementation "org.slf4j:slf4j-simple:$slf4j_version"
  47. testImplementation "org.jetbrains.kotlin:kotlin-test:$kotlin_version"
  48. // OkHttp
  49. api platform('com.squareup.okhttp3:okhttp-bom:4.12.0')
  50. api 'com.squareup.okhttp3:okhttp'
  51. }
  52. sourceSets {
  53. def isProtobufSubrepositoryInitialized = file("./protocol/src/common.proto").exists()
  54. assert isProtobufSubrepositoryInitialized : "Error: Git protobuf submodule missing. Please run `git submodule update --init`.\n"
  55. main {
  56. proto.srcDir './protocol/src'
  57. }
  58. }
  59. protobuf {
  60. protoc {
  61. artifact = 'com.google.protobuf:protoc:3.24.3'
  62. }
  63. generateProtoTasks {
  64. all().each { task ->
  65. task.builtins {
  66. java {
  67. option 'lite'
  68. }
  69. kotlin {
  70. option 'lite'
  71. }
  72. }
  73. }
  74. }
  75. }
  76. test {
  77. useJUnit()
  78. }
  79. jacocoTestReport {
  80. reports {
  81. xml.required = true
  82. html.required = false
  83. }
  84. }
  85. sonarqube {
  86. properties {
  87. property 'sonar.projectKey', 'android-client'
  88. property 'sonar.projectName', 'Threema for Android'
  89. property "sonar.sources", "src/main/"
  90. property "sonar.exclusions", "src/main/java/ove/crypto/**"
  91. property "sonar.tests", "src/test/"
  92. property "sonar.sourceEncoding", "UTF-8"
  93. property "sonar.verbose", "true"
  94. property 'sonar.coverage.jacoco.xmlReportPaths', "$projectDir.parentFile.path/build/reports/jacoco/codeCoverageReport/codeCoverageReport.xml"
  95. }
  96. }
  97. publishing {
  98. publications {
  99. library(MavenPublication) {
  100. from components.java
  101. version getGitVersion()
  102. }
  103. }
  104. repositories {
  105. maven {
  106. url System.getenv("CI_API_V4_URL") + "/projects/" + System.getenv("CI_PROJECT_ID") + "/packages/maven"
  107. name "Gitlab"
  108. credentials(HttpHeaderCredentials) {
  109. name = 'Job-Token'
  110. value = System.getenv("CI_JOB_TOKEN")
  111. }
  112. authentication {
  113. header(HttpHeaderAuthentication)
  114. }
  115. }
  116. }
  117. }
  118. java.targetCompatibility = JavaVersion.VERSION_11
  119. sourceCompatibility = JavaVersion.VERSION_11