-
Notifications
You must be signed in to change notification settings - Fork 26
/
build.gradle
231 lines (215 loc) · 5.52 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
buildscript {
repositories {
jcenter()
}
dependencies {
// applies the Eclipse java formatter
classpath "com.diffplug.gradle.spotless:spotless:${VER_SPOTLESS}"
// uploads artifacts to jcenter
classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:${VER_BINTRAY}"
configurations.all {
resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
}
}
}
repositories {
jcenter()
}
//////////
// JAVA //
//////////
apply plugin: 'java'
sourceSets {
main { java {
srcDir 'src'
} }
test { java {
srcDir 'test'
} }
}
sourceCompatibility = VER_JAVA
targetCompatibility = VER_JAVA
dependencies {
testCompile "com.google.guava:guava:${VER_GUAVA}"
testCompile "com.google.guava:guava-testlib:${VER_GUAVA}"
testCompile "junit:junit:${VER_JUNIT}"
}
jar.manifest {
from 'META-INF/MANIFEST.MF'
}
/////////////
// ECLIPSE //
/////////////
apply plugin: 'eclipse'
eclipse {
project {
natures 'org.eclipse.pde.PluginNature'
natures 'org.eclipse.jdt.core.javanature'
buildCommand 'org.eclipse.jdt.core.javabuilder'
buildCommand 'org.eclipse.pde.ManifestBuilder'
buildCommand 'org.eclipse.pde.SchemaBuilder'
}
classpath {
downloadSources true
downloadJavadoc true
}
jdt {
sourceCompatibility VER_JAVA
targetCompatibility VER_JAVA
}
}
// always create fresh projects
tasks.eclipse.dependsOn(cleanEclipse)
////////////
// FORMAT //
////////////
apply plugin: 'com.diffplug.gradle.spotless'
spotless {
java {
licenseHeaderFile 'spotless.license.java' // License header file
importOrderFile 'spotless.importorder' // An import ordering file, exported from Eclipse
eclipseFormatFile 'spotless.eclipseformat.xml' // XML file dumped out by the Eclipse formatter
// Eclipse formatter puts excess whitespace after lambda blocks
// funcThatTakesLambdas(x -> {} , y -> {} ) // what Eclipse does
// funcThatTakesLambdas(x -> {}, y -> {}) // what I wish Eclipse did
custom 'Lambda fix', { it.replace('} )', '})').replace('} ,', '},') }
}
format 'misc', {
target '**/*.gradle', '**/*.md', '**/.gitignore'
indentWithTabs()
trimTrailingWhitespace()
endWithNewline()
}
}
//////////////
// FINDBUGS //
//////////////
apply plugin: 'findbugs'
findbugs {
toolVersion = VER_FINDBUGS
sourceSets = [sourceSets.main] // don't check the test code
ignoreFailures = false // bug free or it doesn't ship!
reportsDir = file('build/findbugs')
effort = 'max' // min|default|max
reportLevel = 'low' // low|medium|high (low = sensitive to even minor mistakes)
omitVisitors = [] // bugs that we want to ignore
}
// HTML instead of XML
tasks.withType(FindBugs) {
reports {
xml.enabled = false
html.enabled = true
}
}
// we'll want the findbugs annotations (they don't have a 3.0.1 version)
dependencies {
compile 'com.google.code.findbugs:annotations:3.0.0'
compile 'com.google.code.findbugs:jsr305:3.0.0'
}
///////////
// MAVEN //
///////////
apply plugin: 'maven-publish'
task sourcesJar(type: Jar) {
classifier = 'sources'
from sourceSets.main.allJava
}
// Where it's possible to name parameters and methods clearly enough
// that javadoc is not necessary, why make the code bigger?
//
// Thus, no javadoc warnings.
javadoc {
options.addStringOption('Xdoclint:none', '-quiet')
}
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
}
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
artifact sourcesJar
artifact javadocJar
pom.withXml {
// findbugs annotations should have scope "provided"
asNode().dependencies.'*'.findAll() { it.groupId.text() == 'com.google.code.findbugs' }.each() { it.scope*.value = 'provided' }
// add MavenCentral requirements to the POM
asNode().children().last() + {
resolveStrategy = Closure.DELEGATE_FIRST
name project.name
description project.description
url "https://github.com/${org}/${name}"
scm {
url "https://github.com/${org}/${name}"
connection "scm:git:git://github.com/${org}/${name}"
developerConnection "scm:git:ssh:git@github.com/${org}/${name}"
}
licenses {
license {
name 'The Apache Software License, Version 2.0'
url 'http://www.apache.org/license/LICENSE-2.0.txt'
distribution 'repo'
}
}
developers {
developer {
id 'nedtwigg'
name 'Ned Twigg'
email 'ned.twigg@diffplug.com'
}
}
}
}
}
}
if (project.hasProperty('dp_maven')) {
repositories {
maven {
if (project.version.endsWith('-SNAPSHOT')) {
url "${dp_maven}/libs-snapshot-local"
} else {
url "${dp_maven}/libs-release-local"
}
credentials {
username "${dp_maven_user}"
password "${dp_maven_pass}"
}
}
}
}
}
/////////////
// BINTRAY //
/////////////
if (project.hasProperty('dp_bintray_user')) {
apply plugin: 'com.jfrog.bintray'
bintray {
user = dp_bintray_user
key = dp_bintray_key
publish=false
publications = ['mavenJava']
pkg {
repo = 'opensource'
name = project.name
userOrg = project.org
desc = project.description
websiteUrl = "https://github.com/${org}/${name}"
issueTrackerUrl = "https://github.com/${org}/${name}/issues"
vcsUrl = "https://github.com/${org}/${name}"
licenses = ['Apache-2.0']
publicDownloadNumbers = true
// Optional version descriptor
version {
name = project.version
if (project.version.endsWith('SNAPSHOT')) {
vcsTag = 'develop'
} else {
vcsTag = 'v' + project.version
}
}
}
}
// surprisingly, this actually needs to be here
bintrayUpload.dependsOn(publish)
}