build.gradle.kts 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. plugins {
  2. alias(libs.plugins.android.library)
  3. alias(libs.plugins.kotlin.android)
  4. id("maven-publish")
  5. id("signing")
  6. }
  7. android {
  8. namespace = "zxingcpp.lib" // used to be just zxingcpp but needs to contain a '.' in release builds
  9. // ndk version 27 has sufficient c++20 support to enable all features (see #386)
  10. // ndkVersion = "27.0.12077973"
  11. defaultConfig {
  12. compileSdk = libs.versions.androidCompileSdk.get().toInt()
  13. minSdk = libs.versions.androidMinSdk.get().toInt()
  14. ndk {
  15. // speed up build: compile only arm versions
  16. // abiFilters += listOf("armeabi-v7a", "arm64-v8a")
  17. }
  18. externalNativeBuild {
  19. cmake {
  20. arguments(
  21. "-DCMAKE_BUILD_TYPE=RelWithDebInfo",
  22. "-DANDROID_ARM_NEON=ON",
  23. "-DZXING_WRITERS=OFF",
  24. "-DANDROID_SUPPORT_FLEXIBLE_PAGE_SIZES=ON" // This flag can be removed when NDK 28 is the default version
  25. )
  26. }
  27. }
  28. consumerProguardFiles("consumer-rules.pro")
  29. }
  30. compileOptions {
  31. sourceCompatibility(JavaVersion.VERSION_1_8)
  32. targetCompatibility(JavaVersion.VERSION_1_8)
  33. }
  34. kotlinOptions {
  35. jvmTarget = "1.8"
  36. }
  37. externalNativeBuild {
  38. cmake {
  39. path(file("src/main/cpp/CMakeLists.txt"))
  40. }
  41. }
  42. lint {
  43. disable.add("UnsafeExperimentalUsageError")
  44. }
  45. }
  46. kotlin {
  47. explicitApi()
  48. }
  49. dependencies {
  50. implementation(libs.androidx.camera.core)
  51. }
  52. val publishSnapshot: String? by project
  53. group = "io.github.zxing-cpp"
  54. version = "2.3.0" + if (publishSnapshot == "true") "-SNAPSHOT" else ""
  55. val javadocJar by tasks.registering(Jar::class) {
  56. archiveClassifier.set("javadoc")
  57. }
  58. publishing {
  59. publications {
  60. register<MavenPublication>("release") {
  61. artifactId = "android"
  62. groupId = project.group.toString()
  63. version = project.version.toString()
  64. afterEvaluate {
  65. from(components["release"])
  66. }
  67. artifact(javadocJar.get())
  68. pom {
  69. name = "zxing-cpp"
  70. description = "Wrapper for zxing-cpp barcode image processing library"
  71. url = "https://github.com/zxing-cpp/zxing-cpp"
  72. licenses {
  73. license {
  74. name = "The Apache License, Version 2.0"
  75. url = "http://www.apache.org/licenses/LICENSE-2.0.txt"
  76. }
  77. }
  78. developers {
  79. developer {
  80. id = "zxing-cpp"
  81. name = "zxing-cpp community"
  82. email = "zxingcpp@gmail.com"
  83. }
  84. }
  85. scm {
  86. connection = "scm:git:git://github.com/zxing-cpp/zxing-cpp.git"
  87. developerConnection = "scm:git:git://github.com/zxing-cpp/zxing-cpp.git"
  88. url = "https://github.com/zxing-cpp/zxing-cpp"
  89. }
  90. }
  91. }
  92. }
  93. repositories {
  94. maven {
  95. name = "sonatype"
  96. val releasesRepoUrl = "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/"
  97. val snapshotsRepoUrl = "https://s01.oss.sonatype.org/content/repositories/snapshots/"
  98. setUrl(if (version.toString().endsWith("-SNAPSHOT")) snapshotsRepoUrl else releasesRepoUrl)
  99. credentials {
  100. val ossrhUsername: String? by project
  101. val ossrhPassword: String? by project
  102. username = ossrhUsername
  103. password = ossrhPassword
  104. }
  105. }
  106. }
  107. }
  108. signing {
  109. setRequired {
  110. // signing is required if the artifacts are to be published
  111. gradle.taskGraph.allTasks.any { it is PublishToMavenRepository }
  112. }
  113. val signingKey: String? by project
  114. val signingPassword: String? by project
  115. useInMemoryPgpKeys(signingKey, signingPassword)
  116. sign(publishing.publications)
  117. }