|
1 | 1 | apply plugin: 'com.android.library' |
| 2 | +apply plugin: 'maven-publish' |
| 3 | +apply plugin: 'signing' |
2 | 4 |
|
3 | 5 | android { |
4 | 6 | // http://tools.android.com/tech-docs/new-build-system/tips |
@@ -28,3 +30,104 @@ dependencies { |
28 | 30 | } |
29 | 31 |
|
30 | 32 | apply from: new File(rootProject.projectDir, "tools/gradle-on-demand.gradle"); |
| 33 | + |
| 34 | + |
| 35 | +task androidJavadocs(type: Javadoc) { |
| 36 | + failOnError false |
| 37 | + source = android.sourceSets.main.java.srcDirs |
| 38 | + classpath += project.files(android.getBootClasspath().join(File.pathSeparator)) |
| 39 | + android.libraryVariants.all { variant -> |
| 40 | + if (variant.name == 'release') { |
| 41 | + owner.classpath += variant.javaCompile.classpath |
| 42 | + } |
| 43 | + } |
| 44 | + exclude '**/R.html', '**/R.*.html', '**/index.html' |
| 45 | +} |
| 46 | + |
| 47 | +task androidJavadocsJar(type: Jar, dependsOn: androidJavadocs) { |
| 48 | + classifier = 'javadoc' |
| 49 | + from androidJavadocs.destinationDir |
| 50 | +} |
| 51 | + |
| 52 | +task androidSourcesJar(type: Jar) { |
| 53 | + classifier = 'sources' |
| 54 | + from android.sourceSets.main.java.srcDirs |
| 55 | +} |
| 56 | + |
| 57 | +def libVersion = rootProject.ext.sdk.version |
| 58 | +ext.isReleaseVersion = !libVersion.endsWith("SNAPSHOT") |
| 59 | +publishing { |
| 60 | + publications { |
| 61 | + aar(MavenPublication) { |
| 62 | + groupId 'com.tencent.iot.thirdparty.android' |
| 63 | + artifactId 'ijkplayer-armv7a' |
| 64 | + version libVersion |
| 65 | + artifact(androidSourcesJar) |
| 66 | + artifact(androidJavadocsJar) |
| 67 | + artifact file('build/outputs/aar/ijkplayer-armv7a-release.aar') |
| 68 | + |
| 69 | + pom { |
| 70 | + name = 'ijkplayer' |
| 71 | + description = 'Tencent Link Android library' |
| 72 | + url = 'https://github.com/tencentyun/iot-ijkplayer' |
| 73 | + licenses { |
| 74 | + license { |
| 75 | + name = 'Tencent Binary License' |
| 76 | + url = 'https://github.com/tencentyun/iot-link-android/blob/master/explorer-link-android/LICENSE' |
| 77 | + } |
| 78 | + } |
| 79 | + developers { |
| 80 | + developer { |
| 81 | + id = 'tencent_archurtan' |
| 82 | + name = 'Tencent archurtan' |
| 83 | + email = 'archurtan@tencent.com' |
| 84 | + } |
| 85 | + } |
| 86 | + scm { |
| 87 | + url = 'scm:git@github.com:tencentyun/iot-ijkplayer.git' |
| 88 | + connection = 'scm:git@github.com:tencentyun/iot-ijkplayer.git' |
| 89 | + developerConnection = 'scm:git@github.com:tencentyun/iot-ijkplayer.git' |
| 90 | + } |
| 91 | + } |
| 92 | + |
| 93 | + pom.withXml { |
| 94 | + def dependenciesNode = asNode().appendNode('dependencies') |
| 95 | + configurations.implementation.allDependencies.withType(ModuleDependency) { ModuleDependency dp -> |
| 96 | + if (dp.version != "unspecified") { // 过滤项目内library引用 |
| 97 | + def dependencyNode = dependenciesNode.appendNode('dependency') |
| 98 | + dependencyNode.appendNode('groupId', dp.group) |
| 99 | + dependencyNode.appendNode('artifactId', dp.name) |
| 100 | + dependencyNode.appendNode('version', dp.version) |
| 101 | + |
| 102 | + // for exclusions |
| 103 | + if (dp.excludeRules.size() > 0) { |
| 104 | + def exclusions = dependencyNode.appendNode('exclusions') |
| 105 | + dp.excludeRules.each { ExcludeRule ex -> |
| 106 | + def exclusion = exclusions.appendNode('exclusion') |
| 107 | + exclusion.appendNode('groupId', ex.group) |
| 108 | + exclusion.appendNode('artifactId', ex.module) |
| 109 | + } |
| 110 | + } |
| 111 | + } |
| 112 | + } |
| 113 | + } |
| 114 | + } |
| 115 | + } |
| 116 | + repositories { |
| 117 | + maven { |
| 118 | + def releasesRepoUrl = "https://oss.sonatype.org/service/local/staging/deploy/maven2" |
| 119 | + def snapshotsRepoUrl = "https://oss.sonatype.org/content/repositories/snapshots" |
| 120 | + url = libVersion.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl |
| 121 | + credentials { |
| 122 | + username = System.getenv("IOT_SONATYPE_USERNAME") |
| 123 | + password = System.getenv("IOT_SONATYPE_PASSWORD") |
| 124 | + } |
| 125 | + } |
| 126 | + } |
| 127 | +} |
| 128 | + |
| 129 | +signing { |
| 130 | + if (isReleaseVersion) { |
| 131 | + sign publishing.publications.aar |
| 132 | + } |
| 133 | +} |
0 commit comments