-
Notifications
You must be signed in to change notification settings - Fork 30
/
Copy pathbuild.gradle
392 lines (369 loc) · 12 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
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
buildscript {
repositories {
jcenter()
maven { url "https://plugins.gradle.org/m2/" }
}
dependencies {
// markdown javadoc
classpath "ch.raffael.pegdown-doclet:pegdown-doclet:${VER_PEGDOWN_DOCLET}"
// code formatting
classpath "com.diffplug.spotless:spotless-plugin-gradle:${VER_SPOTLESS}"
// bintray uploading
classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:${VER_BINTRAY}"
// gradle plugin portal
classpath "com.gradle.publish:plugin-publish-plugin:${VER_GRADLE_PORTAL}"
}
}
plugins {
// github pages
id "org.ajoberstar.github-pages" version "1.4.2"
}
repositories {
mavenCentral()
// Future versions can be found here: https://wiki.eclipse.org/Eclipse_Project_Update_Sites
ivy {
url "http://download.eclipse.org/eclipse/updates/4.5/R-4.5.2-201602121500/"
layout "pattern", {
artifact "plugins/[artifact]_[revision].[ext]"
}
}
// SNAPSHOT versions are free to rely on other SNAPSHOT libraries
if (project.version.endsWith('-SNAPSHOT')) {
maven {
url 'https://oss.sonatype.org/content/repositories/snapshots/'
}
configurations.all {
resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
}
}
}
apply plugin: 'java-gradle-plugin'
sourceCompatibility = VER_JAVA
targetCompatibility = VER_JAVA
dependencies {
// Compile misc
compile "com.diffplug.durian:durian-core:${VER_DURIAN}"
compile "com.diffplug.durian:durian-collect:${VER_DURIAN}"
compile "com.diffplug.durian:durian-io:${VER_DURIAN}"
compile "com.diffplug.durian:durian-swt:${VER_DURIAN_SWT}"
compile "commons-io:commons-io:${VER_COMMONS_IO}"
compile "com.diffplug.spotless:spotless-lib:${VER_SPOTLESS_LIB}"
// OSGi
compile "biz.aQute.bnd:biz.aQute.bndlib:${VER_BNDLIB}"
// p2
compile "org.eclipse.tycho:org.eclipse.osgi:${VER_ECLIPSE_OSGI}"
// goomph, compileOnly for project setup (need to figure out how to bootstrap goomph)
compileOnly 'p2:org.eclipse.core.jobs:3.7.0.v20150330-2103'
compileOnly 'p2:org.eclipse.core.runtime:3.11.1.v20150903-1804'
compileOnly 'p2:org.eclipse.core.resources:3.10.1.v20150725-1910'
compileOnly 'p2:org.eclipse.equinox.common:3.7.0.v20150402-1709'
compileOnly 'p2:org.eclipse.ui.workbench:3.107.1.v20160120-2131'
compileOnly 'p2:org.eclipse.pde.core:3.10.102.v20160128-0556'
compileOnly 'p2:org.eclipse.jdt.launching:3.8.0.v20150527-0946'
compileOnly 'p2:org.eclipse.emf.ecore:2.11.2.v20160208-0816'
// testing
testCompile "junit:junit:${VER_JUNIT}"
}
test {
testLogging {
exceptionFormat = 'full'
}
}
apply plugin: 'eclipse'
eclipse {
classpath {
downloadSources true
downloadJavadoc true
}
project.file.withXml { provider ->
Node filteredResources = provider.asNode().appendNode('filteredResources')
Node filter = filteredResources.appendNode('filter')
filter.appendNode('id', '1093830624')
filter.appendNode('name', '')
filter.appendNode('type', '10')
Node matcher = filter.appendNode('matcher')
matcher.appendNode('id', 'org.eclipse.ui.ide.multiFilter')
matcher.appendNode('arguments', '1.0-name-matches-false-false-build')
}
}
// always create fresh projects
tasks.eclipse.dependsOn(cleanEclipse)
// with up-to-date test deps
tasks.eclipse.dependsOn(pluginUnderTestMetadata)
///////////////////
// OSGi metadata //
///////////////////
jar.manifest.attributes(
'Manifest-Version': '1.0',
'Bundle-SymbolicName': 'com.diffplug.gradle.goomph',
'Bundle-Name': 'com.diffplug.gradle.goomph',
'Bundle-Version': '0.0.0.SNAPSHOT',
'Export-Package': 'com.diffplug.gradle.osgi',
'Bundle-ClassPath': '.',
'Bundle-ManifestVersion': '2',
'DynamicImport-Package': '*'
)
////////////
// FORMAT //
////////////
apply plugin: 'com.diffplug.gradle.spotless'
spotless {
java {
licenseHeaderFile 'gradle/spotless.license.java' // License header file
importOrderFile 'gradle/spotless.importorder' // An import ordering file, exported from Eclipse
eclipseFormatFile 'gradle/spotless.eclipseformat.xml' // XML file dumped out by the Eclipse formatter
}
format 'misc', {
target '.gitignore', '*.gradle', '*.md', '.ci/*.sh'
indentWithTabs()
trimTrailingWhitespace()
endWithNewline()
}
freshmark {
target '*.md'
propertiesFile('gradle.properties')
}
}
//////////////
// 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 = 'medium' // 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
}
// use markdown in javadoc
def makeLink = { url, text -> "<a href=\"${url}\" style=\"text-transform: none;\">${text}</a>" }
def javadocInfo = '<h2>' + makeLink("https://github.com/${org}/${name}", "${group}:${name}:${version}") +
' by ' + makeLink('http://www.diffplug.com', 'DiffPlug') + '</h2>'
def verSnapshot = { it.endsWith('-SNAPSHOT') ? 'snapshot' : it }
apply plugin: 'ch.raffael.pegdown-doclet'
javadoc {
// 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.
options.addStringOption('Xdoclint:none')
// setup the header
options.header javadocInfo
options.footer javadocInfo
// setup links
options.linksOffline('https://docs.oracle.com/javase/8/docs/api/', 'gradle/javadoc/java8')
options.linksOffline("https://docs.gradle.org/${VER_GRADLE}/javadoc/", 'gradle/javadoc/gradle')
options.linksOffline("https://diffplug.github.io/durian/javadoc/${verSnapshot(VER_DURIAN)}/", 'gradle/javadoc/durian')
options.linksOffline("https://diffplug.github.io/durian-swt/javadoc/${verSnapshot(VER_DURIAN_SWT)}/", 'gradle/javadoc/durian-swt')
options.linksOffline("http://www.javadoc.io/doc/biz.aQute.bnd/biz.aQute.bndlib/${VER_BNDLIB}/", 'gradle/javadoc/bndlib')
}
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
}
////////////////
// PUBLISHING //
////////////////
def isSnapshot = project.version.endsWith('-SNAPSHOT')
// pulls the credentials from either the environment variable or gradle.properties
def cred = {
if (System.env[it] != null) {
return System.env[it]
} else if (project.hasProperty(it)) {
return project[it]
} else {
return 'unknown_' + it
}
}
model { publishing {
publications {
pluginMaven {
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/${project.org}/${project.name}"
scm {
url "https://github.com/${project.org}/${project.name}"
connection "scm:git:git://github.com/${project.org}/${project.name}"
developerConnection "scm:git:ssh:git@github.com/${project.org}/${project.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 (isSnapshot) {
// upload snapshots to oss.sonatype.org
repositories { maven {
url = 'https://oss.sonatype.org/content/repositories/snapshots'
credentials {
username = cred('nexus_user')
password = cred('nexus_pass')
}
} }
}
} }
if (!isSnapshot) {
////////////////////
// BINTRAY UPLOAD //
////////////////////
apply plugin: 'com.jfrog.bintray'
bintray {
user = cred('bintray_user')
key = cred('bintray_pass')
publications = ['pluginMaven']
publish = true
pkg {
repo = 'opensource'
name = project.name
userOrg = project.org
version {
name = project.version
mavenCentralSync {
user = cred('nexus_user')
password = cred('nexus_pass')
}
}
}
}
publish.dependsOn(bintrayUpload)
bintrayUpload.dependsOn(['generatePomFileForPluginMavenPublication', jar, sourcesJar, javadocJar])
}
//////////////////////////
// GRADLE PLUGIN PORTAL //
//////////////////////////
apply plugin: "com.gradle.plugin-publish"
pluginBundle {
// These settings are set for the whole plugin bundle
website = "https://github.com/${project.org}/${project.name}"
vcsUrl = "https://github.com/${project.org}/${project.name}"
plugins {
eclipseBuildPropertiesPlugin {
id = 'com.diffplug.gradle.eclipse.buildproperties'
displayName = 'Goomph eclipse.buildproperties'
description = "Uses Eclipse's build.properties to control a gradle build, and fixes the eclipse project classpath to include binary assets specified in build.properties."
tags = ['eclipse']
}
eclipseExcludeBuildFolderPlugin {
id = 'com.diffplug.gradle.eclipse.excludebuildfolder'
displayName = 'Goomph eclipse.excludebuildfolder'
description = "Excludes the gradle build folder from Eclipse's resource indexing."
tags = ['eclipse']
}
eclipseProjectDepsPlugin {
id = 'com.diffplug.gradle.eclipse.projectdeps'
displayName = 'Goomph eclipse.projectdeps'
description = "Fixes an intermittent problem where dependencies on other projects within the workspace aren't always resolved correctly within Eclipse."
tags = ['eclipse']
}
eclipseResourceFiltersPlugin {
id = 'com.diffplug.gradle.eclipse.resourcefilters'
displayName = 'Goomph eclipse.resourcefilters'
description = "Adds filters to an eclipse project which exclude or include specific resources."
tags = ['eclipse']
}
equinoxLaunch {
id = 'com.diffplug.gradle.equinoxlaunch'
displayName = 'Goomph launch an equinox application'
description = "Launches an equinox application with whatever set of plugins the user specifies"
tags = ['eclipse', 'osgi']
}
oomphIdePlugin {
id = 'com.diffplug.gradle.oomph.ide'
displayName = 'Goomph ooomph.ide'
description = "Downloads and sets up any Eclipse-based IDE."
tags = ['eclipse', 'ide', 'p2']
}
p2AsMavenPlugin {
id = 'com.diffplug.gradle.p2.asmaven'
displayName = 'Goomph p2.asmaven'
description = "Downloads a set of artifacts from a p2 repository and stuffs them into a local maven repository."
tags = ['p2', 'eclipse', 'osgi']
}
osgiBndManifestPlugin {
id = 'com.diffplug.gradle.osgi.bndmanifest'
displayName = 'Goomph osgi.bndmanifest'
description = "Generates a manifest using purely bnd, and outputs it for IDE consumption."
tags = ['osgi', 'bnd', 'eclipse']
}
swtNativeDepsPlugin {
id = 'com.diffplug.gradle.swt.nativedeps'
displayName = 'Goomph swt.nativedeps'
description = "Adds the platform-specific SWT jars to the runtime classpath so that SWT code can run."
tags = ['eclipse', 'swt']
}
}
mavenCoordinates {
groupId = project.group
artifactId = project.name
version = project.version
}
}
// the gradle plugin portal isn't really compatible with SNAPSHOT versions
// https://discuss.gradle.org/t/uploading-snapshot-versions-to-the-plugin-portal/11347
if (isSnapshot) {
publishPlugins.enabled = false
}
//////////////////
// GITHUB PAGES //
//////////////////
githubPages {
repoUri = "https://github.com/${project.org}/${project.name}"
deleteExistingFiles = false
pages {
from javadoc.destinationDir
into "javadoc/${verSnapshot(version)}"
}
credentials {
username = cred('gh_token')
password = ''
}
}
tasks.prepareGhPages.dependsOn(":javadoc")
// helps external scripts detect version
task printVersion
printVersion.doLast {
println version
}