Skip to content

Commit 5b280c6

Browse files
committed
添加 maven 插件及配置
1 parent 2b0c530 commit 5b280c6

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
plugins {
22
id 'com.android.application' version '8.4.2' apply false
33
id 'org.jetbrains.kotlin.android' version '1.6.21' apply false
4+
id 'maven-publish'
45
}
56

67
tasks.register('clean', Delete) {

library/build.gradle

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
apply plugin: 'com.android.library'
2+
apply plugin: 'maven-publish'
23
apply from : '../common.gradle'
34

45
android {
@@ -17,4 +18,32 @@ android {
1718
packageLib.exclude 'R.txt'
1819
}
1920
}
21+
}
22+
23+
publishing {
24+
publications {
25+
release(MavenPublication) {
26+
groupId = 'com.github.getActivity'
27+
artifactId = 'Toaster'
28+
version = android.defaultConfig.versionName
29+
// 指定 aar 文件的确切路径:https://cloud.tencent.com/developer/ask/sof/106381154
30+
afterEvaluate {
31+
artifact(bundleReleaseAar)
32+
}
33+
34+
// 修正 Maven 插件在生成的 pom 文件没有携带 dependencies 信息的问题
35+
// 用于测试 Gradle 命令:./gradlew publishToMavenLocal
36+
// 相关 Github 地址:https://github.com/getActivity/XXPermissions/issues/371#issuecomment-3018735968
37+
pom.withXml {
38+
def dependencies = asNode().appendNode('dependencies')
39+
configurations.implementation.allDependencies.each {
40+
def dependency = dependencies.appendNode('dependency')
41+
dependency.appendNode('groupId', it.group)
42+
dependency.appendNode('artifactId', it.name)
43+
dependency.appendNode('version', it.version)
44+
dependency.appendNode('scope', 'runtime')
45+
}
46+
}
47+
}
48+
}
2049
}

0 commit comments

Comments
 (0)