forked from pgentile/zucchini-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
executable file
·346 lines (230 loc) · 8.46 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
import io.zucchini.build.docker.DockerPlugin
import io.zucchini.build.node.NodePlugin
import io.zucchini.build.node.NPMTask
buildscript {
repositories {
maven {
url "https://plugins.gradle.org/m2/"
}
jcenter()
}
}
plugins {
id 'com.github.ben-manes.versions' version '0.11.3' apply false
id 'us.kirchmeier.capsule' version '1.0.2' apply false
id 'com.google.osdetector' version '1.4.0' apply false
id 'org.ajoberstar.grgit' version '1.5.1' apply false
}
/**
* Replace version used by a group of dependencies.
*
* @param details Dependency details
* @param group Group of the dependency
* @param version Version to set
*/
void replaceDependencyGroupVersion(DependencyResolveDetails details, String group, String version) {
if (details.requested.group == group || details.requested.group.startsWith(group + ".")) {
details.useVersion version
}
}
allprojects {
group = 'io.zucchini-ui'
apply plugin: 'idea'
apply plugin: 'org.ajoberstar.grgit'
apply plugin: DockerPlugin
apply plugin: NodePlugin
repositories {
mavenLocal()
mavenCentral()
}
ext.versions = [
dropwizard : '1.0.2',
orika : '1.4.6',
morphia : '1.2.1',
slf4j : '1.7.21',
spring : '4.3.3.RELEASE',
junit : '4.12',
assertj : '3.5.2',
mockito : '2.2.0',
junitQuickcheck: '0.6.1',
capsule : '1.0.3',
groovy : '2.4.7',
cucumberGroovy : '1.2.5',
jetty : '9.3.9.v20160517',
]
ext.getDockerTag = {
String branchName = project.grgit.branch.current.name
if (branchName == 'master') {
return 'latest'
}
return "branch-${branchName}"
}
// Plugins to use with the java plugin
project.afterEvaluate {
if (project.pluginManager.hasPlugin("java")) {
// Add common dependencies
project.dependencies {
testCompile "junit:junit:${project.versions.junit}"
testCompile "org.assertj:assertj-core:${project.versions.assertj}"
testCompile "org.mockito:mockito-core:${project.versions.mockito}"
}
// Maven plugin
project.apply plugin: 'maven'
// Versions plugin
project.apply plugin: 'com.github.ben-manes.versions'
// PMD plugin
project.apply plugin: 'pmd'
project.pmd {
ignoreFailures = true
}
tasks.withType(Pmd) {
reports {
xml.enabled = false
html.enabled = true
}
}
// Findbugs plugin
project.apply plugin: 'findbugs'
project.findbugs {
effort = "max"
ignoreFailures = true
}
tasks.withType(FindBugs) {
reports {
xml.enabled = false
html.enabled = true
}
}
}
project.configurations.all {
resolutionStrategy {
// Replace commons logging by slf4j, if present
dependencySubstitution {
substitute module('commons-logging:commons-logging') with module("org.slf4j:jcl-over-slf4j:${project.versions.slf4j}")
}
// Override some dependency versions
eachDependency { DependencyResolveDetails details ->
replaceDependencyGroupVersion(details, 'org.slf4j', project.versions.slf4j)
}
}
}
// Shared Java compiler config
project.tasks.withType(JavaCompile) {
project.sourceCompatibility = '1.8'
options.encoding = 'UTF-8'
options.deprecation = true
options.compilerArgs << '-parameters'
options.compilerArgs << '-Werror'
}
}
}
project("${rootProject.name}-backend") {
apply plugin: 'java'
dependencies {
compile "io.dropwizard:dropwizard-core:${versions.dropwizard}"
compile "ma.glasnost.orika:orika-core:${versions.orika}"
compile "org.mongodb.morphia:morphia:${versions.morphia}"
compile "org.mongodb.morphia:morphia-logging-slf4j:${versions.morphia}"
compile "org.slf4j:slf4j-api:${versions.slf4j}"
compile "org.springframework:spring-context:${versions.spring}"
compile "org.eclipse.jetty.websocket:javax-websocket-server-impl:${versions.jetty}"
testCompile "org.assertj:assertj-core:${versions.assertj}"
testCompile "com.pholser:junit-quickcheck-core:${versions.junitQuickcheck}"
testCompile "com.pholser:junit-quickcheck-generators:${versions.junitQuickcheck}"
}
task runBackend(type: JavaExec, description: 'Run backend server') {
classpath = sourceSets.main.runtimeClasspath
main = 'io.zucchiniui.backend.BackendApplication'
args += ['serve', "${rootDir}/server-config.yml"]
}
task runJsonImporter(type: JavaExec, description: 'Execute JsonImportTest') {
classpath = sourceSets.main.runtimeClasspath
main = 'io.zucchiniui.backend.JsonImportTest'
if (project.hasProperty('jsonFilePath')) {
args = [jsonFilePath]
}
}
}
project("${rootProject.name}-frontend") {
apply plugin: 'java'
project.sourceSets.main.resources.srcDir('build/dist')
task webpack(type: NPMTask, description: 'Run Webpack') {
command = 'run'
args = ['build']
inputs.dir('app')
inputs.file('package.json')
inputs.file('webpack.config.js')
outputs.dir('build/dist')
}
tasks.processResources.dependsOn webpack
task jsTest(type: NPMTask, description: 'Test JavaScript') {
command = 'test'
}
tasks.check.dependsOn jsTest
}
project("${rootProject.name}-capsule") {
apply plugin: 'us.kirchmeier.capsule'
dependencies {
compile project(":${rootProject.name}-backend")
compile project(":${rootProject.name}-frontend")
compile "io.dropwizard:dropwizard-assets:${versions.dropwizard}"
}
capsule.version = versions.capsule
task fatCapsule(type: FatCapsule, description: 'Build Capsule') {
applicationClass 'io.zucchiniui.capsule.ZucchiniUIApplication'
capsuleManifest {
minJavaVersion = '1.8.0'
}
}
task runCapsule(type: Exec, description: 'Run Capsule', dependsOn: fatCapsule) {
commandLine 'java', '-jar', fatCapsule.archivePath, 'server', "${rootDir}/server-config.yml"
}
tasks.assemble.dependsOn fatCapsule
docker {
name = rootProject.name
// Project version is required as a build arg
buildArg 'VERSION', project.version
// Add tag based on current Git branch
tag project.getDockerTag()
}
}
project("${rootProject.name}-example-features") {
apply plugin: 'groovy'
dependencies {
compile "org.codehaus.groovy:groovy-all:${versions.groovy}"
compile "info.cukes:cucumber-groovy:${versions.cucumberGroovy}"
compile "org.slf4j:slf4j-api:${versions.slf4j}"
compile "org.assertj:assertj-core:${versions.assertj}"
}
task runCucumber(type: JavaExec, description: 'Run Cucumber features') {
classpath = sourceSets.main.runtimeClasspath
main = 'cucumber.api.cli.Main'
args += [
'--glue', 'classpath:io.zucchiniui.examples',
'--plugin', 'pretty',
'--plugin', "html:${project.buildDir}/cucumber/html",
'--plugin', "json:${project.buildDir}/cucumber/report.json",
'--tags', '~@ignored',
'src/features',
]
ignoreExitValue true
}
task dryRunCucumber(type: JavaExec, description: 'Dry run Cucumber features') {
classpath = sourceSets.main.runtimeClasspath
main = 'cucumber.api.cli.Main'
args += [
'--glue', 'classpath:io.zucchiniui.examples',
'--plugin', 'pretty',
'--plugin', "html:${project.buildDir}/cucumber-dry/html",
'--plugin', "json:${project.buildDir}/cucumber-dry/report.json",
'--dry-run',
'src/features',
]
ignoreExitValue true
}
}
project("${rootProject.name}-mongo") {
docker {
tag project.getDockerTag()
}
}