build.gradle 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. apply plugin: 'com.android.library'
  2. apply plugin: 'maven-publish'
  3. apply plugin: 'signing'
  4. ext.artifactId = 'zxing-android-embedded'
  5. ext["signing.keyId"] = ''
  6. ext["signing.password"] = ''
  7. ext["signing.secretKeyRingFile"] = ''
  8. ext["ossrhUsername"] = ''
  9. ext["ossrhPassword"] = ''
  10. ext["sonatypeStagingProfileId"] = ''
  11. File secretPropsFile = project.rootProject.file('local.properties')
  12. if (secretPropsFile.exists()) {
  13. Properties p = new Properties()
  14. p.load(new FileInputStream(secretPropsFile))
  15. p.each { name, value ->
  16. ext[name] = value
  17. }
  18. } else {
  19. ext["signing.keyId"] = System.getenv('SIGNING_KEY_ID')
  20. ext["signing.password"] = System.getenv('SIGNING_PASSWORD')
  21. ext["signing.secretKeyRingFile"] = System.getenv('SIGNING_SECRET_KEY_RING_FILE')
  22. ext["ossrhUsername"] = System.getenv('OSSRH_USERNAME')
  23. ext["ossrhPassword"] = System.getenv('OSSRH_PASSWORD')
  24. ext["sonatypeStagingProfileId"] = System.getenv('SONATYPE_STAGING_PROFILE_ID')
  25. }
  26. dependencies {
  27. api project.zxingCore
  28. implementation 'androidx.core:core:1.6.0'
  29. implementation 'androidx.fragment:fragment:1.3.6'
  30. testImplementation 'junit:junit:4.13.1'
  31. testImplementation 'org.mockito:mockito-core:1.9.5'
  32. implementation 'com.geyifeng.immersionbar:immersionbar:3.2.2'
  33. }
  34. android {
  35. resourcePrefix 'zxing_'
  36. compileSdkVersion project.androidTargetSdk
  37. sourceSets {
  38. main {
  39. manifest.srcFile 'AndroidManifest.xml'
  40. java.srcDirs = ['src']
  41. res.srcDirs = ['res']
  42. assets.srcDirs = ['assets']
  43. }
  44. test.setRoot('test')
  45. }
  46. // This is bad practice - we should fix the warnings instead.
  47. lintOptions {
  48. // Android warns about the he and id locale folders. he -> iw is already handled with a
  49. // symlink. TODO: what about id?
  50. disable 'LocaleFolder'
  51. }
  52. compileOptions {
  53. sourceCompatibility JavaVersion.VERSION_1_8
  54. targetCompatibility JavaVersion.VERSION_1_8
  55. }
  56. testOptions {
  57. // We test with primitives such as Rect, and rely on their default behaviour working.
  58. unitTests.returnDefaultValues = true
  59. }
  60. defaultConfig {
  61. minSdkVersion 19
  62. }
  63. buildTypes {
  64. debug {
  65. versionNameSuffix ".debug"
  66. resValue "string", "app_version", "${defaultConfig.versionName}${versionNameSuffix}"
  67. }
  68. release {
  69. resValue "string", "app_version", "${defaultConfig.versionName}"
  70. }
  71. }
  72. }
  73. task sourceJar(type: Jar) {
  74. classifier = 'sources'
  75. from android.sourceSets.main.java.srcDirs
  76. }
  77. project.afterEvaluate {
  78. publishing {
  79. publications {
  80. maven(MavenPublication) {
  81. artifact bundleReleaseAar
  82. artifactId project.artifactId
  83. artifact sourceJar
  84. pom {
  85. name = project.artifactId
  86. description = 'Barcode scanner library for Android, based on the ZXing decoder'
  87. url = 'https://github.com/journeyapps/zxing-android-embedded'
  88. licenses {
  89. license {
  90. name = 'The Apache License, Version 2.0'
  91. url = 'https://github.com/journeyapps/zxing-android-embedded/blob/master/COPYING'
  92. }
  93. }
  94. developers {
  95. developer {
  96. id = ''
  97. name = 'Ralf Kistner'
  98. email = 'ralf@journeyapps.com'
  99. organization = 'Journey Mobile, Inc'
  100. organizationUrl = 'https://journeyapps.com'
  101. }
  102. }
  103. scm {
  104. connection = 'scm:git:github.com/journeyapps/zxing-android-embedded.git'
  105. developerConnection = 'scm:git:ssh://github.com/journeyapps/zxing-android-embedded.git'
  106. url = 'https://github.com/journeyapps/zxing-android-embedded'
  107. }
  108. }
  109. pom.withXml {
  110. // HACK to add dependencies to POM.
  111. // When maven-publish can do this automatically for Android projects,
  112. // remove this section.
  113. def deps = asNode().appendNode('dependencies')
  114. project.configurations.api.allDependencies.each { dep ->
  115. def node = deps.appendNode('dependency')
  116. node.appendNode('groupId', dep.group)
  117. node.appendNode('artifactId', dep.name)
  118. node.appendNode('version', dep.version)
  119. node.appendNode('scope', 'api')
  120. }
  121. }
  122. }
  123. }
  124. repositories {
  125. maven {
  126. name = "sonatype"
  127. url = "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
  128. credentials {
  129. username ossrhUsername
  130. password ossrhPassword
  131. }
  132. }
  133. }
  134. }
  135. }
  136. signing {
  137. sign publishing.publications
  138. }