-
Notifications
You must be signed in to change notification settings - Fork 1
/
maven-push-release.gradle
131 lines (110 loc) · 4.06 KB
/
maven-push-release.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
group = "io.hyphenate"
archivesBaseName = "ease-chatroomui-kit"
version = "1.1.0"//发布aar的库版本
apply {
plugin 'maven-publish'
plugin 'signing'
}
def localProperties = new Properties()
localProperties.load(project.rootProject.file('local.properties').newDataInputStream())
Properties properties = new Properties()
properties.load(file(localProperties.getProperty('maven.dir')+"/project.properties").newDataInputStream())
def ossrhUsername = properties.getProperty('ossrhUsername')
def ossrhPassword = properties.getProperty('ossrhPassword')
//指定singing的相关信息
gradle.taskGraph.whenReady { taskGraph ->
if (taskGraph.allTasks.any { it instanceof Sign }) {
def id = properties.getProperty("signing.keyId")
def file = localProperties.getProperty('maven.dir')+properties.getProperty("signing.secretKeyRingFile").substring(1)
def password = properties.getProperty("signing.password")
allprojects { ext."signing.keyId" = id }
allprojects { ext."signing.secretKeyRingFile" = file }
allprojects { ext."signing.password" = password }
}
}
configurations {
deployerJars
}
task javadoc(type: Javadoc) {
options {
encoding 'UTF-8'
charSet 'UTF-8'
}
source = android.sourceSets.main.kotlin.srcDirs
classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
android.libraryVariants.all { variant ->
if (variant.name == 'release') {
owner.source = variant.javaCompiler.source
owner.classpath = files(android.bootClasspath.join(File.pathSeparator))
owner.classpath += variant.javaCompiler.classpath
}
}
failOnError false
}
task javadocJar(type: Jar, dependsOn: javadoc) {
// classifier = 'javadoc'
// 8.0 使用 archiveClassifier 代替 classifier
archiveClassifier = 'javadoc'
from javadoc.destinationDir
}
task sourcesJar(type: Jar) {
//from android.sourceSets.main.kotlin.srcDirs
//def dirs = android.sourceSets.getByName("main").java.srcDirs
from android.sourceSets.main.kotlin.srcDirs
//classifier = 'sources'
// 8.0 使用 archiveClassifier 代替 classifier
archiveClassifier = 'sources'
}
afterEvaluate {
publishing {
publications {
release(MavenPublication) {
groupId = group
artifactId = archivesBaseName
version = version
afterEvaluate {
from components.release
}
// 设置要发布的文件
artifact sourcesJar
artifact javadocJar
signing.sign publishing.publications.release
pom {
name = archivesBaseName
description = "Easy ChatroomUI for Easemob IM SDK"
url = "https://github.com/easemob/UIKit_Chatroom_android"
scm {
connection = "scm:[email protected]:easemob/UIKit_Chatroom_android.git"
developerConnection = "scm:[email protected]:easemob/UIKit_Chatroom_android.git"
url = "https://github.com/easemob/UIKit_Chatroom_android.git"
}
licenses {
license {
name = "The Apache Software License, Version 2.0"
url = "http://www.apache.org/licenses/LICENSE-2.0.txt"
}
}
developers {
developer {
id = "Easemob"
name = "Easemob"
email = "[email protected]"
}
}
}
}
}
}
}
publishing {
repositories {
maven {
name = "ossrh"
url = uri("https://oss.sonatype.org/service/local/staging/deploy/maven2/")
credentials {
username = ossrhUsername
password = ossrhPassword
}
}
}
}