jcenter.gradle 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. group = PROJ_GROUP_ID
  2. version = PROJ_VERSION
  3. project.archivesBaseName = PROJ_ARTIFACT_ID
  4. apply plugin: 'com.jfrog.bintray'
  5. apply plugin: 'com.github.dcendents.android-maven'
  6. //输入:gradlew bintray 执行
  7. //############################## jar、sources、doc 打包 start #######################################
  8. task sourcesJar(type: Jar) {
  9. from android.sourceSets.main.java.srcDirs
  10. classifier = 'sources'
  11. }
  12. task javadoc(type: Javadoc) {
  13. source = android.sourceSets.main.java.srcDirs
  14. classpath += configurations.compile
  15. classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
  16. }
  17. task javadocJar(type: Jar, dependsOn: javadoc) {
  18. classifier = 'javadoc'
  19. from javadoc.destinationDir
  20. }
  21. javadoc {
  22. options {
  23. encoding "UTF-8"
  24. charSet 'UTF-8'
  25. author true
  26. version true
  27. links "http://docs.oracle.com/javase/7/docs/api"
  28. title PROJ_ARTIFACT_ID
  29. }
  30. }
  31. //添加以下信息避免JAVADOC打包时引用其它类库而出现问题,比如出现以下错误
  32. // xxxx.java:20: 错误: 找不到符号
  33. // public static <T> T create(JsonElement json, Class<T> classOfModel) {
  34. // ^
  35. // 符号: 类 JsonElement
  36. // 位置: 类 xxxx
  37. android.libraryVariants.all { variant ->
  38. println variant.javaCompile.classpath.files
  39. if (variant.name == 'release') {
  40. //我们只需 release 的 javadoc
  41. task("generate${variant.name.capitalize()}Javadoc", type: Javadoc) {
  42. // title = ''
  43. // description = ''
  44. source = variant.javaCompile.source
  45. classpath = files(variant.javaCompile.classpath.files, project.android.getBootClasspath())
  46. options {
  47. encoding "utf-8"
  48. links "http://docs.oracle.com/javase/7/docs/api/"
  49. linksOffline "http://d.android.com/reference", "${android.sdkDirectory}/docs/reference"
  50. }
  51. exclude '**/BuildConfig.java'
  52. exclude '**/R.java'
  53. }
  54. task("javadoc${variant.name.capitalize()}Jar", type: Jar,
  55. dependsOn: "generate${variant.name.capitalize()}Javadoc") {
  56. classifier = 'javadoc'
  57. from tasks.getByName("generate${variant.name.capitalize()}Javadoc").destinationDir
  58. }
  59. artifacts {
  60. archives tasks.getByName("javadoc${variant.name.capitalize()}Jar")
  61. }
  62. }
  63. }
  64. artifacts {
  65. archives javadocJar
  66. archives sourcesJar
  67. }
  68. //############################## jar、sources、doc 打包 end #######################################
  69. //################################# jcenter 上传配置 start #########################################
  70. bintray {
  71. // user = hasProperty("bintrayUser") ? getProperty("bintrayUser") : getProperty("BINTRAY_USER")
  72. // groupName = hasProperty("bintrayKey") ? getProperty("bintrayKey") : getProperty("BINTRAY_KEY")
  73. user = BINTRAY_USER
  74. key = BINTRAY_KEY
  75. configurations = ['archives']
  76. pkg {
  77. repo = PROJ_REPO
  78. name = PROJ_NAME
  79. desc = PROJ_DESCRIPTION
  80. websiteUrl = PROJ_WEB_SITE_URL
  81. issueTrackerUrl = PROJ_ISSUE_TRACKER_URL
  82. vcsUrl = PROJ_VCS_URL
  83. publish = true
  84. publicDownloadNumbers = true
  85. licenses = LICENSES
  86. // version {
  87. // desc = libraryDescription
  88. // gpg {
  89. // sign = true //Determines whether to GPG sign the files. The default is false
  90. // passphrase = properties.getProperty("bintray.gpg.password")
  91. // //Optional. The passphrase for GPG signing'
  92. // }
  93. // }
  94. }
  95. }
  96. //install
  97. install {
  98. repositories.mavenInstaller {
  99. // This generates POM.xml with proper parameters
  100. pom {
  101. project {
  102. packaging 'aar'
  103. groupId PROJ_GROUP_ID
  104. artifactId PROJ_ARTIFACT_ID
  105. // Add your description here
  106. name PROJ_NAME
  107. description PROJ_DESCRIPTION
  108. url PROJ_WEB_SITE_URL
  109. // Set your license
  110. licenses {
  111. license {
  112. name LICENSE_NAME
  113. url LICENSE_URL
  114. }
  115. }
  116. developers {
  117. developer {
  118. id DEVELOPER_ID
  119. name DEVELOPER_NAME
  120. email DEVELOPER_EMAIL
  121. }
  122. }
  123. scm {
  124. connection PROJ_WEB_SITE_URL
  125. developerConnection PROJ_WEB_SITE_URL
  126. url PROJ_VCS_URL
  127. }
  128. }
  129. }
  130. }
  131. }
  132. //################################# jcenter 上传配置 end #########################################