11apply plugin : ' com.android.library'
2- apply plugin : ' maven-publish'
3- apply plugin : ' signing'
42
53android {
64 compileSdkVersion 29
@@ -24,101 +22,3 @@ dependencies {
2422}
2523
2624
27- task androidSourcesJar (type : Jar ) {
28- archiveClassifier. set(" sources" )
29- from android. sourceSets. main. java. source
30- exclude " **/R.class"
31- exclude " **/BuildConfig.class"
32- }
33-
34- publishing {
35- // 定义发布什么
36- publications {
37- mavenJava(MavenPublication ) {
38- // group id,发布后引用的依赖的 group id
39- groupId ' io.github.weidongjian'
40- // 发布后引用的依赖的 artifact id
41- artifactId ' wheelview'
42- // 发布的版本
43- version ' 1.0.0'
44- // 发布的 arr 的文件和源码文件
45- artifact(" $buildDir /outputs/aar/${ project.getName()} -release.aar" )
46- artifact androidSourcesJar
47- pom {
48- // 构件名称,可以自定义
49- name = ' wheelview'
50- // 构件描述
51- description = ' Android Wheel View'
52- // 构件主页
53- url = ' https://github.com/weidongjian/androidWheelView'
54- // 许可证名称和地址
55- licenses {
56- license {
57- name = ' The Apache License, Version 2.0'
58- url = ' http://www.apache.org/licenses/LICENSE-2.0.txt'
59- }
60- }
61- // 开发者信息
62- developers {
63- developer {
64- name = ' weidongjian'
65- email = ' weidongjian@gmail.com'
66- }
67- }
68- // 版本控制仓库地址
69- scm {
70- url = ' https://github.com/weidongjian/androidWheelView'
71- connection = ' https://github.com/weidongjian/androidWheelView.git'
72- developerConnection = ' git@github.com:weidongjian/androidWheelView.git'
73- }
74- // 解决依赖关系
75- withXml {
76- def dependenciesNode = asNode(). appendNode(' dependencies' )
77- project. configurations. all { configuration ->
78- def name = configuration. name
79- if (name != " implementation" && name != " compile" && name != " api" ) {
80- return
81- }
82- println (configuration)
83- configuration. dependencies. each {
84- println (it)
85- if (it. name == " unspecified" ) {
86- // 忽略无法识别的
87- return
88- }
89- def dependencyNode = dependenciesNode. appendNode(' dependency' )
90- dependencyNode. appendNode(' groupId' , it. group)
91- dependencyNode. appendNode(' artifactId' , it. name)
92- dependencyNode. appendNode(' version' , it. version)
93- if (name == " api" || name == " compile" ) {
94- dependencyNode. appendNode(" scope" , " compile" )
95- } else { // implementation
96- dependencyNode. appendNode(" scope" , " runtime" )
97- }
98- }
99- }
100- }
101- }
102- }
103- }
104- // 定义发布到哪里
105- repositories {
106- maven {
107- // 发布的位置,这里根据发布的版本区分了 SNAPSHOT 和最终版本两种情况
108- def releasesRepoUrl = " https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/"
109- def snapshotsRepoUrl = " https://s01.oss.sonatype.org/content/repositories/snapshots/"
110- url = version. endsWith(' SNAPSHOT' ) ? snapshotsRepoUrl : releasesRepoUrl
111- credentials {
112- // 这里就是之前在 issues.sonatype.org 注册的账号
113- username project. sonatypeUsername
114- password project. sonatypePassword
115- }
116- }
117- }
118- }
119-
120- signing {
121- sign publishing. publications
122- }
123-
124-
0 commit comments