-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbuild.gradle
227 lines (195 loc) · 6.19 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
227
plugins {
id 'com.jfrog.bintray' version '1.8.4'
id 'co.riiid.gradle' version '0.4.2'
id 'io.freefair.lombok' version '4.1.5'
id 'idea'
id 'java'
id 'maven'
}
sourceCompatibility = '1.8'
targetCompatibility = '1.8'
ext {
versions = [:]
versions.jackson = '2.10.0'
versions.httpclient = '4.5.10'
versions.commonsLang = '3.9'
versions.junit = '4.12'
versions.hamcrest = '1.3'
versions.mockito = '3.1.0'
versions.jsonassert = '1.5.0'
versions.slf4j = '1.7.29'
}
repositories {
jcenter()
mavenCentral()
}
sourceSets {
itest {
compileClasspath += main.output
runtimeClasspath += main.output
java.srcDir file('src/itest/java')
}
}
generateLombokConfig.enabled = false
configurations {
itestCompileOnly.extendsFrom compileOnly
itestAnnotationProcessor.extendsFrom annotationProcessor
itestImplementation.extendsFrom implementation
itestImplementation.extendsFrom testImplementation
}
idea {
module {
downloadSources = true
downloadJavadoc = true
testSourceDirs = testSourceDirs + sourceSets.itest.allJava.srcDirs
testResourceDirs = testResourceDirs + sourceSets.itest.resources.srcDirs
}
}
build {
dependsOn javadoc
}
processResources {
expand(project.properties)
}
dependencies {
implementation "com.fasterxml.jackson.core:jackson-core:${versions.jackson}"
implementation "com.fasterxml.jackson.core:jackson-annotations:${versions.jackson}"
implementation "com.fasterxml.jackson.core:jackson-databind:${versions.jackson}"
implementation "org.apache.httpcomponents:httpclient:${versions.httpclient}"
implementation "org.apache.httpcomponents:httpmime:${versions.httpclient}"
implementation "org.apache.commons:commons-lang3:${versions.commonsLang}"
testImplementation("junit:junit:${versions.junit}") {
exclude module: 'hamcrest'
exclude module: 'hamcrest-core'
}
testImplementation "org.hamcrest:hamcrest-all:${versions.hamcrest}"
testImplementation "org.mockito:mockito-core:${versions.mockito}"
testImplementation "org.skyscreamer:jsonassert:${versions.jsonassert}"
testImplementation "org.slf4j:slf4j-api:${versions.slf4j}"
testImplementation "org.slf4j:slf4j-simple:${versions.slf4j}"
}
task itest(type: Test) {
testClassesDirs = sourceSets.itest.output.classesDirs
classpath = sourceSets.itest.runtimeClasspath + sourceSets.test.runtimeClasspath
systemProperty "testApiUsername", sysProp("testApiUsername")
systemProperty "testApiPassword", sysProp("testApiPassword")
systemProperty "testAccountName", sysProp("testAccountName")
systemProperty "testAccountPassword", sysProp("testAccountPassword")
systemProperty "testCallerId", sysProp("testCallerId")
}
task sourcesJar(type: Jar, dependsOn: classes) {
archiveClassifier.set('sources')
from sourceSets.main.allSource
}
task javadocJar(type: Jar, dependsOn: javadoc) {
archiveClassifier.set('javadoc')
from javadoc.destinationDir
}
task clientFatJar(type: Jar, dependsOn: jar) {
archiveClassifier.set('all')
from {
[
sourceSets.main.output,
configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) }
]
}
}
tasks.withType(Jar) {
manifest.attributes(
'Manifest-Version': '1.0',
'Implementation-Title': archiveBaseName,
'Implementation-Version': archiveVersion,
'Implementation-Build-Number': sysProp('BUILD_NUMBER'),
'Implementation-Vendor': project.orgName,
'Implementation-Build-Date': new Date().format('yyyy-MM-dd'),
'Implementation-Build-JDK': sysProp('java.version'),
'Implementation-Build-Gradle': gradle.gradleVersion,
'Implementation-Target-JDK': project.targetCompatibility,
'Description': project.description,
'Documentation': project.docsUrl,
'Repository': project.vcsUrl)
into('META-INF') { from 'LICENSE.txt' }
}
javadoc {
failOnError = false
source = delombok
}
task generatePom {
doLast {
pom {
project {
inceptionYear '2015'
licenses {
license {
name "The MIT License (MIT)"
url "https://opensource.org/licenses/MIT"
distribution "repo"
}
}
developers {
developer {
id "vladimir-mhl"
name "Vladimir Mikhailov"
email "vmikhailov@callfire.com"
}
}
}
}
.withXml {
asNode().dependencies.'*'
.findAll { it.scope.text() == 'test' }
.each { it.parent().remove(it) }
}
.writeTo("build/META-INF/maven/${project.group}/${project.name}/pom.xml")
}
}
jar {
into('META-INF') {
from 'build/META-INF'
}
dependsOn generatePom
}
artifacts {
archives sourcesJar
archives javadocJar
}
github {
def assetPath = "build/libs/${project.name}-${project.version}"
repo = project.repoName
owner = sysProp('gitHubOwner')
token = sysProp('gitHubToken')
tagName = project.version
targetCommitish = 'master'
name = project.version
body = releaseNotes()
assets = [
"${assetPath}-all.jar",
"${assetPath}-javadoc.jar",
"${assetPath}-sources.jar",
"${assetPath}.jar"
]
}
bintray {
user = sysProp('BINTRAY_USER')
key = sysProp('BINTRAY_KEY')
configurations = ['archives']
publish = true
pkg {
repo = 'maven'
name = project.repoName
desc = project.description
websiteUrl = project.orgUrl
issueTrackerUrl = project.issueTrackerUrl
vcsUrl = project.vcsUrl
licenses = ['MIT']
labels = ['callfire', 'api', 'client']
publicDownloadNumbers = true
}
}
def releaseNotes() {
def matches = file('Changelog.txt').text =~ /(?s)Version .+?\n(.+?)(?=Version)/
matches.count > 0 ? matches[0][1] : 'N/A'
}
static def sysProp(String name) {
"${System.properties[name] ?: 'not set'}"
}