build.gradle 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. import org.apache.tools.ant.taskdefs.condition.Os
  2. apply plugin: 'com.android.library'
  3. apply plugin: 'com.github.dcendents.android-maven'
  4. apply plugin: 'com.jfrog.bintray'
  5. Properties properties = new Properties()
  6. properties.load(project.rootProject.file('local.properties').newDataInputStream())
  7. android {
  8. compileSdkVersion 23
  9. buildToolsVersion "23.0.3"
  10. defaultConfig {
  11. minSdkVersion 15
  12. targetSdkVersion 22
  13. versionCode 1
  14. versionName "1.0"
  15. proguardFiles 'proguard-rules.pro'
  16. consumerProguardFiles 'proguard-rules.pro'
  17. }
  18. sourceSets {
  19. main {
  20. manifest.srcFile 'AndroidManifest.xml'
  21. java.srcDirs = ['src']
  22. res.srcDirs = ['res']
  23. jni.srcDirs = []
  24. jniLibs.srcDirs = ['libs']
  25. }
  26. }
  27. // Call external ndk-build(.cmd) script to build the native code
  28. task ndkBuild(type: Exec) {
  29. def ndkDirProperty = properties.getProperty('ndk.dir')
  30. def ndkDirPrefix = ndkDirProperty != null ? ndkDirProperty + '/' : ''
  31. def ndkBuildExt = Os.isFamily(Os.FAMILY_WINDOWS) ? ".cmd" : ""
  32. commandLine "${ndkDirPrefix}ndk-build${ndkBuildExt}", '-C', file('.').absolutePath,
  33. '-j', Runtime.runtime.availableProcessors()
  34. }
  35. tasks.withType(JavaCompile) {
  36. compileTask -> compileTask.dependsOn ndkBuild
  37. }
  38. // Cleanup task to remove previously generated binaries
  39. task ndkClean(type: Exec) {
  40. def ndkDirProperty = properties.getProperty('ndk.dir')
  41. def ndkDirPrefix = ndkDirProperty != null ? ndkDirProperty + '/' : ''
  42. def ndkBuildExt = Os.isFamily(Os.FAMILY_WINDOWS) ? ".cmd" : ""
  43. commandLine "${ndkDirPrefix}ndk-build${ndkBuildExt}", '-C', file('.').absolutePath, 'clean'
  44. }
  45. tasks.withType(Delete) {
  46. cleanTask -> cleanTask.dependsOn ndkClean
  47. }
  48. }
  49. dependencies {
  50. compile fileTree(dir: 'libs', include: ['*.jar'])
  51. }
  52. // Settings for uploading module AAR to Bintray for library distribution
  53. task sourcesJar(type: Jar) {
  54. from android.sourceSets.main.java.srcDirs
  55. classifier = 'sources'
  56. }
  57. task javadoc(type: Javadoc) {
  58. failOnError = false
  59. source = android.sourceSets.main.java.srcDirs
  60. classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
  61. options {
  62. links "http://docs.oracle.com/javase/7/docs/api/"
  63. linksOffline "http://d.android.com/reference","${android.sdkDirectory}/docs/reference"
  64. }
  65. }
  66. task javadocJar(type: Jar, dependsOn: javadoc) {
  67. classifier = 'javadoc'
  68. from javadoc.destinationDir
  69. }
  70. artifacts {
  71. archives javadocJar
  72. archives sourcesJar
  73. }
  74. install {
  75. repositories.mavenInstaller {
  76. pom.project {
  77. name = 'tess-two'
  78. packaging = 'aar'
  79. groupId = 'com.rmtheis'
  80. artifactId = 'tess-two'
  81. developers {
  82. developer {
  83. id = 'rmtheis'
  84. name = 'Robert Theis'
  85. email = '[email protected]'
  86. }
  87. }
  88. licenses {
  89. license {
  90. name = 'The Apache Software License, Version 2.0'
  91. url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
  92. distribution = 'repo'
  93. }
  94. }
  95. scm {
  96. url 'https://github.com/rmtheis/tess-two'
  97. }
  98. }
  99. }
  100. }
  101. bintray {
  102. user = properties.getProperty("bintray.user")
  103. key = properties.getProperty("bintray.apikey")
  104. configurations = ['archives']
  105. pkg {
  106. repo = 'maven'
  107. name = 'tess-two'
  108. userOrg = user
  109. publish = true
  110. }
  111. }