-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
226 lines (192 loc) · 6.47 KB
/
build.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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
import java.text.SimpleDateFormat
plugins {
// 上传到 jCenter
id "com.jfrog.bintray" version "1.7.3"
// https://github.com/Codearte/gradle-nexus-staging-plugin/
// 用于自动在 https://oss.sonatype.org/ 上执行 close、release 等相关操作
// id 'io.codearte.nexus-staging' version '0.11.0'
}
ext {
scm = [
url : 'https://github.com/someok/someok-restdocs-extend',
connection : 'https://github.com/someok/someok-restdocs-extend.git',
developerConnection: 'git@github.com:someok/someok-restdocs-extend.git',
]
defaultManifest = { proj ->
return manifest {
def buildTimeAndDate = new Date()
def buildDate = new SimpleDateFormat('yyyy-MM-dd').format(buildTimeAndDate)
def buildTime = new SimpleDateFormat('HH:mm').format(buildTimeAndDate)
def git_cmd = "git rev-parse HEAD"
def git_proc = git_cmd.execute()
attributes 'SCM-Revision': git_proc.text.trim()
attributes 'Built-By': System.properties['user.name']
attributes 'Created-By': System.properties['java.version'] + " (" + System.properties['java.vendor'] + " " + System.getProperty("java.vm.version") + ")"
attributes 'Build-Host': InetAddress.localHost.hostName
attributes 'Build-Date': buildDate
attributes 'Build-Time': buildTime
attributes 'Timestamp': String.valueOf(System.currentTimeMillis())
attributes 'Specification-Title': proj.archivesBaseName
attributes 'Specification-Version': proj.version
attributes 'Specification-Vendor': 'someok.com'
attributes 'Implementation-Title': proj.archivesBaseName
attributes 'Implementation-Version': proj.version
attributes 'Implementation-Vendor': 'someok.com'
attributes 'provider': 'gradle'
}
}
}
apply plugin: 'java'
apply plugin: 'maven'
apply plugin: 'maven-publish'
apply plugin: 'signing'
sourceCompatibility = project_jdk
targetCompatibility = project_jdk
repositories {
mavenCentral()
}
dependencies {
// 这儿需要使用 compile,而不能用 api,因为 artifacts 不支持
compile 'org.springframework.restdocs:spring-restdocs-core:1.2.2.RELEASE'
compile 'org.springframework.restdocs:spring-restdocs-mockmvc:1.2.2.RELEASE'
testImplementation group: 'junit', name: 'junit', version: '4.12'
}
javadoc {
options {
encoding 'UTF-8'
charSet 'UTF-8'
author true
version true
noSince false
}
}
jar {
excludes = ['**/rebel.xml']
doFirst {
manifest = defaultManifest({ project })
}
}
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
doFirst {
manifest = defaultManifest({ project })
}
}
task sourcesJar(type: Jar) {
classifier = 'sources'
from sourceSets.main.allSource
doFirst {
manifest = defaultManifest({ project })
}
}
artifacts {
archives jar
archives javadocJar
archives sourcesJar
}
// jCenter 相关设置
bintray {
user = bintrayUsername
key = bintrayApiKey
publications = ['jCenterPublish']
publish = true
pkg {
repo = 'maven'
name = project.name
desc = project.description
version {
name = project.version
vcsTag = project.version
released = new Date()
gpg {
sign = true //Determines whether to GPG sign the files. The default is false
passphrase = gpgPassword //Optional. The passphrase for GPG signing'
}
mavenCentralSync {
sync = true
//[Default: true] Determines whether to sync the version to Maven Central.
user = sonatypeUsername //OSS user token: mandatory
password = sonatypePassword //OSS user password: mandatory
close = '1'
//Optional property. By default the staging repository is closed and artifacts are released to Maven Central. You can optionally turn this behaviour off (by puting 0 as value) and release the version manually.
}
}
userOrg = 'someok'
labels = ['spring-restdocs', 'java', 'asciidoc']
licenses = ['MIT']
websiteUrl = scm.url
vcsUrl = scm.connection
publicDownloadNumbers = true
}
}
def pomConfig = {
packaging 'jar'
name project.name
description project.description
url scm.url
scm {
url scm.url
connection scm.connection
developerConnection scm.developerConnection
}
licenses {
license {
name 'MIT'
url 'https://raw.githubusercontent.com/someok/someok-restdocs-extend/master/LICENSE'
distribution 'repo'
}
}
developers {
developer {
id 'someok'
name 'JX Wang'
email 'wjianxu@gmail.com'
url 'https://github.com/someok'
timezone 'Asia/Shanghai'
}
}
issueManagement {
system 'github'
url 'https://github.com/someok/someok-restdocs-extend/issues'
}
}
publishing {
publications {
jCenterPublish(MavenPublication) {
from components.java
artifact sourcesJar
artifact javadocJar
groupId project.group
artifactId project.name
version project.version
pom.withXml {
def root = asNode()
root.appendNode('description', project.description)
// root.appendNode('name', 'Your name of the lib')
// root.appendNode('url', 'https://site_for_lib.tld')
root.children().last() + pomConfig
}
}
}
}
/*
signing {
required { gradle.taskGraph.hasTask("uploadArchives") }
sign configurations.archives
}
uploadArchives {
repositories {
mavenDeployer {
beforeDeployment { deployment -> signing.signPom(deployment) }
repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") {
authentication(userName: sonatypeUsername, password: sonatypePassword)
}
snapshotRepository(url: "https://oss.sonatype.org/content/repositories/snapshots") {
authentication(userName: sonatypeUsername, password: sonatypePassword)
}
pom.project pomConfig
}
}
}
*/