Skip to content

Commit 7e5555b

Browse files
committed
maven 迁移中央仓库
1 parent 4ef9ca0 commit 7e5555b

File tree

3 files changed

+31
-95
lines changed

3 files changed

+31
-95
lines changed

.github/workflows/opensource.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ jobs:
6666
- name: Package apk and aar with Gradle
6767
run: ./gradlew assembleOpensource
6868
- name: Publish aar to Maven
69-
run: ./gradlew publish
69+
run: ./gradlew publishMavenPublicationToMavenCentralRepository
7070
- name: Archive the apk
7171
uses: actions/upload-artifact@v4
7272
with:

gradle.properties

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,5 @@ signing.keyId=MY_KEY_ID
2323
signing.password=MY_PASSWORD
2424
signing.secretKeyRingFile=MY_KEY_RING_FILE
2525
android.injected.testOnly = false
26+
mavenCentralUsername=${IOT_SONATYPE_USERNAME}
27+
mavenCentralPassword=${IOT_SONATYPE_PASSWORD}
Lines changed: 28 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
apply plugin: 'com.android.library'
2-
apply plugin: 'kotlin-android'
3-
apply plugin: 'maven-publish'
4-
apply plugin: 'signing'
5-
apply plugin: 'com.kezong.fat-aar'
1+
plugins {
2+
id 'com.android.library'
3+
id 'kotlin-android'
4+
id 'com.kezong.fat-aar'
5+
id "com.vanniktech.maven.publish" version "0.25.3"
6+
}
67

78
android {
89
compileSdkVersion 29
@@ -59,102 +60,35 @@ configurations.all {
5960
resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
6061
}
6162

62-
task androidJavadocs(type: Javadoc) {
63-
failOnError false
64-
source = android.sourceSets.main.java.srcDirs
65-
classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
66-
android.libraryVariants.all { variant ->
67-
if (variant.name == 'release') {
68-
owner.classpath += variant.javaCompile.classpath
69-
}
70-
}
71-
exclude '**/R.html', '**/R.*.html', '**/index.html'
72-
}
73-
74-
task androidJavadocsJar(type: Jar, dependsOn: androidJavadocs) {
75-
classifier = 'javadoc'
76-
from androidJavadocs.destinationDir
77-
}
78-
79-
task androidSourcesJar(type: Jar) {
80-
classifier = 'sources'
81-
from android.sourceSets.main.java.srcDirs
82-
}
83-
8463
def libVersion = rootProject.ext.android.videoSdkSnapshotVersion + '-SNAPSHOT'
8564
ext.isReleaseVersion = !libVersion.endsWith("SNAPSHOT")
86-
publishing {
87-
publications {
88-
aar(MavenPublication) {
89-
groupId 'com.tencent.iot.video'
90-
artifactId 'video-link-android'
91-
version libVersion
92-
artifact(androidSourcesJar)
93-
artifact(androidJavadocsJar)
94-
artifact file('build/outputs/aar/video-link-android-release.aar')
65+
mavenPublishing {
9566

96-
pom {
97-
name = 'video link android'
98-
description = 'Tencent Video Link Android library'
99-
url = 'https://github.com/tencentyun/iot-link-android/tree/master/video-link-android'
100-
licenses {
101-
license {
102-
name = 'Tencent Binary License'
103-
url = 'https://github.com/tencentyun/iot-link-android/blob/master/explorer-link-android/LICENSE'
104-
}
105-
}
106-
developers {
107-
developer {
108-
id = 'tencent_archurtan'
109-
name = 'Tencent archurtan'
110-
111-
}
112-
}
113-
scm {
114-
url = 'scm:[email protected]:tencentyun/iot-link-android.git'
115-
connection = 'scm:[email protected]:tencentyun/iot-link-android.git'
116-
developerConnection = 'scm:[email protected]:tencentyun/iot-link-android.git'
117-
}
118-
}
119-
120-
pom.withXml {
121-
def dependenciesNode = asNode().appendNode('dependencies')
122-
configurations.implementation.allDependencies.withType(ModuleDependency) { ModuleDependency dp ->
123-
if (dp.version != "unspecified") { // 过滤项目内library引用
124-
def dependencyNode = dependenciesNode.appendNode('dependency')
125-
dependencyNode.appendNode('groupId', dp.group)
126-
dependencyNode.appendNode('artifactId', dp.name)
127-
dependencyNode.appendNode('version', dp.version)
67+
coordinates("com.tencent.iot.video.android", "video-link-android", libVersion)
68+
publishToMavenCentral()
69+
signAllPublications()
12870

129-
// for exclusions
130-
if (dp.excludeRules.size() > 0) {
131-
def exclusions = dependencyNode.appendNode('exclusions')
132-
dp.excludeRules.each { ExcludeRule ex ->
133-
def exclusion = exclusions.appendNode('exclusion')
134-
exclusion.appendNode('groupId', ex.group)
135-
exclusion.appendNode('artifactId', ex.module)
136-
}
137-
}
138-
}
139-
}
71+
pom {
72+
name = 'video link android'
73+
description = 'Tencent Video Link Android library'
74+
url = 'https://github.com/tencentyun/iot-link-android/tree/master/video-link-android'
75+
licenses {
76+
license {
77+
name = 'Tencent Binary License'
78+
url = 'https://github.com/tencentyun/iot-link-android/blob/master/explorer-link-android/LICENSE'
14079
}
14180
}
142-
}
143-
repositories {
144-
maven {
145-
def releasesRepoUrl = "https://oss.sonatype.org/service/local/staging/deploy/maven2"
146-
def snapshotsRepoUrl = "https://oss.sonatype.org/content/repositories/snapshots"
147-
url = libVersion.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
148-
credentials {
149-
username = System.getenv("IOT_SONATYPE_USERNAME")
150-
password = System.getenv("IOT_SONATYPE_PASSWORD")
81+
developers {
82+
developer {
83+
id = 'tencent_archurtan'
84+
name = 'Tencent archurtan'
85+
15186
}
15287
}
153-
}
154-
}
155-
156-
signing {
157-
if (isReleaseVersion) {
158-
sign publishing.publications.aar
88+
scm {
89+
url = 'scm:[email protected]:tencentyun/iot-link-android.git'
90+
connection = 'scm:[email protected]:tencentyun/iot-link-android.git'
91+
developerConnection = 'scm:[email protected]:tencentyun/iot-link-android.git'
92+
}
15993
}
16094
}

0 commit comments

Comments
 (0)