build.gradle 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. apply plugin: 'com.android.library'
  2. android {
  3. compileSdkVersion 29
  4. buildToolsVersion "29.0.3"
  5. defaultConfig {
  6. minSdkVersion 17
  7. targetSdkVersion 29
  8. versionCode 2
  9. versionName "1.0.2"
  10. }
  11. buildTypes {
  12. release {
  13. minifyEnabled false
  14. proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
  15. }
  16. }
  17. }
  18. dependencies {
  19. implementation fileTree(dir: "libs", include: ["*.jar"])
  20. implementation 'androidx.annotation:annotation:1.1.0'
  21. }
  22. /** 以下开始是将Android Library上传到jcenter的相关配置**/
  23. apply plugin: 'com.github.dcendents.android-maven'
  24. apply plugin: 'com.jfrog.bintray'
  25. //项目主页
  26. def siteUrl = 'https://github.com/yangchong211/YCVideoPlayer' // project homepage
  27. //项目的版本控制地址
  28. def gitUrl = 'https://github.com/yangchong211/YCVideoPlayer.git' // project git
  29. //发布到组织名称名字,必须填写
  30. group = "cn.yc"
  31. //发布到JCenter上的项目名字,必须填写
  32. def libName = "VideoSqlLite"
  33. // 版本号,下次更新是只需要更改版本号即可
  34. version = "1.0.2"
  35. //生成源文件
  36. task sourcesJar(type: Jar) {
  37. from android.sourceSets.main.java.srcDirs
  38. classifier = 'sources'
  39. }
  40. //生成文档
  41. task javadoc(type: Javadoc) {
  42. source = android.sourceSets.main.java.srcDirs
  43. classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
  44. options.encoding "UTF-8"
  45. options.charSet 'UTF-8'
  46. options.author true
  47. options.version true
  48. options.links "https://github.com/linglongxin24/FastDev/tree/master/mylibrary/docs/javadoc"
  49. failOnError false
  50. }
  51. //文档打包成jar
  52. task javadocJar(type: Jar, dependsOn: javadoc) {
  53. classifier = 'javadoc'
  54. from javadoc.destinationDir
  55. }
  56. //拷贝javadoc文件
  57. task copyDoc(type: Copy) {
  58. from "${buildDir}/docs/"
  59. into "docs"
  60. }
  61. //上传到jcenter所需要的源码文件
  62. artifacts {
  63. archives javadocJar
  64. archives sourcesJar
  65. }
  66. // 配置maven库,生成POM.xml文件
  67. install {
  68. repositories.mavenInstaller {
  69. // This generates POM.xml with proper parameters
  70. pom {
  71. project {
  72. packaging 'aar'
  73. //项目描述,自由填写
  74. name 'This is video sqllite lib'
  75. url siteUrl
  76. licenses {
  77. license {
  78. //开源协议
  79. name 'The Apache Software License, Version 2.0'
  80. url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
  81. }
  82. }
  83. developers {
  84. developer {
  85. //开发者的个人信息,根据个人信息填写
  86. id 'yangchong'
  87. name 'yc'
  88. email 'yangchong211@163.com'
  89. }
  90. }
  91. scm {
  92. connection gitUrl
  93. developerConnection gitUrl
  94. url siteUrl
  95. }
  96. }
  97. }
  98. }
  99. }
  100. //上传到jcenter
  101. Properties properties = new Properties()
  102. properties.load(project.rootProject.file('local.properties').newDataInputStream())
  103. bintray {
  104. user = properties.getProperty("bintray.user") //读取 local.properties 文件里面的 bintray.user
  105. key = properties.getProperty("bintray.apikey") //读取 local.properties 文件里面的 bintray.apikey
  106. configurations = ['archives']
  107. pkg {
  108. repo = "maven"
  109. name = libName //发布到JCenter上的项目名字,必须填写
  110. desc = 'android video sqllite' //项目描述
  111. websiteUrl = siteUrl
  112. vcsUrl = gitUrl
  113. licenses = ["Apache-2.0"]
  114. publish = true
  115. }
  116. }
  117. javadoc {
  118. options {
  119. //如果你的项目里面有中文注释的话,必须将格式设置为UTF-8,不然会出现乱码
  120. encoding "UTF-8"
  121. charSet 'UTF-8'
  122. author true
  123. version true
  124. links "http://docs.oracle.com/javase/7/docs/api"
  125. }
  126. }