build.gradle 4.2 KB

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