-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.gradle
208 lines (178 loc) · 7.39 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
/*
* This file is part of MrFoosball (https://github.com/gesundkrank/mrfoosball).
* Copyright (c) 2020 Jan Graßegger.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import com.bmuschko.gradle.docker.tasks.image.DockerBuildImage
import com.bmuschko.gradle.docker.tasks.image.Dockerfile
import com.github.spotbugs.SpotBugsTask
buildscript {
repositories {
jcenter()
}
dependencies {
classpath "com.avast.gradle:gradle-docker-compose-plugin:0.8.12"
}
}
plugins {
id 'java'
id 'checkstyle'
id "com.github.spotbugs" version "3.0.0"
id 'application'
id 'com.github.johnrengelman.shadow' version '4.0.3'
id 'com.bmuschko.docker-remote-api' version '6.1.3'
id 'com.github.node-gradle.node' version '2.2.0'
}
apply plugin: 'docker-compose'
repositories {
jcenter()
mavenCentral()
}
group = "de.gesundkrank.mrfoosball"
mainClassName = 'de.gesundkrank.mrfoosball.Main'
compileJava {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
checkstyle {
ignoreFailures = false
maxWarnings = 0
}
spotbugs {
excludeFilter = file("$rootProject.projectDir/config/findbugs/excludeFilter.xml")
}
test {
useTestNG()
}
def jerseyVersion = '2.30'
dependencies {
implementation group: 'org.glassfish.jersey.containers', name: 'jersey-container-grizzly2-http',
version: jerseyVersion
implementation group: 'org.glassfish.jersey.inject', name: 'jersey-hk2', version: jerseyVersion
implementation(group: 'org.glassfish.jersey.media', name: 'jersey-media-moxy',
version: jerseyVersion) {
exclude group: 'org.eclipse.persistence', module: 'org.eclipse.persistence.moxy'
}
implementation group: 'org.glassfish.jersey.containers', name: 'jersey-container-servlet-core',
version: jerseyVersion
// https://mvnrepository.com/artifact/org.eclipse.persistence/org.eclipse.persistence.moxy
implementation group: 'org.eclipse.persistence', name: 'org.eclipse.persistence.moxy',
version: '2.7.3'
// https://mvnrepository.com/artifact/org.hibernate/hibernate-core
implementation group: 'org.hibernate', name: 'hibernate-core', version: '5.4.0.Final'
// https://mvnrepository.com/artifact/org.postgresql/postgresql
implementation group: 'org.postgresql', name: 'postgresql', version: '9.4.1212'
implementation group: 'org.apache.logging.log4j', name: 'log4j-api', version: '2.8.2'
implementation group: 'org.apache.logging.log4j', name: 'log4j-core', version: '2.8.2'
implementation 'org.apache.logging.log4j:log4j-1.2-api:2.8.2'
implementation 'org.apache.logging.log4j:log4j-slf4j-impl:2.8.2'
// https://mvnrepository.com/artifact/org.postgresql/postgresql
implementation group: 'de.gesundkrank.jskills', name: 'jskills', version: '1.1'
// https://mvnrepository.com/artifact/org.apache.zookeeper/zookeeper
implementation group: 'org.apache.zookeeper', name: 'zookeeper', version: '3.4.11'
// https://mvnrepository.com/artifact/com.google.zxing/core
implementation group: 'com.google.zxing', name: 'core', version: '3.3.3'
implementation 'com.sun.xml.bind:jaxb-impl:2.3.1'
// https://mvnrepository.com/artifact/javax.json/javax.json-api
implementation group: 'org.glassfish', name: 'javax.json', version: '1.1.4'
// https://mvnrepository.com/artifact/commons-io/commons-io
implementation group: 'commons-io', name: 'commons-io', version: '2.6'
// https://mvnrepository.com/artifact/commons-codec/commons-codec
implementation group: 'commons-codec', name: 'commons-codec', version: '1.14'
// https://mvnrepository.com/artifact/org.testng/testng
testImplementation group: 'org.testng', name: 'testng', version: '7.1.0'
testImplementation group: "org.glassfish.jersey.test-framework.providers",
name: "jersey-test-framework-provider-grizzly2", version: jerseyVersion
testImplementation 'org.mockito:mockito-core:3.2.4'
}
node {
download = true
version = '11.6.0'
}
shadowJar {
baseName = 'mrfoosball'
classifier = null
}
tasks.withType(SpotBugsTask) {
reports {
xml.enabled false
html.enabled true
}
}
task tslint(type: NpmTask) {
args = ['--prefix', 'frontend', 'run-script', 'tslint']
}
task cleanNodeModules(type: Delete) {
delete 'frontend/node_modules'
}
task installFrontend(type: NpmTask) {
args = ['--prefix', 'frontend', 'install']
}
installFrontend.shouldRunAfter cleanNodeModules
task cleanFrontend(type: Delete, dependsOn: installFrontend) {
delete 'build/resources/main/www'
delete 'frontend/www'
}
task buildFrontend(type: NpmTask, dependsOn: cleanFrontend) {
args = ['--prefix', 'frontend', 'run', 'build']
}
task buildProductionFrontend(type: NpmTask, dependsOn: [cleanFrontend, tslint]) {
args = ['--prefix', 'frontend', 'run', 'buildProduction']
}
task copyFrontend(type: Copy) {
from 'frontend/www'
into 'build/resources/main/www'
}
copyFrontend.shouldRunAfter buildFrontend, buildProductionFrontend
task buildApp(dependsOn: [shadowJar, copyFrontend])
task productionDockerFile(type: Dockerfile) {
destFile = project.file('build/libs/Dockerfile')
from "openjdk:$compileJava.targetCompatibility-slim"
workingDir 'mrfoosball'
copyFile 'mrfoosball.jar', '.'
exposePort 8080
entryPoint 'java', '-jar', 'mrfoosball.jar'
}
task testDockerFile(type: Dockerfile) {
destFile = project.file('build/libs/Dockerfile')
from "openjdk:$compileJava.targetCompatibility-slim"
environmentVariable 'DOCKERIZE_VERSION', 'v0.6.1'
workingDir 'mrfoosball'
exposePort 8080
addFile 'https://github.com/jwilder/dockerize/releases/download/v0.6.1/dockerize-linux-amd64-v0.6.1.tar.gz',
'dockerize.tar.gz'
runCommand 'tar -C /usr/local/bin -xvzf dockerize.tar.gz'
copyFile 'mrfoosball.jar', '.'
copyFile 'mrfoosball.properties', '.'
entryPoint 'dockerize', '-wait', 'tcp://postgres:5432', 'java',
'-Dorg.jboss.logging.provider=log4j2', '-jar', 'mrfoosball.jar'
}
task buildDocker(type: DockerBuildImage,
dependsOn: [buildProductionFrontend, buildApp, productionDockerFile]) {
inputDir = productionDockerFile.destFile.get().asFile.parentFile
images.add("${project.findProperty('imageName') ?: 'mrfoosball'}:" +
"${project.findProperty('tag') ?: 'latest'}")
}
task dockerTest(type: DockerBuildImage) {
Task frontendDep = project.hasProperty('production') ? buildProductionFrontend : buildFrontend
dependsOn frontendDep, buildApp, testDockerFile
inputDir = testDockerFile.destFile.get().asFile.parentFile
images.add("${project.findProperty('imageName') ?: 'mrfoosball'}:" +
"${project.findProperty('tag') ?: 'latest'}")
copy {
from 'mrfoosball.properties'
into inputDir.get().toString()
}
}
composeUp.dependsOn(dockerTest)