-
Notifications
You must be signed in to change notification settings - Fork 4
/
build.gradle
239 lines (198 loc) · 8.2 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
import org.apache.tools.ant.taskdefs.condition.Os
import org.apache.tools.ant.filters.ReplaceTokens
import org.apache.commons.io.FileUtils
// The settings.gradle file defines the name of the master project and the webapp sub-project
// This tells the rest of the gradle script which dependencies are on the classpath.
// It needs to be at the beginning.
buildscript {
repositories {
mavenCentral()
maven { url "https://repo.spring.io/milestone" }
}
dependencies {
classpath "commons-io:commons-io:2.4"
}
}
// Needs to be after the buildscript block.
plugins {
// org.gradle plugins
id "java"
id "war"
id "jacoco"
id "idea"
id "org.sonarqube" version "3.0"
// argelbargel allows the root project to be analyzed by sonarqube even though it contains sources as well as sub-modules:
id "argelbargel.gradle.plugins.sonarqube-multiproject-plugin" version "1.3"
// spring.io
id "org.springframework.boot" version "2.3.4.RELEASE"
id "io.spring.dependency-management" version "1.0.10.RELEASE"
// https://github.com/hierynomus/license-gradle-plugin used by license-finder software
id "com.github.hierynomus.license-report" version "0.15.0"
// node-gradle is used in webapp
id "com.github.node-gradle.node" version "2.2.0"
// task-tree plugin to visualise task dependencies using 'taskTree' task:
// gradle :war :taskTree --no-repeat
id "com.dorongold.task-tree" version "1.5"
}
project.buildDir = "${project.projectDir}/build/build"
// define variables ///////////////////////////////////////////////////////////////////////////////
def gitCommit = "git rev-parse HEAD".execute().text.trim()
def systemModellerName = "system-modeller"
def systemModellerVersion = "3.6.0-SNAPSHOT"
def javaVersion = 1.8
version = systemModellerVersion // picked up by sonarqube
// configure plugins //////////////////////////////////////////////////////////////////////////////
sourceCompatibility = javaVersion
targetCompatibility = javaVersion
springBoot {
mainClassName = 'uk.ac.soton.itinnovation.security.systemmodeller.SystemModellerApplication'
}
jar {
baseName = systemModellerName
version = systemModellerVersion
dependsOn(':src:main:webapp:bundleProd', 'extractWebFiles')
}
bootRun {
systemProperty 'spring.profiles.active', System.properties['spring.profiles.active']
}
//always download latest versions (spring boot has its own dependency management)
dependencyManagement {
resolutionStrategy {
cacheChangingModulesFor 0, 'seconds'
}
}
// define repositories ////////////////////////////////////////////////////////////////////////////
repositories {
mavenCentral()
}
// define dependencies ////////////////////////////////////////////////////////////////////////////
dependencies {
//spring
compile('org.springframework.boot:spring-boot-starter-data-mongodb')
compile('org.springframework.boot:spring-boot-starter-web')
compile('org.springframework.boot:spring-boot-starter-security')
compile('org.springframework.boot:spring-boot-starter-thymeleaf')
compile('org.thymeleaf.extras:thymeleaf-extras-springsecurity5')
providedRuntime('org.springframework.boot:spring-boot-starter-tomcat')
//spring-doc
compile('org.springdoc:springdoc-openapi-ui:1.5.12')
compile('org.springdoc:springdoc-openapi-security:1.5.12')
compile('org.springdoc:springdoc-openapi-javadoc:1.5.12')
//other 3rd party
compile("com.googlecode.json-simple:json-simple:1.1")
compile('javax.json:javax.json-api:1.0')
compile('org.json:json:20160810')
compile('org.seleniumhq.selenium:selenium-chrome-driver:2.52.0')
compile('org.seleniumhq.selenium:selenium-java:2.52.0')
compile('org.yaml:snakeyaml:1.23')
compile('org.keycloak:keycloak-spring-security-adapter:8.0.0')
compile('org.keycloak:keycloak-spring-boot-2-adapter:8.0.0')
compile('org.keycloak:keycloak-tomcat-adapter:8.0.0')
compile('org.keycloak:keycloak-admin-client:8.0.2')
compile('com.google.code.gson:gson:2.8.6')
compileOnly('org.projectlombok:lombok:1.18.10')
annotationProcessor('org.projectlombok:lombok:1.18.10')
compile('org.apache.jena:jena-tdb:3.14.0')
annotationProcessor('com.github.therapi:therapi-runtime-javadoc-scribe:0.12.0')
compile("net.lingala.zip4j:zip4j:2.10.0")
compile("com.bpodgursky:jbool_expressions:1.23")
//test dependencies
testCompile('org.springframework.boot:spring-boot-starter-test') {exclude group: "com.vaadin.external.google", module:"android-json"}
testCompile('org.springframework.boot:spring-boot-test')
testCompile('org.tuxdude.logback.extensions:logback-colorizer:1.0.1')
testCompile('io.rest-assured:rest-assured:3.0.3')
testCompile('io.rest-assured:xml-path:3.0.3')
testCompile('org.hamcrest:hamcrest-all:1.3')
testCompile('org.assertj:assertj-core:3.14.0')
}
//tasks////////////////////////////////////////////////////////////////////////////////////////////
task extractWebFiles(type: Copy) {
from {
"${project.projectDir}/src/main/webapp/dist"
}
into "${project.projectDir}/src/main/resources/static/dist"
}
task extractWebFilesProd(dependsOn: ':src:main:webapp:bundleProd') {
doLast {
File webappDist = file("${project.projectDir}/src/main/webapp/dist")
if (webappDist.exists()) {
println("Running extractWebFilesProd from webapp: " + webappDist)
File srcDist = file("${project.projectDir}/src/main/resources/static/dist")
File buildDist = file("${project.buildDir}/resources/main/static/dist")
def filesToCopy = copySpec {
from webappDist
}
[srcDist, buildDist].each { dest ->
copy {
with filesToCopy
into dest
}
println('Copied into: ' + dest)
}
} else {
println("SKIPPING extractWebFilesProd: webapp files missing: " + webappDist)
}
}
}
// Exclude extra packaging by Spring framework
bootWar {
enabled = false
}
// Configure war file packaging
war {
enabled = true
baseName = systemModellerName
dependsOn('extractWebFilesProd')
exclude(".gradle")
exclude(".eslintignore")
exclude("node_modules")
exclude("yarn*")
exclude("build.gradle")
exclude("package.json")
exclude("src/main/resources")
exclude("users-assured.json")
exclude("users-5g.json")
include("${project.buildDir}/resources/main")
}
task bootTest(type: org.springframework.boot.gradle.tasks.run.BootRun) {
doFirst() {
main = springBoot.mainClassName
classpath = sourceSets.main.runtimeClasspath
systemProperty 'spring.profiles.active', 'test'
}
dependsOn ':src:main:webapp:bundle'
dependsOn 'extractWebFiles'
tasks.findByName('extractWebFiles').mustRunAfter('src:main:webapp:bundle')
}
// https://karolkalinski.github.io/gradle-task-that-runs-spring-boot-aplication-with-profile-activated/
task bootDev(type: org.springframework.boot.gradle.tasks.run.BootRun) {
doFirst() {
main = springBoot.mainClassName
classpath = sourceSets.main.runtimeClasspath
systemProperty 'spring.profiles.active', 'dev'
}
}
test {
systemProperties = System.properties
systemProperties['user.dir'] = workingDir
testLogging {
events "passed", "skipped", "failed" //, "standardOut", "standardError"
showStandardStreams = true
afterSuite { desc, result ->
if (!desc.parent) { // will match the outermost suite
def output = "Result: ${result.resultType} (${result.testCount} tests, ${result.successfulTestCount} successes, ${result.failedTestCount} failures, ${result.skippedTestCount} skipped)"
def startItem = '| ', endItem = ' |'
def repeatLength = startItem.length() + output.length() + endItem.length()
println('\n' + ('-' * repeatLength) + '\n' + startItem + output + endItem + '\n' + ('-' * repeatLength))
}
}
}
finalizedBy jacocoTestReport // generate test coverage report after tests run successfully
}
jacocoTestReport {
dependsOn test
reports {
xml.enabled true
csv.enabled false
}
}