build.gradle 3.3 KB

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