-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
221 lines (188 loc) · 5.38 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
plugins {
id 'com.diffplug.spotless' version '6.2.2'
id 'com.github.ben-manes.versions' version '0.42.0'
id 'com.github.spotbugs' version '5.0.5'
id 'com.star-zero.gradle.githook' version '1.2.1'
id "fish.payara.micro-gradle-plugin" version "1.1.0"
id 'io.swagger.core.v3.swagger-gradle-plugin' version '2.2.0'
id 'pl.allegro.tech.build.axion-release' version '1.13.6'
id 'ru.netris.commitlint' version '1.4.1'
id 'se.bjurr.gitchangelog.git-changelog-gradle-plugin' version '1.79.0'
id 'checkstyle'
id 'jacoco'
id 'java'
id 'pmd'
id 'war'
}
group = 'app'
version = '0.0.1-SNAPSHOT'
repositories {
mavenCentral()
}
sourceSets {
integrationTest {
compileClasspath += sourceSets.main.output + project.configurations.testCompileClasspath
runtimeClasspath += sourceSets.main.output + project.configurations.testRuntimeClasspath
}
}
dependencies {
implementation 'org.eclipse.microprofile:microprofile:4.1'
implementation 'org.eclipse.microprofile.openapi:microprofile-openapi-api:3.0'
implementation 'org.microprofile-ext.openapi-ext:openapi-ui:1.1.5'
testImplementation 'org.junit.jupiter:junit-jupiter:5.8.2'
testImplementation 'org.mockito:mockito-junit-jupiter:4.6.1'
testImplementation 'org.mockito:mockito-core:4.6.1'
testImplementation 'org.mockito:mockito-inline:4.6.1'
testImplementation 'org.testcontainers:testcontainers:1.17.2'
testImplementation 'org.testcontainers:junit-jupiter:1.17.2'
testImplementation 'io.rest-assured:rest-assured:5.1.0'
}
java {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
compileJava {
options.encoding = 'UTF-8'
options.compilerArgs << '-parameters'
}
war {
archiveFileName = 'microprofile-api.war'
}
payaraMicro {
payaraVersion = '5.2022.2'
deployWar = true
javaCommandLineOptions = ['agentlib': 'jdwp=transport=dt_socket,server=y,suspend=n,address=5005']
}
githook {
failOnMissingHooksDir = false
hooks {
'commit-msg' {
task = 'commitlint'
}
}
}
resolve {
outputFileName = 'openapi'
outputFormat = 'YAML'
prettyPrint = 'TRUE'
classpath = sourceSets.main.runtimeClasspath
resourcePackages = ['app']
outputDir = file('build')
}
checkstyle {
toolVersion = '9.0'
configFile = file('checkstyle.xml')
}
pmd {
toolVersion = '6.38.0'
}
spotless {
java {
target 'src/**/*.java'
importOrder()
removeUnusedImports()
prettier([
'prettier': '2.5.1',
'prettier-plugin-java': '1.6.1'
]).configFile('.prettierrc')
}
}
spotbugs {
toolVersion = '4.4.1'
}
jacoco {
toolVersion = '0.8.7'
}
jacocoTestReport {
dependsOn test
finalizedBy jacocoTestCoverageVerification
}
jacocoTestCoverageVerification {
dependsOn test
violationRules {
rule {
limit {
minimum = 0.8
}
}
}
}
check {
dependsOn.clear()
dependsOn 'lint', 'test'
}
test {
finalizedBy jacocoTestReport
useJUnitPlatform()
testLogging {
exceptionFormat = 'full'
}
}
task integrationTest(type: Test) {
description = 'Runs the integration tests.'
group = 'Verification'
testClassesDirs = sourceSets.integrationTest.output.classesDirs
classpath = sourceSets.integrationTest.runtimeClasspath
useJUnitPlatform()
testLogging {
exceptionFormat = 'full'
}
}
task lint() {
dependsOn 'formatCheck', 'checkstyle', 'pmd', 'spotbugs'
description = 'Runs several static code analysis.'
group = 'Verification'
}
task checkstyle() {
dependsOn 'checkstyleIntegrationTest', 'checkstyleMain', 'checkstyleTest'
description = 'Runs Checkstyle analysis for the source folder.'
group = 'Verification'
}
task pmd() {
dependsOn 'pmdIntegrationTest', 'pmdMain', 'pmdTest'
description = 'Runs PMD analysis for the source folder.'
group = 'Verification'
}
task spotbugs() {
dependsOn 'spotbugsIntegrationTest', 'spotbugsMain', 'spotbugsTest'
description = 'Runs SpotBugs analysis for the source folder.'
group = 'Verification'
tasks.withType(com.github.spotbugs.snom.SpotBugsTask) {
reports {
html.enabled = true
}
}
}
task format() {
dependsOn 'spotlessApply'
description = 'Applies code formatting steps to source code in-place.'
group = 'Verification'
}
task formatCheck() {
dependsOn 'spotlessCheck'
description = 'Checks that source code satisfies formatting steps.'
group = 'Verification'
}
task generateOpenApi() {
dependsOn 'resolve'
description = 'Generates the openapi specification file.'
group = 'Release'
}
task generateChangelog(type: se.bjurr.gitchangelog.plugin.gradle.GitChangelogTask) {
description = 'Generates a changelog from GIT repository.'
group = 'Release'
fromRepo = file('.')
file = file('CHANGELOG.md');
templateContent = file('changelog.mustache').getText('UTF-8');
}
task buildImage(type: Exec) {
dependsOn 'war'
commandLine 'docker', 'build', '-f', 'src/main/docker/Dockerfile', '-t', 'microprofile-api', '.'
description = 'Builds a Docker image of the application.'
group = 'Build'
}
task deploy(type: Exec) {
commandLine 'ansible-playbook', 'ci/deploy/deploy-to-swarm.yaml'
description = 'Deploys the application to Docker Swarm.'
group = 'Release'
}