-
Notifications
You must be signed in to change notification settings - Fork 6
/
build.gradle
272 lines (237 loc) · 8.61 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
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath "org.springframework.boot:spring-boot-gradle-plugin:2.2.2.RELEASE"
}
}
plugins {
id "org.flywaydb.flyway" version "6.0.8"
id "org.sonarqube" version "3.3"
id "com.moowork.node" version "0.12"
}
apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
apply plugin: 'checkstyle'
apply plugin: 'jacoco'
apply plugin: 'pmd'
group = serviceGroup
version = serviceVersion
archivesBaseName = rootProject.name
project.ext.buildTime = java.time.Instant.now().toString() // for versioning
sourceCompatibility = 1.8
targetCompatibility = 1.8
repositories {
mavenCentral()
jcenter()
maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
}
dependencies {
compile 'com.fasterxml.jackson.datatype:jackson-datatype-hibernate4:2.10.0'
compile 'commons-io:commons-io:2.6'
compile 'net.sf.supercsv:super-csv-dozer:2.4.0'
compile 'net.sf.supercsv:super-csv:2.4.0'
compile 'org.apache.commons:commons-collections4:4.4'
compile 'org.apache.commons:commons-csv:1.7'
compile 'org.apache.commons:commons-lang3:3.9'
compile 'org.apache.commons:commons-text:1.8'
compile 'org.flywaydb:flyway-core'
compile 'org.hibernate:hibernate-java8'
compile 'org.javers:javers-spring-boot-starter-sql:2.8.1'
compile 'org.openlmis:openlmis-service-util:3.1.0'
compile 'org.postgresql:postgresql:42.0.0'
compile "org.projectlombok:lombok"
compile 'org.slf4j:slf4j-ext:1.7.25'
compile 'org.springframework.boot:spring-boot-starter-data-jpa'
compile 'org.springframework.boot:spring-boot-starter-security'
compile 'org.springframework.boot:spring-boot-starter-web'
compile 'org.springframework.security.oauth.boot:spring-security-oauth2-autoconfigure:2.2.2.RELEASE'
compile 'org.springframework.security:spring-security-oauth2-core'
compile 'org.springframework.security:spring-security-oauth2-client'
compile 'org.springframework:spring-context-support'
compile 'org.webjars.npm:api-console:3.0.17'
annotationProcessor 'org.projectlombok:lombok:1.18.22'
testCompile 'be.joengenduvel.java.verifiers:to-string:1.0.2'
testCompile 'com.github.tomakehurst:wiremock:2.22.0'
testCompile 'com.jayway.restassured:rest-assured:2.7.0'
testCompile 'guru.nidi.raml:raml-tester:0.8.15'
testCompile "org.raml:raml-parser:0.8.37"
testCompile 'junit:junit'
testCompile 'nl.jqno.equalsverifier:equalsverifier:3.1.10'
testCompile 'org.mockito:mockito-core:2.23.0'
testCompile 'org.powermock:powermock-api-mockito2:2.0.0'
testCompile 'org.powermock:powermock-module-junit4:2.0.0'
testCompile 'org.springframework.boot:spring-boot-starter-test'
testCompile 'org.springframework:spring-test'
testAnnotationProcessor 'org.projectlombok:lombok:1.18.22'
}
idea {
project {
vcs = 'Git'
ipr.withXml { xmlFile ->
// enable 'Annotation Processors', source: https://gist.github.com/stephanos/8645809
xmlFile.asNode().component
.find { it.@name == 'CompilerConfiguration' }['annotationProcessing'][0]
.replaceNode {
annotationProcessing {
profile(default: true, name: 'Default', useClasspath: 'true', enabled: true)
}
}
}
/* iml.withXml { xmlFile ->
xmlFile.asNode().component.find { it.@name == 'NewModuleRootManager'}['Content'][0]
.addNode {
sourceFolder {
profile(url: "file://$MODULE_DIR\$/src/integration-test/java", isTestSource:
true)
}
}
}*/
}
}
flyway {
url = "$System.env.DATABASE_URL"
user = "$System.env.POSTGRES_USER"
password = "$System.env.POSTGRES_PASSWORD"
schemas = ['cce']
sqlMigrationPrefix = ''
placeholderPrefix = '#['
placeholderSuffix = ']'
}
sourceSets {
integrationTest {
java {
compileClasspath += main.output + test.output
runtimeClasspath += main.output + test.output
srcDir file('src/integration-test/java')
}
resources.srcDir file('src/integration-test/resources')
}
}
configurations {
integrationTestCompile.extendsFrom testCompile
integrationTestRuntime.extendsFrom testRuntime
}
task flywayTest(type: Test) {
testClassesDirs = sourceSets.integrationTest.output.classesDirs
classpath = sourceSets.integrationTest.runtimeClasspath
testLogging {
events "passed", "skipped", "failed"
exceptionFormat = 'full'
}
include '**/migration/**'
}
task integrationTest(type: Test) {
testClassesDirs = sourceSets.integrationTest.output.classesDirs
classpath = sourceSets.integrationTest.runtimeClasspath
testLogging {
events "passed", "skipped", "failed"
exceptionFormat = 'full'
}
mustRunAfter test
environment 'BASE_URL', "http://localhost"
exclude '**/migration/**'
}
tasks.withType(Test) {
reports.html.destination = file("${reporting.baseDir}/${name}")
reports.junitXml.destination = file("${testResultsDir}/${name}")
}
// Usage: gradle generateMigration [-PmigrationName=name_of_migration]
// Defaults to 'migration' as migration name
// Example: gradle generateMigration -PmigrationName=add_column_to_users
// Will create a file in migration folder with name yyyyMMddHHmmssSSS_add_column_to_users.sql.
task generateMigration {
description 'Creates an empty new file within the src/main/resources/db/migration directory into which developers can add new SQL migration code.'
doLast {
def fileName = project.hasProperty('migrationName') ? migrationName : 'migration'
def timestamp = new Date().format('yyyyMMddHHmmssSSS', TimeZone.getTimeZone('GMT'))
def fullFileName = "${timestamp}__${fileName}.sql"
def migrationFile = new File(sourceSets.main.resources.srcDirs.first(), 'db/migration/' + fullFileName)
migrationFile << "-- WHEN COMMITTING OR REVIEWING THIS FILE: Make sure that the timestamp in the file name (that serves as a version) is the latest timestamp, and that no new migration have been added in the meanwhile.\n"
migrationFile << "-- Adding migrations out of order may cause this migration to never execute or behave in an unexpected way.\n"
migrationFile << "-- Migrations should NOT BE EDITED. Add a new migration to apply changes."
migrationFile.createNewFile()
}
}
task checkApiIsRaml(type:Exec) {
executable "raml-cop"
args "src/main/resources/api-definition.yaml"
}
configure(checkApiIsRaml) {
group = JavaBasePlugin.VERIFICATION_GROUP
description = 'Verify that the api-specification is valid RAML'
}
jacocoTestReport {
group = "reporting"
description = "Generate Jacoco coverage reports after running tests."
reports {
xml.enabled true
html.enabled true
csv.enabled false
}
additionalSourceDirs(files(sourceSets.main.allJava.srcDirs))
}
checkstyle {
toolVersion = "8.12"
}
//NOTE: This plugin requires that this task be named 'sonarqube'. In fact, it is performing SonarCloud analysis.
sonarqube {
properties {
property "sonar.projectKey", "OpenLMIS_openlmis-cce"
property "sonar.organization", "openlmis"
property "sonar.host.url", "https://sonarcloud.io"
property "sonar.java.source", "17"
property "sonar.coverage.jacoco.xmlReportPaths", "./report.xml"
}
}
pmd {
toolVersion = '5.4.0'
consoleOutput= true
ignoreFailures = false
ruleSetFiles = files("config/pmd/ruleset.xml")
reportsDir = file("build/reports/pmd")
}
tasks.withType(Pmd){
reports {
xml.enabled true
html.enabled true
}
}
test {
testLogging {
events 'started', 'passed'
exceptionFormat = 'full'
}
}
apply from: "documentation.gradle"
integrationTest {
dependsOn ramlToHtml
}
processResources {
// we want the generated HTML spec file included in the output jar
finalizedBy ramlToHtml
// update version information in build
filesMatching('**/version.properties') {
expand(project.properties)
}
}
apply from: "registration.gradle"
assemble {
dependsOn ramlToHtml
dependsOn copyRamlHtmlToBuild
dependsOn copyConsulRegistrationToBuild
dependsOn jacocoTestReport
}
check {
dependsOn ramlToHtml
dependsOn copyRamlHtmlToBuild
dependsOn integrationTest
dependsOn copyConsulRegistrationToBuild
}
build {
dependsOn jacocoTestReport
dependsOn check
}