forked from honeybadger-io/honeybadger-java
-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.gradle
312 lines (259 loc) · 9.54 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
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
buildscript {
repositories { jcenter() }
dependencies {
classpath 'com.github.jengelman.gradle.plugins:shadow:+'
}
}
apply plugin: 'java'
apply plugin: 'application'
apply plugin: 'maven'
apply plugin: 'maven-publish'
apply plugin: 'signing'
apply plugin: 'idea'
apply plugin: 'com.github.johnrengelman.shadow'
group = 'io.honeybadger'
version = '1.0.9'
sourceCompatibility = 1.7
targetCompatibility = 1.7
archivesBaseName = rootProject.name
mainClassName = "io.honeybadger.reporter.HoneybadgerCLI"
task wrapper(type: Wrapper) {
gradleVersion = '2.4'
distributionUrl = "https://services.gradle.org/distributions/gradle-$gradleVersion-all.zip"
}
run {
standardInput = System.in
}
repositories {
mavenCentral()
mavenLocal()
}
configurations {
providedCompile
providedCompile.extendsFrom(compile)
}
javadoc {
classpath = sourceSets.main.output + sourceSets.main.compileClasspath +
configurations.providedCompile
}
sourceSets {
main {
compileClasspath += configurations.providedCompile
}
test {
compileClasspath += configurations.providedCompile
runtimeClasspath += configurations.providedCompile
}
integration {
java.srcDir file('src/integration/java')
resources.srcDir file('src/main/resources')
compileClasspath = sourceSets.main.output +
sourceSets.test.output +
configurations.testRuntime +
configurations.providedCompile
runtimeClasspath = output + compileClasspath
}
}
dependencies {
// We compile against the servlet API, but we don't bring it into the dependency graph
// because the implementation is typically provided by the application server
providedCompile 'javax.servlet:javax.servlet-api:3.1.0'
providedCompile 'com.typesafe.play:play_2.10:2.4.2'
// logging facade that allows users of the library to use their own logging implementations
// This is the one unshadowed dependency
compile 'org.slf4j:slf4j-api:1.7.12'
// ==========================================================================
// NOTE: If you are adding a dependency, be sure to shadow it in the settings
// below the dependencies section.
// ==========================================================================
// JSON processing
compile 'com.google.code.gson:gson:2.3.1'
// HTTP requesting library - used to talk to the Honeybadger API
compile('org.apache.httpcomponents:fluent-hc:4.5') {
// we exclude commons logging because we replace it with a shadowed
// jcl-over-slf4j in order to redirect all logging messages over
// the slf4j interface
exclude group: 'commons-logging'
}
// Used so we don't have to pull in commons-logging as a dependency
compile 'org.slf4j:jcl-over-slf4j:1.7.12'
// Used to get the Honeybadger library version from the JAR manifest
compile 'com.jcabi:jcabi-manifests:1.1'
// Used for rendering HTML error page templates
compile 'com.github.spullara.mustache.java:compiler:0.8.18'
// Utilities for testing below
testCompile ('com.google.guava:guava:18.0') {
exclude group: 'org.slf4j'
}
testCompile 'junit:junit:4.12'
testCompile 'ch.qos.logback:logback-classic:1.1.3'
testCompile 'org.mockito:mockito-all:1.10.19'
testCompile 'com.github.fge:json-schema-validator:2.2.6'
}
// We don't generate an unshadowed jar
jar {
onlyIf { false }
doFirst {
manifest {
attributes("Honeybadger-Java-Version": version)
}
}
}
// By default we include all (but one) dependencies and remap their packge names
// so that they won't conflict with other dependencies in the graph.
shadowJar {
baseName = "${rootProject.name}"
classifier = ''
doFirst {
// We set the version of the library here so that we can get at it
// at runtime and send it to the Honeybadger API as part of its
// diagnostic data.
manifest {
attributes("Honeybadger-Java-Version": version)
}
}
relocate 'com.google', 'io.honeybadger.com.google'
relocate 'org.apache', 'io.honeybadger.org.apache'
relocate 'com.jcabi', 'io.honeybadger.com.jcabi'
relocate 'com.github', 'io.honeybadger.com.github'
exclude 'org/slf4j/**'
}
def installer = install.repositories.mavenInstaller
// Remove everything but slf4j
[installer]*.pom*.whenConfigured {pom ->
pom.dependencies.retainAll {
(it.artifactId == 'slf4j-api' && it.groupId == 'org.slf4j') ||
it.scope != "compile"
}
}
publishing {
publications {
shadow(MavenPublication) {
from components.shadow
artifactId = "${rootProject.name}"
}
}
}
task sourcesJar(type: Jar) {
classifier = 'sources'
from sourceSets.main.allJava
}
task javadocJar(type: Jar) {
classifier = 'javadoc'
from javadoc
}
task integration(type: Test) {
group = 'Verification'
description = 'Runs the integration tests.'
testClassesDir = sourceSets.integration.output.classesDir
classpath = sourceSets.integration.runtimeClasspath
}
// Dumps system properties to STDOUT
task showSystemProperties << {
System.properties.each { k, v -> println "${k}:${v}" }
}
tasks.withType(Test) {
def apiKeyProp = "honeybadger.api_key"
def readApiKeyProp = "honeybadger.read_api_key"
if (!System.getProperty(apiKeyProp) && !System.getenv("HONEYBADGER_API_KEY")) {
println 'No API key'
def msg = "${apiKeyProp} system property must be specified"
throw new org.gradle.api.InvalidUserDataException(msg)
}
// Assume a default environment of test if it isn't specified
systemProperty 'ENV', System.getProperty('ENV', 'TEST')
systemProperty 'honeybadger.version', version
systemProperty 'honeybadger.application_package', 'io.honeybadger'
def passSysProp = { String prop ->
systemProperty prop, System.getProperty(prop)
}
// White-listed system properties that can be passed from gradle.properties
passSysProp(apiKeyProp)
passSysProp(readApiKeyProp)
passSysProp('honeybadger.url')
passSysProp('http.proxyHost')
passSysProp('http.proxyPort')
passSysProp('honeybadger.excluded_exception_classes')
passSysProp('honeybadger.excluded_sys_props')
}
// Task dependency definitions
jar.dependsOn(shadowJar)
check.dependsOn(integration)
integration.mustRunAfter test
artifacts {
archives javadocJar, sourcesJar, shadowJar
}
signing {
sign configurations.archives
}
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
artifact sourcesJar {
classifier "sources"
}
// This messy thing is here to add proper exclusions to
// generated POMs
project.configurations[JavaPlugin.RUNTIME_CONFIGURATION_NAME].allDependencies.findAll {
it instanceof ModuleDependency && !it.excludeRules.isEmpty()
}.each { ModuleDependency dep ->
pom.withXml {
def xmlDep = asNode().dependencies.dependency.find {
it.groupId[0].text() == dep.group && it.artifactId[0].text() == dep.name
}
def xmlExclusions = xmlDep.exclusions[0]
if (!xmlExclusions) xmlExclusions = xmlDep.appendNode('exclusions')
dep.excludeRules.each { ExcludeRule rule ->
def xmlExclusion = xmlExclusions.appendNode('exclusion')
xmlExclusion.appendNode('groupId', rule.group)
xmlExclusion.appendNode('artifactId', rule.module)
}
}
}
}
}
}
uploadArchives {
repositories {
mavenDeployer {
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") {
authentication(userName: ossrhUsername, password: ossrhPassword)
}
snapshotRepository(url: "https://oss.sonatype.org/content/repositories/snapshots/") {
authentication(userName: ossrhUsername, password: ossrhPassword)
}
pom.project {
name 'Honeybadger Java Client'
packaging 'jar'
description 'Library that sends exceptions to the online error management service Honeybadger.'
url 'https://github.com/honeybadger-io/honeybadger-java'
scm {
connection 'scm:git:[email protected]:honeybadger-io/honeybadger-jvm-client-v2.git'
developerConnection 'scm:git:[email protected]:honeybadger-io/honeybadger-java.git'
url '[email protected]:honeybadger-io/honeybadger-java.git'
}
licenses {
license {
name 'MIT License'
url 'https://raw.githubusercontent.com/honeybadger-io/honeybadger-java/master/LICENSE'
}
}
developers {
developer {
id 'elijah'
name 'Elijah Zupancic'
email '[email protected]'
organizationUrl 'https://github.com/dekobon'
}
}
}
}
}
}
idea {
module {
scopes.PROVIDED.plus += [configurations.providedCompile]
}
}