-
Notifications
You must be signed in to change notification settings - Fork 4
/
build.gradle
201 lines (156 loc) · 6.49 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
import org.springframework.boot.gradle.plugin.SpringBootPlugin
plugins {
id 'java'
id 'com.heroku.sdk.heroku-gradle' version '2.0.0'
id 'jacoco'
id 'org.sonarqube' version '3.3'
id 'org.springframework.boot' version '2.7.18'
id 'io.spring.dependency-management' version '1.1.6'
id 'org.ajoberstar.git-publish' version '3.0.1'
id 'com.github.johnrengelman.processes' version '0.5.0'
id 'org.springdoc.openapi-gradle-plugin' version '1.5.0'
id 'io.freefair.lombok' version '6.4.3.1'
id 'org.liquibase.gradle' version '2.2.0'
}
group = 'org.sitmun'
def targetJavaVersion = JavaVersion.VERSION_11
sourceCompatibility = "${targetJavaVersion}"
targetCompatibility = "${targetJavaVersion}"
repositories {
mavenLocal()
mavenCentral()
}
dependencyManagement {
imports {
mavenBom SpringBootPlugin.BOM_COORDINATES
}
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-data-rest'
implementation 'org.springframework.boot:spring-boot-starter-validation'
implementation 'org.springframework.boot:spring-boot-starter-security'
implementation 'org.springframework.boot:spring-boot-starter-actuator'
implementation 'org.springframework.ldap:spring-ldap-core'
implementation 'org.springframework.security:spring-security-ldap'
testImplementation 'com.unboundid:unboundid-ldapsdk'
implementation 'org.postgresql:postgresql'
implementation 'com.oracle.database.jdbc:ojdbc8'
testImplementation 'org.hamcrest:hamcrest'
implementation "com.google.guava:guava:${guava_version}"
implementation "com.querydsl:querydsl-jpa:${querydls_version}"
implementation platform("com.squareup.okhttp3:okhttp-bom:${okhttp_version}")
implementation 'com.squareup.okhttp3:okhttp'
implementation 'com.squareup.okhttp3:logging-interceptor'
implementation "org.json:json:${json_version}"
implementation "io.jsonwebtoken:jjwt-api:${jjwt_version}"
implementation "io.jsonwebtoken:jjwt-impl:${jjwt_version}"
implementation "io.jsonwebtoken:jjwt-jackson:${jjwt_version}"
implementation "org.springdoc:springdoc-openapi-common:${springdoc_openapi_version}"
implementation "org.springdoc:springdoc-openapi-ui:${springdoc_openapi_version}"
implementation "org.mapstruct:mapstruct:${mapstruct_version}"
implementation "org.apache.commons:commons-lang3:${commons_lang3_version}"
implementation 'org.liquibase:liquibase-core'
implementation 'com.mattbertolini:liquibase-slf4j:2.0.0'
annotationProcessor 'javax.annotation:javax.annotation-api'
annotationProcessor 'org.springframework.boot:spring-boot-configuration-processor'
annotationProcessor "com.querydsl:querydsl-apt:${querydls_version}:jpa"
annotationProcessor 'javax.persistence:javax.persistence-api'
annotationProcessor "org.mapstruct:mapstruct-processor:${mapstruct_version}"
testImplementation('org.springframework.boot:spring-boot-starter-test') {
exclude group: 'com.vaadin.external.google', module: 'android-json'
}
testImplementation 'org.springframework.security:spring-security-test'
testImplementation 'com.h2database:h2'
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Stage task:
// - build app module
// - do not run tests
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
tasks.register('stage') {
dependsOn ':processResources', ':bootJar'
it.doLast {
copy {
from "build/libs/sitmun-backend-core-${version}.jar"
into "."
rename "sitmun-backend-core-${version}.jar", "sitmun.jar"
}
}
}
gradle.taskGraph.whenReady { taskGraph ->
if (taskGraph.hasTask(stage)) {
subprojects {
test.enabled = false
}
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Heroku deployment:
// - contributes the task deployHeroku
// - expects the stage task has been successfully executed
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
heroku {
def procFile = ["web": "java -Dserver.port=\$PORT \$JAVA_OPTS -cp \"sitmun.jar:env/heroku/resources/config\" org.springframework.boot.loader.JarLauncher"]
appName = "sitmun-backend-core"
includes = ["sitmun.jar"]
includeBuildDir = false
processTypes(procFile)
}
tasks.named("deployHeroku") {
it.dependsOn 'stage'
it.doLast {
delete "sitmun.jar"
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// QA
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
subprojects {
apply plugin: 'org.sonarqube'
tasks.withType(Test).configureEach {
useJUnitPlatform()
maxHeapSize = '1G'
}
}
apply from: "$project.rootDir/sonar.gradle"
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Run as local
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
tasks.register('herokuDevLocal', JavaExec) {
dependsOn 'stage'
group = "Run"
description = "Run as local the Heroku deployment"
classpath = files("build/libs/sitmun-backend-core-${version}.jar")
}
tasks.withType(Test).configureEach {
useJUnitPlatform()
}
compileJava.inputs.files(processResources)
jacocoTestReport {
reports {
xml.required.set(true)
}
}
test.finalizedBy jacocoTestReport
tasks.register("codeCoverageReport", JacocoReport) {
jacocoClasspath = project.configurations.jacocoAnt
subprojects { subproject ->
subproject.plugins.withType(JacocoPlugin).configureEach {
subproject.tasks.matching({ t -> t.extensions.findByType(JacocoTaskExtension) }).configureEach { testTask ->
if (testTask.extensions.getByType(JacocoTaskExtension).isEnabled()) {
sourceSets subproject.sourceSets.main
executionData(testTask)
} else {
logger.warn('Jacoco extension is disabled for test task \'{}\' in project \'{}\'. this test task will be excluded from jacoco report.', testTask.getName(), subproject.getName())
}
}
subproject.tasks.matching({ t -> t.extensions.findByType(JacocoTaskExtension) }).forEach {
rootProject.tasks.codeCoverageReport.dependsOn(it)
}
}
}
}
rootProject.tasks.sonarqube {
dependsOn(tasks.codeCoverageReport)
}