forked from quince-science/QuinCe
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
283 lines (244 loc) · 8.29 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
/*
* This build file was generated by the Gradle 'init' task.
*
* This generated file contains a sample Java Library project to get you started.
* For more details take a look at the Java Libraries chapter in the Gradle
* user guide available at https://docs.gradle.org/4.4.1/userguide/java_library_plugin.html
*/
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'org.gretty:gretty:3.0.3'
// Flyway migration needs the mysql connector
classpath 'mysql:mysql-connector-java:8.0.29'
// Gson
classpath 'com.google.code.gson:gson:2.10.1'
}
}
// Flyway database migration plugin:
plugins {
id "org.flywaydb.flyway" version "7.15.0"
id "com.diffplug.gradle.spotless" version "4.5.1"
}
apply plugin: 'java'
apply plugin: 'war'
apply plugin: 'org.gretty'
apply plugin: 'eclipse-wtp'
apply plugin: 'jacoco'
war {
webAppDirName = 'WebApp/WebContent'
}
gretty {
servletContainer = 'tomcat9'
enableNaming = true
}
repositories {
mavenCentral()
}
dependencies {
implementation "org.primefaces:primefaces:13.0.0"
implementation 'javax.el:javax.el-api:3.0.0'
implementation 'mysql:mysql-connector-java:8.0.29'
implementation 'commons-validator:commons-validator:1.4.1'
implementation 'org.apache.commons:commons-email:1.4'
implementation 'org.apache.commons:commons-lang3:3.11'
implementation 'org.apache.commons:commons-math3:3.6'
implementation 'org.apache.commons:commons-csv:1.7'
implementation 'org.apache.commons:commons-text:1.9'
//
implementation 'commons-codec:commons-codec:1.3'
implementation 'commons-beanutils:commons-beanutils:1.8.3'
implementation 'commons-collections:commons-collections:3.2'
implementation 'commons-digester:commons-digester:1.8'
implementation 'commons-logging:commons-logging:1.1.1'
//
implementation 'commons-fileupload:commons-fileupload:1.3.1'
implementation 'org.apache.myfaces.core:myfaces-api:2.2.8'
implementation 'org.apache.myfaces.core:myfaces-impl:2.2.8'
implementation 'org.apache.myfaces.core:myfaces-bundle:2.2.8'
// Flyway library for Java-based migrations
implementation 'org.flywaydb:flyway-core:7.15.0'
// Google GSON library
implementation 'com.google.code.gson:gson:2.10.1'
// JAX-B dependencies for JDK 9+
implementation 'javax.xml.bind:jaxb-api:2.3.1'
implementation 'javax.xml.ws:jaxws-api:2.3.1'
implementation 'javax.ws.rs:javax.ws.rs-api:2.1.1'
implementation 'org.glassfish.jaxb:jaxb-runtime:3.0.0-M4'
// Jersey RESTful API
implementation 'org.glassfish.jersey.containers:jersey-container-servlet:2.34'
implementation 'org.glassfish.jersey.inject:jersey-hk2:2.34'
implementation 'org.glassfish.jersey.media:jersey-media-moxy:2.34'
implementation 'org.glassfish.jersey.media:jersey-media-multipart:2.34'
// Simple lat/long calculations
implementation 'com.javadocmd:simplelatlng:1.4.0'
// gretty plugin handling the tomcat server
gretty 'org.apache.tomcat:tomcat-dbcp:8.0.1'
gretty 'org.apache.tomcat:tomcat:8.0.1'
// Use JUnit test framework
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.7.0'
testImplementation 'org.junit.jupiter:junit-jupiter-params:5.7.0'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.7.0'
testImplementation 'com.h2database:h2:1.4.197'
testImplementation 'org.flywaydb.flyway-test-extensions:flyway-spring-test:7.0.0'
testImplementation 'org.mockito:mockito-core:5.8.0'
// Flyway library for Java-based migrations
testImplementation 'org.flywaydb:flyway-core:7.15.0'
// JUnit resources
testImplementation files('WebApp/junit')
// Fix for Eclipse 2023-09
// Use JUnit Jupiter for testing.
testImplementation 'org.junit.jupiter:junit-jupiter:5.9.3'
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
// JavaMelody monitoring
// Can't use v2 until we use Tomcat 10
implementation 'net.bull.javamelody:javamelody-core:1.95.0'
}
sourceSets {
main {
java {
srcDirs = ['WebApp/src', 'src/QC_Routines/src', 'src/migrations']
}
resources {
srcDirs = ['WebApp/WebContent/resources', 'src/migrations']
}
}
test {
java {
srcDirs = ['WebApp/junit']
}
}
}
compileJava {
options.encoding = "UTF-8"
}
tasks.withType(JavaCompile) {
options.encoding = "UTF-8"
}
test {
useJUnitPlatform()
}
eclipse {
wtp {
facet {
facet name: "jst.web", version: "2.5" // Dynamic Web Application
facet name: "java", version: "17" // Java version
facet name: "wst.jsdt.web", version: "1.0" // JavaScript
facet name: "jst.jsf", version: "2.2" // Java Server Faces
}
}
}
def rootPath = file('.').absolutePath
def webContext=new XmlSlurper().parse(rootPath + '/WebApp/WebContent/META-INF/context.xml')
// Load db setup
// Database migration scripts are added to the folder
// src/migrations/flywayMigrations/dbmigrations
// sql migration files are named with:
// V[number]__[any_name].sql, eg V2__new_table_record.sql
flyway {
url = webContext.Resource.@url
user = webContext.Resource.@username
password = webContext.Resource.@password
locations = ["classpath:db_migrations"]
baselineOnMigrate = false
}
// Make sure project is cleaned and build before running flywayMigrate task
flywayMigrate {
dependsOn 'clean'
dependsOn 'war'
tasks.findByName('war').mustRunAfter 'clean'
}
spotless {
// Blocks defining how to format different code types
format 'java', {
// Formatting options for java files
target 'WebApp/**/*.java'
trimTrailingWhitespace()
indentWithSpaces(2)
endWithNewline()
}
format 'misc', {
// Formatting options for misc files
target 'WebApp/**/*.xhtml', 'WebApp/**/*.xml',
'WebApp/WebContent/resources/style/dataFiles.css',
'WebApp/WebContent/resources/style/main.css',
'WebApp/WebContent/resources/style/manualQc.css',
'WebApp/WebContent/resources/style/newInstrument.css',
'WebApp/WebContent/resources/style/plotPage.css',
'WebApp/WebContent/resources/style/reviewCalibrationData.css',
'scripts/*.sh', 'scripts/**/*.sh'
trimTrailingWhitespace()
indentWithSpaces(2)
endWithNewline()
}
format 'js', {
// Formatting options for javascript files
target 'WebApp/WebContent/resources/script/dataFiles.js',
'WebApp/WebContent/resources/script/dataSets.js',
'WebApp/WebContent/resources/script/jsColorScale.js',
'WebApp/WebContent/resources/script/manualQc.js',
'WebApp/WebContent/resources/script/newInstrument.js',
'WebApp/WebContent/resources/script/plotPage.js',
'WebApp/WebContent/resources/script/reviewCalibrationData.js'
trimTrailingWhitespace()
indentWithSpaces(2)
endWithNewline()
}
format 'python', {
// Formatting options for python files
target 'NRT/*.py'
trimTrailingWhitespace()
indentWithSpaces(2)
endWithNewline()
}
}
tasks.withType(Test).configureEach {
maxParallelForks = Runtime.runtime.availableProcessors().intdiv(2) ?: 1
}
tasks.register("migrationCheck") {
description = 'Check that database migrations for the app also exist in the junit test config'
doLast {
def appMigrationFiles = []
File appMigrationsDir = new File('./src/migrations/db_migrations')
appMigrationsDir.eachFileRecurse { file ->
if (file.name.endsWith("sql")) {
appMigrationFiles << file.getName()
}
}
def testMigrationFiles = []
File testMigrationsDir = new File('./WebApp/junit/resources/db_migrations')
testMigrationsDir.eachFileRecurse { file ->
if (file.name.endsWith("sql")) {
testMigrationFiles << file.getName()
}
}
Arrays.sort(appMigrationFiles)
Arrays.sort(testMigrationFiles)
def listsMatch = true
for (appFile in appMigrationFiles) {
if (!testMigrationFiles.contains(appFile)) {
listsMatch = false
println("Missing test migration for " + appFile)
}
}
for (testFile in testMigrationFiles) {
if (!appMigrationFiles.contains(testFile)) {
listsMatch = false
println("Extra test migration file " + testFile + " should not exist")
}
}
if (!listsMatch) {
throw new GradleException("Database migrations mismatch")
}
}
}
jacocoTestReport {
reports {
xml.required = true
xml.destination = file("${buildDir}/reports/jacoco/report.xml")
csv.required = false
html.required = false
}
}