build.gradle.kts 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. @file:Suppress("UnstableApiUsage")
  2. import org.gradle.api.tasks.testing.logging.TestLogEvent
  3. val pkg: String = providers.gradleProperty("wireguardPackageName").get()
  4. plugins {
  5. alias(libs.plugins.android.library)
  6. `maven-publish`
  7. signing
  8. }
  9. android {
  10. compileSdk = 34
  11. compileOptions {
  12. sourceCompatibility = JavaVersion.VERSION_17
  13. targetCompatibility = JavaVersion.VERSION_17
  14. }
  15. namespace = "${pkg}.tunnel"
  16. defaultConfig {
  17. minSdk = 21
  18. }
  19. externalNativeBuild {
  20. cmake {
  21. path("tools/CMakeLists.txt")
  22. }
  23. }
  24. testOptions.unitTests.all {
  25. it.testLogging { events(TestLogEvent.PASSED, TestLogEvent.SKIPPED, TestLogEvent.FAILED) }
  26. }
  27. buildTypes {
  28. all {
  29. externalNativeBuild {
  30. cmake {
  31. targets("libwg-go.so", "libwg.so", "libwg-quick.so")
  32. arguments("-DGRADLE_USER_HOME=${project.gradle.gradleUserHomeDir}")
  33. }
  34. }
  35. }
  36. release {
  37. externalNativeBuild {
  38. cmake {
  39. arguments("-DANDROID_PACKAGE_NAME=${pkg}")
  40. }
  41. }
  42. }
  43. debug {
  44. externalNativeBuild {
  45. cmake {
  46. arguments("-DANDROID_PACKAGE_NAME=${pkg}.debug")
  47. }
  48. }
  49. }
  50. }
  51. lint {
  52. disable += "LongLogTag"
  53. disable += "NewApi"
  54. }
  55. publishing {
  56. singleVariant("release") {
  57. withJavadocJar()
  58. withSourcesJar()
  59. }
  60. }
  61. }
  62. dependencies {
  63. implementation(libs.androidx.annotation)
  64. implementation(libs.androidx.collection)
  65. compileOnly(libs.jsr305)
  66. testImplementation(libs.junit)
  67. }
  68. publishing {
  69. publications {
  70. register<MavenPublication>("release") {
  71. groupId = pkg
  72. artifactId = "tunnel"
  73. version = providers.gradleProperty("wireguardVersionName").get()
  74. afterEvaluate {
  75. from(components["release"])
  76. }
  77. pom {
  78. name.set("WireGuard Tunnel Library")
  79. description.set("Embeddable tunnel library for WireGuard for Android")
  80. url.set("https://www.wireguard.com/")
  81. licenses {
  82. license {
  83. name.set("The Apache Software License, Version 2.0")
  84. url.set("http://www.apache.org/licenses/LICENSE-2.0.txt")
  85. distribution.set("repo")
  86. }
  87. }
  88. scm {
  89. connection.set("scm:git:https://git.zx2c4.com/wireguard-android")
  90. developerConnection.set("scm:git:https://git.zx2c4.com/wireguard-android")
  91. url.set("https://git.zx2c4.com/wireguard-android")
  92. }
  93. developers {
  94. organization {
  95. name.set("WireGuard")
  96. url.set("https://www.wireguard.com/")
  97. }
  98. developer {
  99. name.set("WireGuard")
  100. email.set("team@wireguard.com")
  101. }
  102. }
  103. }
  104. }
  105. }
  106. repositories {
  107. maven {
  108. name = "sonatype"
  109. url = uri("https://oss.sonatype.org/service/local/staging/deploy/maven2/")
  110. credentials {
  111. username = providers.environmentVariable("SONATYPE_USER").orNull
  112. password = providers.environmentVariable("SONATYPE_PASSWORD").orNull
  113. }
  114. }
  115. }
  116. }
  117. signing {
  118. useGpgCmd()
  119. sign(publishing.publications)
  120. }