forked from alfio-event/alf.io
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
368 lines (320 loc) · 12.4 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
import org.apache.tools.ant.filters.ReplaceTokens
import java.nio.file.Files
import java.nio.file.Paths
import java.time.Year
import java.time.ZoneId
import java.time.ZonedDateTime
import java.time.format.DateTimeFormatter
import java.util.regex.Pattern
buildscript {
dependencies {
classpath 'ru.yandex.qatools.embed:postgresql-embedded:+'
}
repositories {
jcenter()
maven {
url "https://plugins.gradle.org/m2/"
}
}
}
plugins {
id 'io.franzbecker.gradle-lombok' version '1.14'
id 'java'
id 'idea'
id 'jacoco'
id 'com.github.kt3k.coveralls' version '2.8.2'
id 'com.github.ben-manes.versions' version '0.20.0'
id 'com.github.hierynomus.license' version '0.14.0'
id 'net.researchgate.release' version '2.7.0'
id 'org.springframework.boot' version '2.1.0.RELEASE'
}
apply plugin: 'java'
apply plugin: 'war'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
//as pointed out by @facundofarias, we should check minimum javac version in order to avoid problems with type inference mechanism during compilation
task validate {
//check JDK version
def javaVersion = JavaVersion.current();
if (!javaVersion.isJava8Compatible()) {
throw new GradleException("A Java JDK 8+ is required to build the project.")
}
//check build number, but only if current java version is 8
if (javaVersion == JavaVersion.VERSION_1_8) {
def currentVersion = System.getProperty("java.version")
def matcher = Pattern.compile("1(\\.\\d+){2}_(\\d+)").matcher(currentVersion)
if (!matcher.find()) {
throw new GradleException(currentVersion + " is not a recognized java version. Please report this issue.")
}
def buildNumber = Integer.parseInt(matcher.group(2))
if(buildNumber < 25) {
throw new GradleException(currentVersion + " is not a supported JDK version. Minimum version is 1.8.0b25. Please update your local JDK.")
}
}
}
idea {
project {
jdkName sourceCompatibility.toString()
languageLevel sourceCompatibility
}
}
def profile = project.hasProperty('profile') ? project.profile : 'dev'
ext {
// default settings
jettyPort = 8080
jettyHost = '0.0.0.0'
datasourceUrl = 'jdbc:postgresql://localhost:5432/alfio'
datasourceUsername = 'postgres'
datasourcePassword = 'password'
datasourceValidationQuery = 'SELECT 1'
//springProfilesActive = 'dev
//springProfilesActive = 'dev,demo'
springProfilesActive = 'dev'
port = "8080"
switch (profile) {
case 'docker-test':
datasourceUrl = 'jdbc:postgresql://0.0.0.0:5432/postgres'
datasourceUsername = 'postgres'
datasourcePassword = 'postgres'
datasourceValidationQuery = 'SELECT 1'
break
case 'travis':
project.springProfilesActive = 'travis'
break
}
}
configurations {
compileOnly
testCompileOnly
providedRuntime
providedCompile
}
repositories {
mavenCentral()
jcenter()
}
dependencies {
compile "org.springframework:spring-webmvc:$springVersion"
compile "org.springframework:spring-context-support:$springVersion"
compile "org.springframework:spring-jdbc:$springVersion"
compile "org.springframework:spring-aop:$springVersion"
compile "com.fasterxml.jackson.datatype:jackson-datatype-jsr310:$jacksonVersion"
compile "com.fasterxml.jackson.core:jackson-core:$jacksonVersion"
compile "com.fasterxml.jackson.core:jackson-databind:$jacksonVersion"
compile "org.springframework.boot:spring-boot-properties-migrator", {
exclude module : 'spring-boot-starter-logging'
}
compile "org.springframework.security:spring-security-web:$springSecurityConfigVersion"
compile "org.springframework.security:spring-security-config:$springSecurityConfigVersion"
compile 'org.springframework.session:spring-session:1.3.4.RELEASE'
compile "ch.digitalfondue.npjt-extra:npjt-extra:1.1.4"
compile "com.samskivert:jmustache:1.14"
compile "com.github.sps.mustache:mustache-spring-view:1.4"
compile "javax.mail:mail:1.5.0-b01"
compile 'com.moodysalem:LatLongToTimezoneMaven:1.2'
/**/
compile "com.openhtmltopdf:openhtmltopdf-core:0.0.1-RC17"
compile "com.openhtmltopdf:openhtmltopdf-pdfbox:0.0.1-RC17"
compile "com.openhtmltopdf:openhtmltopdf-jsoup-dom-converter:0.0.1-RC17"
/**/
compile "com.google.zxing:core:3.3.3"
compile "com.google.zxing:javase:3.3.3"
compile "org.flywaydb:flyway-core:5.1.3"
compile "org.postgresql:postgresql:42.2.5"
compile "com.zaxxer:HikariCP:2.7.7"
compile "org.apache.logging.log4j:log4j-api:$log4jVersion"
compile "com.stripe:stripe-java:5.42.0"
compile 'com.paypal.sdk:rest-api-sdk:1.14.0'
compile 'com.squareup.okhttp3:okhttp:3.11.0'
compile "org.apache.commons:commons-lang3:3.7"
compile "org.apache.commons:commons-text:1.2"
compile "com.opencsv:opencsv:4.2"
compile 'commons-codec:commons-codec:1.11'
compile 'net.sf.biweekly:biweekly:0.6.2'
compile 'com.atlassian.commonmark:commonmark:0.11.0'
compile 'com.ryantenney.passkit4j:passkit4j:2.0.1'
compile 'com.github.ben-manes.caffeine:caffeine:2.6.2'
compile 'de.danielbechler:java-object-diff:0.95'
compile 'com.github.scribejava:scribejava-core:5.0.0'
compile 'ch.digitalfondue.vatchecker:vatchecker:1.1'
compile 'ch.digitalfondue.basicxlsx:basicxlsx:0.5.0'
compile 'org.imgscalr:imgscalr-lib:4.2'
testCompile "ru.yandex.qatools.embed:postgresql-embedded:2.9"
compileOnly "javax.servlet:javax.servlet-api:3.1.0"
testCompile "javax.servlet:javax.servlet-api:3.1.0"
testCompile "org.springframework.boot:spring-boot-starter-test", {
exclude module : 'spring-boot-starter-logging'
}
testCompile "net.sourceforge.htmlunit:htmlunit:2.29"
runtime "commons-fileupload:commons-fileupload:1.3.3"
providedCompile "org.springframework.boot:spring-boot-starter-web", {
exclude module : 'spring-boot-starter-logging'
exclude group: "org.springframework.boot", module: 'spring-boot-starter-tomcat'
}
providedCompile "org.springframework.boot:spring-boot-starter", {
exclude module : 'spring-boot-starter-logging'
}
providedCompile "org.springframework.boot:spring-boot@jar", {
exclude module : 'spring-boot-starter-logging'
}
providedCompile "org.springframework.boot:spring-boot-autoconfigure@jar", {
exclude module : 'spring-boot-starter-logging'
}
providedCompile "org.springframework.boot:spring-boot-starter-log4j2"
compile "org.springframework.boot:spring-boot-starter-jetty", {
exclude group: "org.eclipse.jetty.websocket", module: "websocket-server"
exclude group: "org.eclipse.jetty.websocket", module:"javax-websocket-server-impl"
}
testCompile "org.junit.jupiter:junit-jupiter-api"
testCompile "org.junit.jupiter:junit-jupiter-engine"
testCompile "org.junit.platform:junit-platform-engine"
testRuntime "org.junit.vintage:junit-vintage-engine:$junitVersion"
providedCompile "org.springframework.boot:spring-boot-starter-jetty", {
exclude group: "org.eclipse.jetty.websocket", module: "websocket-server"
exclude group: "org.eclipse.jetty.websocket", module:"javax-websocket-server-impl"
exclude module : 'spring-boot-starter-logging'
}
providedRuntime "org.springframework.boot:spring-boot-starter-jetty", {
exclude group: "org.eclipse.jetty.websocket", module: "websocket-server"
exclude group: "org.eclipse.jetty.websocket", module:"javax-websocket-server-impl"
exclude module : 'spring-boot-starter-logging'
}
runtime "org.glassfish.jaxb:jaxb-runtime:2.4.0-b180830.0438" //temporary for JDK11
}
// -- license configuration
license {
header = rootProject.file('config/HEADER')
strictCheck = true
ignoreFailures = false
mapping {
java = 'JAVADOC_STYLE'
sql = 'DOUBLEDASHES_STYLE'
}
ext.year = '2014-'+Year.now().toString()
include '**/*.java'
include '**/*.sql'
}
processResources {
doLast {
final gradleProperties = new File((File) it.destinationDir, 'application.properties')
final properties = new Properties()
assert gradleProperties.file
gradleProperties.withReader { properties.load(it) }
properties['alfio.version'] = project.version
properties['alfio.build-ts'] = ZonedDateTime.now(ZoneId.of("UTC")).format(DateTimeFormatter.ISO_ZONED_DATE_TIME)
gradleProperties.withWriter { properties.store(it, null) }
}
}
compileJava {
options.compilerArgs = ['-Xlint:all,-serial,-processing']
}
//propagate the system properties to the tests
test {
useJUnitPlatform()
systemProperties = System.properties
testLogging {
events "failed"
exceptionFormat "full"
info.events = ["failed"]
}
}
bootRun {
def externalConfig = new File("./custom.jvmargs")
def opts = []
opts += [
"-Dspring.profiles.active=${project.springProfilesActive}",
"-Ddatasource.url=${project.datasourceUrl}",
"-Ddatasource.username=${project.datasourceUsername}",
"-Ddatasource.password=${project.datasourcePassword}",
"-Dalfio.version=${project.version}",
"-Dalfio.build-ts=${ZonedDateTime.now(ZoneId.of("UTC")).format(DateTimeFormatter.ISO_ZONED_DATE_TIME)}"
]
if(externalConfig.exists()) {
opts += externalConfig.readLines()
}
jvmArgs = opts
}
bootWar {
mainClassName = 'alfio.config.SpringBootLauncher'
classifier = 'boot'
def bowerDir = "resources/bower_components"
def excludesFile = new File("./lib_exclude")
if(excludesFile.exists()) {
exclude(excludesFile.readLines().collect({ bowerDir + it }))
}
}
// -- code-coverage
jacoco {
toolVersion = '0.8.0'
}
jacocoTestReport {
group = 'Reporting'
description = 'Generate Jacoco coverage reports after running tests.'
additionalSourceDirs = project.files(sourceSets.main.allSource.srcDirs)
sourceDirectories = project.files(sourceSets.main.allSource.srcDirs)
classDirectories = project.files(sourceSets.main.output)
reports {
xml.enabled = true
csv.enabled = false
html.enabled = true
}
}
task dockerize(type: Copy) {
from 'src/main/dist/Dockerfile'
into "${buildDir}/dockerize"
filter(ReplaceTokens, tokens: [ALFIO_VERSION: project.version])
}
task distribution(type: Copy) {
from new File(project.buildDir, "libs/alfio-${project.version}-boot.war")
into "${buildDir}/dockerize"
dependsOn build, dockerize
}
task clever(type: Copy) {
from new File(project.buildDir, "libs/alfio-${project.version}-boot.war")
rename(new Transformer<String, String>() {
@Override
String transform(String s) {
return "alfio-boot.war"
}
})
into "${project.buildDir}/clevercloud"
dependsOn build
}
import ru.yandex.qatools.embed.postgresql.EmbeddedPostgres
import ru.yandex.qatools.embed.postgresql.distribution.Version.Main
task startEmbeddedPgSQL {
doLast {
final pgsqlPath = Paths.get(".", "alfio-itest")
Files.createDirectories(pgsqlPath)
final tmpDataDir = Files.createTempDirectory(pgsqlPath, "alfio-data")
final postgres = new EmbeddedPostgres(Main.PRODUCTION, tmpDataDir.normalize().toAbsolutePath().toString())
postgres.start(EmbeddedPostgres.cachedRuntimeConfig(Paths.get(System.getProperty("java.io.tmpdir"), "pgembed")),
"localhost", 5432, "alfio", "postgres", "password", Arrays.asList("-E", "SQL_ASCII", "--locale=C", "--lc-collate=C", "--lc-ctype=C"))
postgres.getProcess().ifPresent({
final pid = it.getProcessId()
Files.write(Paths.get(".", "alfio-itest", "pgsql-pid"), Arrays.asList(Long.toString(pid)))
System.out.println("Launched pgsql with pid " + pid)
})
}
}
task stopEmbeddedPgSQL {
doLast {
final pidFile = Paths.get(".", "alfio-itest", "pgsql-pid");
final pid = Files.readAllLines(pidFile).get(0)
Files.deleteIfExists(pidFile)
Runtime.runtime.exec("kill -9 " + pid)
System.out.println("Killed pgsql with pid " + pid)
}
}
release {
buildTasks = ['distribution']
git {
requireBranch = ''
pushToRemote = 'origin'
signTag = true
}
}
lombok {
version = '1.18.4'
sha256 = ""
}