build.gradle 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  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 'com.googlecode.libphonenumber:libphonenumber:8.13.7'
  33. api 'androidx.annotation:annotation:1.6.0'
  34. api 'net.sourceforge.streamsupport:streamsupport-flow:1.7.4'
  35. api 'com.google.protobuf:protobuf-javalite:3.19.4'
  36. implementation "org.slf4j:slf4j-api:$slf4j_version"
  37. // commons-io >2.6 requires android 8
  38. implementation 'commons-io:commons-io:2.6'
  39. implementation 'net.i2p.crypto:eddsa:0.3.0'
  40. testImplementation "junit:junit:$junit_version"
  41. testImplementation 'org.mockito:mockito-core:4.8.1'
  42. testImplementation "org.powermock:powermock-reflect:2.0.9"
  43. testImplementation "org.slf4j:slf4j-simple:$slf4j_version"
  44. }
  45. sourceSets {
  46. def isProtobufSubrepositoryInitialized = file("./src/main/proto/common.proto").exists()
  47. assert isProtobufSubrepositoryInitialized : "Error: Git protobuf submodule missing. Please run `git submodule update --init`.\n"
  48. main {
  49. java.srcDirs += "${protobuf.generatedFilesBaseDir}/main/java"
  50. }
  51. }
  52. sourceCompatibility = JavaVersion.VERSION_11
  53. protobuf {
  54. protoc {
  55. artifact = 'com.google.protobuf:protoc:3.19.4'
  56. }
  57. generateProtoTasks {
  58. all().each { task ->
  59. task.builtins {
  60. java {
  61. option 'lite'
  62. }
  63. }
  64. }
  65. }
  66. }
  67. test {
  68. useJUnit()
  69. }
  70. jacocoTestReport {
  71. reports {
  72. xml.required = true
  73. html.required = false
  74. }
  75. }
  76. sonarqube {
  77. properties {
  78. property 'sonar.projectKey', 'android-client'
  79. property 'sonar.projectName', 'Threema for Android'
  80. property "sonar.sources", "src/main/"
  81. property "sonar.exclusions", "src/main/java/ove/crypto/**"
  82. property "sonar.tests", "src/test/"
  83. property "sonar.sourceEncoding", "UTF-8"
  84. property "sonar.verbose", "true"
  85. property 'sonar.coverage.jacoco.xmlReportPaths', "$projectDir.parentFile.path/build/reports/jacoco/codeCoverageReport/codeCoverageReport.xml"
  86. }
  87. }
  88. publishing {
  89. publications {
  90. library(MavenPublication) {
  91. from components.java
  92. version getGitVersion()
  93. }
  94. }
  95. repositories {
  96. maven {
  97. url System.getenv("CI_API_V4_URL") + "/projects/" + System.getenv("CI_PROJECT_ID") + "/packages/maven"
  98. name "Gitlab"
  99. credentials(HttpHeaderCredentials) {
  100. name = 'Job-Token'
  101. value = System.getenv("CI_JOB_TOKEN")
  102. }
  103. authentication {
  104. header(HttpHeaderAuthentication)
  105. }
  106. }
  107. }
  108. }