-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbuild.gradle
467 lines (376 loc) · 14.6 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
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
/*
* gradle build script for totask2 project.
*
* uses gradle 2.6 for compile (or provided gradlew script).
*
* @see http://man-at-home.github.io/totask2/
* @author man-at-home
* @since 2014
* @version 2015
*/
// development
apply plugin: "java"
apply plugin: "js"
apply plugin: "war"
apply plugin: "eclipse"
apply plugin: "maven"
apply plugin: "docker"
apply plugin: "spring-boot"
// qa
apply plugin: "checkstyle"
apply plugin: "findbugs"
apply plugin: "jacoco"
// apply plugin: "cobertura" // not yet there with java8 it seems, jacoco works though
apply plugin: "jdepend"
apply plugin: "pmd"
apply plugin: "sonar-runner"
apply plugin: "groovy"
apply plugin: "com.github.kt3k.coveralls"
// documentation
apply plugin: 'project-report'
apply plugin: "build-dashboard"
apply plugin: "plantuml"
apply plugin: "announce"
apply plugin: "org.asciidoctor.gradle.asciidoctor"
apply plugin: "org.standardout.versioneye"
// db
apply plugin: "org.flywaydb.flyway"
repositories {
mavenLocal()
mavenCentral()
maven{url "http://repo.spring.io/libs-release" }
maven{url "http://jasperreports.sourceforge.net/maven2/"}
maven{url "http://jaspersoft.artifactoryonline.com/jaspersoft/third-party-ce-artifacts/"}
maven{url "http://gradle.artifactoryonline.com/gradle/libs/"}
jcenter()
}
buildscript {
repositories {
mavenLocal()
mavenCentral()
maven { url "http://repo.spring.io/libs-release" }
jcenter()
}
dependencies {
classpath "org.springframework.boot:spring-boot-gradle-plugin:1.2.3.RELEASE" // spring boot with gradle
classpath "org.flywaydb:flyway-gradle-plugin:3.2.1" // db migration
classpath "org.asciidoctor:asciidoctor-gradle-plugin:1.5.2" // documentation engine
classpath "be.jlr-home.gradle:plantumlPlugin:0.1.1" // documentation graphing
classpath "com.eriwen:gradle-js-plugin:1.12.0" // javascript build utilities
classpath "com.wordnik:swagger-codegen:2.1.2-M1" // optional swagger doc generation
// classpath "net.saliman:gradle-cobertura-plugin:2.2.7" // coverage for shippable.com build
classpath "org.kt3k.gradle.plugin:coveralls-gradle-plugin:2.3.1"
classpath "org.standardout:gradle-versioneye-plugin:1.0.1" // versioneye gradle analysis
classpath "se.transmode.gradle:gradle-docker:1.2" // docker container creation
classpath "com.h2database:h2:1.4.187" // dev database (usable in memory)
}
}
sourceCompatibility = "1.8"
compileJava {
targetCompatibility = 1.8
}
war {
archiveName = 'totask2.war'
}
configurations {
compile.exclude group: "org.springframework.boot", module: "spring-boot-starter-tomcat" // wildfly, undertow, otherwise remove hier and below
}
dependencies {
compile "org.apache.poi:poi:3.12"
compile "org.slf4j:slf4j-api:1.7.12" // logging api
compile "ch.qos.logback:logback-classic:1.1.3" // logging library
// compile "org.logback-extensions:logback-ext-loggly:0.1.2" // log into the cloud, loggly.com
// compile "com.papertrailapp:logback-syslog4j:1.0.0" // log into the cloud, papertrail.com
compile "net.sf.jasperreports:jasperreports:6.1.0" // reporting engine (excel, pdf generation)
compile "com.h2database:h2:1.4.187" // dev database (usable in memory)
compile "org.ajar:swagger-spring-mvc-ui:0.4" // rest tester ui integrated in web app
compile "com.mangofactory:swagger-springmvc:1.0.2" // newer version on hold cause of scala upgrade dependencies..
compile "io.dropwizard.metrics:metrics-core:3.1.2" // more metric types than spring boot alone
compile "org.coursera:metrics-datadog:1.1.1" // report metrics to datadoghq.com
compile "io.keen:keen-client-api-java:2.1.1" // analytic data for keen.io
compile "org.springframework:spring-context:4.1.6.RELEASE" // spring
compile "org.springframework:spring-context-support:4.1.6.RELEASE"
compile( "org.springframework.boot:spring-boot-starter-web:1.2.4.RELEASE" ) { // spring boot
exclude group: "org.springframework.boot", module: "spring-boot-starter-tomcat:1.2.4.RELEASE"
}
compile "org.springframework.boot:spring-boot-starter-thymeleaf:1.2.4.RELEASE" // templating engine
compile "org.springframework.boot:spring-boot-starter-undertow:1.2.4.RELEASE" // wildfly/undertow, if not remove here and above
compile "org.springframework.boot:spring-boot-starter-data-jpa:1.2.4.RELEASE"
compile "org.springframework.boot:spring-boot-starter-security:1.2.4.RELEASE"
compile "org.springframework.boot:spring-boot-starter-actuator:1.2.4.RELEASE"
compile "org.hibernate:hibernate-envers:4.3.8.Final" // orm mapper history building
// compile "javax.interceptor:javax.interceptor-api:3.+" // workaround javadoc exception InterceptorBinding
compile "org.flywaydb:flyway-core:3.2.1" // database migration utility
testCompile "org.seleniumhq.selenium:selenium-firefox-driver:2.45.0" // ui tester
testCompile "org.springframework.boot:spring-boot-starter-test:1.2.3.RELEASE" // helper for unit testing spring boot
// testCompile "org.springframework.security:spring-security-test:4.0.0.M1"
testCompile "org.spockframework:spock-spring:1.0-groovy-2.4" // groovy unit test addone
}
jdepend {
toolVersion = "2.9.1"
}
jdependMain {
reports {
xml.enabled = false
text.enabled = true
}
}
jdependTest {
reports {
xml.enabled = false
text.enabled = true
}
}
findbugs {
toolVersion = "3.0.1"
ignoreFailures = true
effort = "max"
reportLevel = "high"
}
checkstyle {
ignoreFailures = true
toolVersion = "6.7" // with java8 support
}
pmd {
ignoreFailures = true
// toolVersion = "5.2.3"
}
tasks.withType(FindBugs) {
reports {
xml.enabled = false
html.enabled = true
}
}
jacocoTestReport {
reports {
xml.enabled = true // required for sonar&coveralls
html.enabled = true
csv.enabled = false
// html.destination = "${buildDir}/reports/jacoco"
}
}
// cobertura {
// coverageReportDir = file("${buildDir}/reports/cobertura")
// coverageFormats = ["xml"]
// }
// configured for local sonarQube 4.5 installation (defaults)
sonarRunner {
toolVersion = '2.4'
sonarProperties {
property "sonar.projectName", "totask2 project time logging"
property "sonar.projectKey", "totask2"
property "sonar.jacoco.reportPath", "${buildDir}/jacoco/test.exec"
property "sonar.junit.reportsPath", "${buildDir}/test-results/"
property "sonar.surefire.reportsPath", "${buildDir}/test-results/"
}
}
asciidoctor {
sourceDir = new File("${projectDir}/src/docs")
outputDir = new File("${buildDir}/docs/asciidoc")
logDocuments = true
}
flyway {
url = "jdbc:h2:totask2.qa.db" // makes no sense with the dev in memory db.
user = 'sa'
}
javadoc {
failOnError = false
// options.overview = "${projectDir}/src/main/java/overview.html" // relative to source root
options.windowTitle = "totask2 api documentation ${version}"
options.links( "http://download.oracle.com/javase/8/docs/api/" )
options.addBooleanOption("Xdoclint:none").setValue(true)
}
// enable spring-boot profiles (dev and qa) in gradle tasks
project.gradle.projectsEvaluated {
applicationDefaultJvmArgs = ["-Dspring.profiles.active=${project.gradle.startParameter.systemPropertiesArgs['spring.profiles.active']}"]
}
javascript.source {
dev {
js {
srcDir "${projectDir}/src/main/webapp/js/totask2"
include "*.js"
}
}
}
// lint javascript files
jshint {
tasks.jshint.source = javascript.source.dev.js.files
tasks.jshint.dest = file("${buildDir}/jshint.out")
tasks.jshint.reporter = 'checkstyle'
tasks.jshint.ignoreExitCode=true
jshint.options = [bitwise:true]
jshint.predef=[
"Ext" :true,
'$' :true // jquery
]
}
// generate javascript docs
jsdoc {
tasks.jsdoc.source = javascript.source.dev.js.files
tasks.jsdoc.destinationDir = file("${buildDir}/jsdoc")
}
announce {
// twitter
username = "totask2tweeter" // currently not active..
}
versioneye {
exclude "testCompile", "testRuntime" , "buildscript", "rhino", "jdepend", "jacocoAnt", "jacocoAgent", "pmd"
}
group = "manathome" // group for docker image!
// CUSTOM TASKS
// ============
task printEnv {
// println "coveralls.."
// println "Dies ist das coveralls repo: $System.env.COVERALLS_REPO_TOKEN"
println "Dies ist temp: $System.env.TEMP"
}
tasks.coveralls {
description "calculate code coverage on coveralls.io"
dependsOn printEnv, check, jacocoTestReport
// onlyIf { isCI }
}
task copyPlantUMLImages(type: Copy) {
description "use diagrams from javadoc in asciidoc articles too"
dependsOn javadoc
from fileTree(dir: "${buildDir}/docs/javadoc", include: "**/doc-files/*.png").files
into "${buildDir}/docs/asciidoc/images/uml"
}
asciidoctor.shouldRunAfter schemadoc
// generate all documentation
task allDocs {
description "generation of full documenation for totask2 (asciidoc and javadoc)"
dependsOn javadoc, schemadoc, asciidoctor, copyPlantUMLImages, projectReport
}
task wrapper(type: Wrapper) {
description "gradle wrapper generation (call if gradle version changes)"
gradleVersion = '2.6'
}
task buildDocker(type: Docker) {
description "build docker container for totask2"
dependsOn build
push false
applicationName="totask2"
tagVersion="1"
dockerfile = file("src/main/docker/Dockerfile")
doFirst {
copy {
from jar
into stageDir
}
}
}
task deployLocal(type: Copy) {
description "deploy into app server (wildlfy 8.1 currently). start with wildfly/bin/standalone.bat"
dependsOn assemble
from "${buildDir}/libs"
include '*.war'
into 'c:/dev/wildfly/standalone/deployments'
}
// deploy into cloud server (wildlfy cardridge currently)
task deployOpenShift(type: Copy) {
description "deploy into app server (wildlfy 8.1 - called from action_hook/deploy)"
dependsOn assemble
from "${buildDir}/libs"
include '*.war'
into 'deployments'
// rename { String fileName -> "ROOT.war" } // if you neet the application running as root url /
}
task writeOpenShiftPom << {
description "prepare pom for maven based build targeting openShift deployment"
pom {
project {
groupId "manathome"
description "totask2 openshift maven pom, generated by gradle"
url "http://man-at-home.github.io/totask2/"
packaging "war"
version "1.0.0_dev"
parent {
groupId "org.springframework.boot"
artifactId "spring-boot-starter-parent"
version "1.2.3.RELEASE"
}
repositories {
repository {
id "repo.spring.id"
name "repo.spring.io"
url "http://repo.spring.io/libs-release"
}
repository {
id "repo.jaspersoft.oem"
name "repo.jaspersoft.oem"
url "http://jaspersoft.artifactoryonline.com/jaspersoft/third-party-ce-artifacts/"
}
}
developers {
developer {
id "man-at-home"
name "man at home"
}
}
}
}
.withXml {
asNode()
.appendNode("build")
.appendNode("plugins").with {
appendNode("plugin").with {
appendNode("groupId", "org.apache.maven.plugins")
appendNode("artifactId", "maven-compiler-plugin")
appendNode("version", "3.3")
appendNode("configuration").with {
appendNode("source", "1.8")
appendNode("target", "1.8")
}
}
appendNode("plugin").with {
appendNode("groupId", "org.apache.maven.plugins")
appendNode("artifactId", "maven-war-plugin")
appendNode("version", "2.3")
appendNode("configuration").with {
appendNode("failOnMissingWebXml", "false")
appendNode("outputDirectory", "deployments")
appendNode("warName", "ROOT")
}
}
}
}
.writeTo("$projectDir/openshift.pom.xml")
}
// call on windows (to test openShift execution): mvn package -f openshift.pom.xml -DskipTests=true
task localMaven(type:Exec) {
description "execute maven locally on my development machine"
dependsOn writeOpenShiftPom
commandLine "cmd", "/c", "\\dev\\maven\\bin\\mvn", "-f", "$projectDir\\openshift.pom.xml", "package", "-DskipTests=true"
}
task deployLocalMaven(type: Copy) {
description "deploy into app server (wildlfy 8.1 currently). start with wildfly/bin/standalone.bat"
dependsOn localMaven
from "/target"
include 'toTask2*.war'
into 'c:/dev/wildfly/standalone/deployments'
}
task genSwagger(type: JavaExec) {
description "generate swagger doc or clients via codgen package and gradle"
// needing buildscript dependency classpath "com.wordnik:swagger-codegen:2.1.2-M1" (see http://swagger.io)
classpath = buildscript.configurations.classpath
args = ["-i", "http://localhost:8080/api-docs/totask2/workentry-rest-api", "-o", "${buildDir}/docs/rest-api", "-l", "android"]
main = "com.wordnik.swagger.codegen.Codegen"
}
task prepareHerokuSlug(type: Delete) {
description "free space before heroku deployment (space issues)"
delete "${buildDir}/classes", "${buildDir}/distributions", "${buildDir}/libs/toTask2.jar.original",
"${buildDir}/libs/toTask2.war.original", "${buildDir}/libs/totask2.war"
}
task stage {
description "heroku deployment (cloud)"
dependsOn assemble, prepareHerokuSlug
}
test.doLast {
// announce.announce "gradle $it.name done", "twitter"
announce.announce "gradle $it.name done", "local"
}
// reminder: start h2 console (start-menue) >h2w.bat, connect to jdbc:h2:c:/data/projects/totask2/totask2.qa.db
// reminder: run qa profile: >gradlew bootRun -Dspring.profiles.active=qa
// reminder: run sonar server: >\dev\sonarqube\bin\windows-x86-32\StartSonar
// reminder: run local wildFly >C:\dev\wildfly\bin\standalone.bat
// reminder: generate+wildfly maven for openshift: >gradlew deployLocalMaven