-
Notifications
You must be signed in to change notification settings - Fork 2
/
publish.gradle
147 lines (131 loc) · 5.25 KB
/
publish.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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
apply plugin: 'maven-publish'
apply plugin: 'signing'
task generateSourcesJar(type: Jar) {
archiveClassifier.set('sources')
if (JAVA_LIB == "true"){
from sourceSets.main.allSource
}else {
from android.sourceSets.main.java.srcDirs
}
}
task javadocsJar(type: Jar, dependsOn: generateSourcesJar) {
archiveClassifier.set('javadoc')
}
ext {
PUBLISH_GROUP_ID = 'io.github.sunshaobei'
PUBLISH_VERSION = '1.0.0'
PUBLISH_ARTIFACT_ID = "sliver"
}
ext["signing.keyId"] = ''
ext["signing.password"] = ''
ext["signing.secretKeyRingFile"] = ''
ext["ossrhUsername"] = ''
ext["ossrhPassword"] = ''
File secretPropsFile = project.rootProject.file('local.properties')
if (secretPropsFile.exists()) {
println "Found secret props file, loading props"
Properties p = new Properties()
p.load(new FileInputStream(secretPropsFile))
p.each { name, value ->
ext[name] = value
println value
}
} else {
println "No props file, loading env vars"
}
afterEvaluate {
publishing {
publications {
if (JAVA_LIB == "true"){
java(MavenPublication) {
// Applies the component for the release build variant.
from components.java
// You can then customize attributes of the publication as shown below.
groupId = POM_GROUPID
artifactId = POM_ARTIFACTID
version = POM_VERSION
artifact generateSourcesJar
artifact javadocsJar
pom {
name = POM_ARTIFACTID
description = POM_ARTIFACTID
url = 'https://github.com/sunshaobei/Satis'
licenses {
license {
name = 'The Apache Software License, Version 2.0'
url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
distribution = 'repo'
comments = 'A business-friendly OSS license'
}
}
developers {
developer {
id = 'sunshaobei'
name = 'sunshaobei'
email = '[email protected]'
url = 'https://github.com/sunshaobei/Satis'
}
}
scm {
url = 'https://github.com/sunshaobei/Satis'
connection = 'scm:git@https://github.com/sunshaobei/Satis.git'
developerConnection = 'scm:git@https://github.com/sunshaobei/Satis.git'
}
}
}
}else {
release(MavenPublication) {
// Applies the component for the release build variant.
from components.release
// You can then customize attributes of the publication as shown below.
groupId = POM_GROUPID
artifactId = POM_ARTIFACTID
version = POM_VERSION
artifact generateSourcesJar
artifact javadocsJar
pom {
name = POM_ARTIFACTID
description = POM_ARTIFACTID
url = 'https://github.com/sunshaobei/Satis'
licenses {
license {
name = 'The Apache Software License, Version 2.0'
url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
distribution = 'repo'
comments = 'A business-friendly OSS license'
}
}
developers {
developer {
id = 'sunshaobei'
name = 'sunshaobei'
email = '[email protected]'
url = 'https://github.com/sunshaobei/Satis'
}
}
scm {
url = 'https://github.com/sunshaobei/Satis'
connection = 'scm:git@https://github.com/sunshaobei/Satis.git'
developerConnection = 'scm:git@https://github.com/sunshaobei/Satis.git'
}
}
}
}
}
repositories {
// The repository to publish to, Sonatype/MavenCentral
maven {
url = (POM_VERSION.endsWith('SNAPSHOT') || POM_VERSION.endsWith('snapshot')) ? SNAPSHOT_URL : RELEASE_URL
System.out.println("上传至:"+url)
credentials {
username = ossrhUsername
password = ossrhPassword
}
}
signing {
sign publishing.publications
}
}
}
}
// 58584D12