|
| 1 | +//在根build.gradle中加入 |
| 2 | +//classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.4' |
| 3 | +//classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1' |
| 4 | + |
| 5 | +//在module的build.gradle末位加入 |
| 6 | +//apply from: './bintray.gradle' |
| 7 | + |
| 8 | +// 执行 ./gradlew clean bintrayUpload |
| 9 | + |
| 10 | +def toUpload = true // 配置是否上传 |
| 11 | +if (toUpload) { |
| 12 | + apply plugin: 'com.github.dcendents.android-maven' |
| 13 | + apply plugin: 'com.jfrog.bintray' |
| 14 | + |
| 15 | + // 定义参数 |
| 16 | + // 依赖信息 |
| 17 | + def groupIdDefined = "com.licheedev" |
| 18 | + def artifactIdDefined = "android-serialport" |
| 19 | + def versionDefined = rootProject.ext.versionName |
| 20 | + // 其他信息 |
| 21 | + def siteUrl = "https://github.com/licheedev" |
| 22 | + def gitUrl = "https://github.com/licheedev/Android-SerialPort-API.git" |
| 23 | + def libName = "$artifactIdDefined" |
| 24 | + |
| 25 | + // 待发布项目的groupId和version。android-maven-gradle-plugin插件需要这么配置。 |
| 26 | + group = "$groupIdDefined" |
| 27 | + version = "$versionDefined" |
| 28 | + |
| 29 | + // bintray平台信息配置 |
| 30 | + bintray { |
| 31 | + user = BINTRAY_USER |
| 32 | + key = BINTRAY_KEY |
| 33 | + |
| 34 | + println "user=${user},key=${key}" |
| 35 | + |
| 36 | + configurations = ['archives'] |
| 37 | + publish = true |
| 38 | + pkg { |
| 39 | + repo = "maven" |
| 40 | + name = libName |
| 41 | + licenses = [" Apache-2.0"] |
| 42 | + websiteUrl = siteUrl |
| 43 | + vcsUrl = gitUrl |
| 44 | + version { |
| 45 | + name = "$versionDefined" |
| 46 | + } |
| 47 | + } |
| 48 | + } |
| 49 | + |
| 50 | + // pom文件信息配置 |
| 51 | + install { |
| 52 | + repositories.mavenInstaller { |
| 53 | + pom.project { |
| 54 | + groupId "$groupIdDefined" |
| 55 | + artifactId "$artifactIdDefined" |
| 56 | + version "$versionDefined" |
| 57 | + packaging 'aar' |
| 58 | + } |
| 59 | + } |
| 60 | + } |
| 61 | + |
| 62 | + // 生成sourceJar和javaDocJar |
| 63 | + task sourcesJar(type: Jar) { |
| 64 | + from android.sourceSets.main.java.srcDirs |
| 65 | + classifier = 'sources' |
| 66 | + } |
| 67 | + |
| 68 | + task javadoc(type: Javadoc) { |
| 69 | + failOnError false |
| 70 | + source = android.sourceSets.main.java.sourceFiles |
| 71 | + options { |
| 72 | + encoding = "utf-8" |
| 73 | + } |
| 74 | + classpath += project.files(android.getBootClasspath().join(File.pathSeparator)) |
| 75 | + classpath += configurations.compile |
| 76 | + } |
| 77 | + task javadocJar(type: Jar, dependsOn: javadoc) { |
| 78 | + classifier = 'javadoc' |
| 79 | + from javadoc.destinationDir |
| 80 | + } |
| 81 | + |
| 82 | + artifacts { |
| 83 | + archives sourcesJar |
| 84 | + archives javadocJar |
| 85 | + } |
| 86 | +} |
0 commit comments