-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathbuild.gradle
431 lines (350 loc) · 12.9 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
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
buildscript {
repositories {
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath "org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:3.5.0.2730"
}
}
plugins {
id 'org.springframework.boot' version '3.3.4'
id 'io.spring.dependency-management' version '1.1.6'
id 'com.github.jk1.dependency-license-report' version '2.9'
id "org.sonarqube" version "5.1.0.4882"
id "jacoco"
id 'java'
}
jar {
enabled false
}
import com.github.jk1.license.render.*
licenseReport {
renderers = [new InventoryHtmlReportRenderer()]
outputDir = "$projectDir/build/licenses"
allowedLicensesFile = project.layout.projectDirectory.file("${rootDir}/.tmp/allowed-licenses.json").asFile
}
allprojects {
group = 'tpi.dgrv4'
version = 'v4.2.25'
apply plugin: 'io.spring.dependency-management'
repositories {
mavenCentral()
}
// 指定編碼 UTF-8
tasks.withType(JavaCompile) {
options.encoding = "UTF-8"
}
tasks.withType(Test) {
systemProperty "file.encoding", "UTF-8"
}
}
subprojects {
apply plugin: 'org.springframework.boot'
apply plugin: 'java'
apply plugin: 'java-library'
apply plugin: 'eclipse'
sourceCompatibility = '17'
targetCompatibility = '17'
dependencies {
implementation files("${rootDir}/libsext/dgrv4_CodecUtil-lib-ga95b4c20e.jar")
implementation files("${rootDir}/libsext/dgrv4_HttpUtil-lib-ga95b4c20e.jar")
implementation files("${rootDir}/libsext/onlineConsole-v1.0-55-gdc3e362.jar")
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation ('org.springframework.boot:spring-boot-starter-web'){
exclude group:'org.springframework.boot', module:'spring-boot-starter-tomcat'
}
implementation ('org.springframework.boot:spring-boot-starter-undertow:3.3.4'){
// Exclude xnio-nio to avoid CVE-2023-5685
exclude group: 'org.jboss.xnio', module: 'xnio-nio'
// Exclude undertow-core to avoid CVE-2024-6162 and CVE-2024-5971
exclude group: 'io.undertow', module: 'undertow-core'
exclude group: 'io.undertow', module: 'undertow-websockets-jsr'
}
implementation ('io.undertow:undertow-servlet:2.3.17.Final'){
// Exclude undertow-core to avoid CVE-2024-6162 and CVE-2024-5971
exclude group: 'io.undertow', module: 'undertow-core'
}
implementation 'org.jboss.xnio:xnio-nio:3.8.16.Final'
implementation 'jakarta.servlet:jakarta.servlet-api:6.1.0'
implementation 'com.h2database:h2:1.4.199'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
compileOnly 'org.projectlombok:lombok:1.18.32'
annotationProcessor 'org.projectlombok:lombok:1.18.32'
implementation 'commons-io:commons-io:2.16.1'
implementation 'org.bouncycastle:bc-fips:2.0.0'
}
// clear lib
task myClearLib(type: Delete) {
delete "$buildDir/libs/lib"
delete "$buildDir/libs/libsext"
}
// copy lib
task myCopyLib(dependsOn:resolveMainClassName, type: Copy) {
//task myCopyLib(type: Copy) {
from(configurations.runtimeClasspath){
include '**/*.jar'
exclude '**/dgrv4*.jar'
exclude '**/aws-java-sdk*.jar'
exclude '**/h2-*.jar'
exclude '**/mariadb-java-client-*.jar'
exclude '**/mssql-jdbc-*.jar'
exclude '**/ojdbc11-*.jar'
exclude '**/postgresql-*.jar'
into 'libs/lib'
}
from(configurations.runtimeClasspath){
include '**/dgrv4*.jar'
into 'libs/libsext'
}
from(configurations.runtimeClasspath){
include '**/google-cloud-logging-logback*.jar'
include '**/bcprov-jdk15on*.jar'
include '**/aws-java-sdk*.jar'
include '**/h2-*.jar'
include '**/mariadb-java-client-*.jar'
include '**/mssql-jdbc-*.jar'
include '**/ojdbc11-*.jar'
include '**/postgresql-*.jar'
into 'libs/libsext/party-3rd-jar'
}
into "$buildDir"
}
}
def getDate() {
return new Date().format('yyyyMMdd_HHmm')
}
// Gateway jar runnable
project(':dgrv4_Gateway_serv'){
// 引用其它 project
dependencies{
implementation project(':dgrv4_Common_lib')
implementation project(':dgrv4_KeeperServer_lib')
implementation project(':dgrv4_Entity_lib')
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
testImplementation 'org.junit.jupiter:junit-jupiter-api' // JUnit 5 API 介面
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine' // JUnit 5 測試框架的實作
testImplementation 'org.junit.vintage:junit-vintage-engine' // 加了這個才能跑 Junit 4 的 Test Case,因為它從 spring-boot-starter-test 移除了
testImplementation 'org.junit.platform:junit-platform-runner'
testImplementation 'org.mock-server:mockserver-junit-jupiter:5.12.0'
// jasypt
implementation 'com.github.ulisesbocchio:jasypt-spring-boot-starter:3.0.5'
// for Print SQL and Paramter
implementation group: 'com.googlecode.log4jdbc', name: 'log4jdbc', version: '1.2'
//implementation group: 'org.springdoc', name: 'springdoc-openapi-ui', version: '1.5.12'
// https://mvnrepository.com/artifact/com.nimbusds/nimbus-jose-jwt
implementation 'com.nimbusds:nimbus-jose-jwt:9.40'
// https://mvnrepository.com/artifact/commons-lang/commons-lang
implementation group: 'commons-lang', name: 'commons-lang', version: '2.6'
// https://mvnrepository.com/artifact/org.codehaus.janino/janino
implementation 'org.codehaus.janino:janino:3.0.7'
implementation 'org.apache.httpcomponents.client5:httpclient5:5.3.1'
implementation 'org.apache.httpcomponents:httpclient:4.5.14'
implementation 'org.apache.httpcomponents:httpmime:4.5.14'
implementation 'javax.activation:javax.activation-api:1.2.0'
// for tsmpdpaa
implementation 'com.sun.mail:javax.mail:1.6.2'
implementation 'org.springdoc:springdoc-openapi-ui:1.6.14'
implementation 'org.yaml:snakeyaml:2.2'
implementation ('org.apache.poi:poi-ooxml:5.3.0'){
// 'Avoid CVE-2024-26308'
exclude group: 'org.apache.commons', module: 'commons-compress'
}
implementation 'org.apache.commons:commons-compress:1.27.0'
// Kryo Serialization
implementation 'com.esotericsoftware:kryo:5.4.0'
// websocket
implementation 'org.springframework.boot:spring-boot-starter-websocket'
implementation 'io.undertow:undertow-core:2.3.17.Final'
implementation 'io.undertow:undertow-websockets-jsr:2.3.17.Final'
implementation 'com.github.oshi:oshi-core:6.4.5'
implementation 'net.java.dev.jna:jna:5.13.0'
// compileOnly: JDBC Driver 5 種
implementation 'com.h2database:h2:1.4.199'
// compileOnly: H2 Config
implementation project(':dgrv4_H2Config_lib')
implementation 'com.microsoft.sqlserver:mssql-jdbc'
implementation 'com.oracle.database.jdbc:ojdbc11'
implementation 'org.postgresql:postgresql'
implementation('org.mariadb.jdbc:mariadb-java-client:3.1.2', {
exclude group: 'net.java.dev.jna', module: 'jna-platform' //使用其它版本的相依
})
// compileOnly: Google
// https://mvnrepository.com/artifact/com.google.cloud/google-cloud-logging-logback
compileOnly 'com.google.cloud:google-cloud-logging-logback:0.130.17-alpha'
// compileOnly: AWS
//https://docs.aws.amazon.com/zh_tw/sdk-for-java/latest/developer-guide/setup-project-gradle.html
compileOnly platform('com.amazonaws:aws-java-sdk-bom:1.12.627')
compileOnly 'com.amazonaws:aws-java-sdk-s3'
// https://mvnrepository.com/artifact/com.amazonaws/aws-java-sdk-marketplacemeteringservice
compileOnly 'com.amazonaws:aws-java-sdk-marketplacemeteringservice:1.12.627'
// https://mvnrepository.com/artifact/com.amazonaws/aws-java-sdk-cloudfront
compileOnly 'com.amazonaws:aws-java-sdk-cloudfront:1.12.627'
//https://mvnrepository.com/artifact/org.bouncycastle/bcprov-jdk15on/1.70
compileOnly 'org.bouncycastle:bcprov-jdk15on:1.70'
// compileOnly: AWS Customized
implementation 'org.springframework.boot:spring-boot-starter-freemarker:3.3.4'
}
task createVersionTxt() {
doFirst {
file("src/main/resources/version.txt").text = version
}
}
build {
dependsOn bootJar
}
bootRun {
dependsOn createVersionTxt
}
bootJar {
dependsOn createVersionTxt
archivesBaseName = "${rootProject.name}"
dependsOn myClearLib
dependsOn (myCopyLib)
}
jar {
//不產生JAR檔
enabled false
}
task executeGitDescribe(type: Exec) {
commandLine 'git', 'describe', '--tags'
workingDir project.projectDir
//workingDir projectDir
standardOutput = new ByteArrayOutputStream()
doLast {
println "Git describe result: ${standardOutput.toString().trim()}"
}
}
}
project(':dgrv4_Common_lib'){
// 引用其它 project
dependencies{
testImplementation 'org.junit.jupiter:junit-jupiter-api' // JUnit 5 API 介面
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine' // JUnit 5 測試框架的實作
testImplementation 'org.junit.vintage:junit-vintage-engine' // 加了這個才能跑 Junit 4 的 Test Case,因為它從 spring-boot-starter-test 移除了
testImplementation 'org.junit.platform:junit-platform-runner'
testImplementation 'org.mock-server:mockserver-junit-jupiter:5.12.0'
// Kryo Serialization
implementation 'com.esotericsoftware:kryo:5.4.0'
// 因為 org.mariadb.jdbc:mariadb-java-client:3.1.2 子相依使用了 jna 5.x 的版本, 與程式不相
implementation 'com.github.oshi:oshi-core:6.4.5'
implementation 'net.java.dev.jna:jna:5.13.0'
}
bootJar {
//不產生JAR檔
enabled false
}
jar {
exclude "**/*.properties"
exclude "**/*.sql"
exclude "**/*.jar"
exclude "**/*.xml"
archiveClassifier = 'lib' // 去除 postfix = plain 字樣
archivesBaseName = "dgrv4-common"
if (project.hasProperty("version")) {
archiveVersion = version + '-' + getDate() //換版時修改
}
dependsOn myClearLib
}
}
project(':dgrv4_Entity_lib'){
// 引用其它 project
dependencies{
implementation project(':dgrv4_Common_lib')
compileOnly 'org.apache.commons:commons-lang3:3.12.0'
compileOnly 'com.oracle.database.jdbc:ojdbc11'
// https://nipafx.dev/static/b862798a258987401978b6731416a360/f11bc/junit-5-architecture-diagram.webp
testImplementation 'org.junit.jupiter:junit-jupiter-api' // JUnit 5 API 介面
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine' // JUnit 5 測試框架的實作
testImplementation 'org.junit.vintage:junit-vintage-engine' // 加了這個才能跑 Junit 4 的 Test Case,因為它從 spring-boot-starter-test 移除了
testImplementation 'org.junit.platform:junit-platform-runner'
testImplementation 'org.mock-server:mockserver-junit-jupiter:5.12.0'
// Kryo Serialization
compileOnly 'com.esotericsoftware:kryo:5.4.0'
}
bootJar {
//不產生JAR檔
enabled false
}
jar {
exclude "**/*.properties"
exclude "**/*.sql"
exclude "**/*.jar"
exclude "**/*.xml"
archiveClassifier = 'lib' // 去除 postfix = plain 字樣
archivesBaseName = "dgrv4_Entity"
if (project.hasProperty("version")) {
archiveVersion = version + '-' + getDate() //換版時修改
}
dependsOn myClearLib
}
}
project(':dgrv4_H2Config_lib'){
// 引用其它 project
dependencies{
implementation project(':dgrv4_Common_lib')
testImplementation 'org.junit.jupiter:junit-jupiter-api' // JUnit 5 API 介面
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine' // JUnit 5 測試框架的實作
testImplementation 'org.junit.vintage:junit-vintage-engine' // 加了這個才能跑 Junit 4 的 Test Case,因為它從 spring-boot-starter-test 移除了
testImplementation 'org.junit.platform:junit-platform-runner'
testImplementation 'org.mock-server:mockserver-junit-jupiter:5.12.0'
// compileOnly: H2 Driver
compileOnly 'com.h2database:h2:1.4.199'
}
bootJar {
//不產生JAR檔
enabled false
}
jar {
exclude "**/*.properties"
exclude "**/*.sql"
exclude "**/*.jar"
exclude "**/*.xml"
archiveClassifier = 'lib' // 去除 postfix = plain 字樣
archivesBaseName = "dgrv4_H2Config" // ** Copy 使用後記得改名字 **
if (project.hasProperty("version")) {
archiveVersion = version + '-' + getDate() //換版時修改
}
dependsOn myClearLib
}
}
project(':dgrv4_KeeperServer_lib'){
// 引用其它 project
dependencies{
compileOnly group: 'commons-lang', name: 'commons-lang', version: '2.6'
// Kryo Serialization
implementation 'com.esotericsoftware:kryo:5.4.0'
}
bootJar {
//不產生JAR檔
enabled false
}
jar {
exclude "**/*.properties"
exclude "**/*.sql"
exclude "**/*.jar"
exclude "**/*.xml"
archiveClassifier = 'lib' // 去除 postfix = plain 字樣
archivesBaseName = "dgrv4_KeeperServer"
if (project.hasProperty("version")) {
archiveVersion = version + '-' + getDate() //換版時修改
}
dependsOn myClearLib
}
}
gradle.taskGraph.whenReady {taskGraph ->
if (project.hasProperty('excludeProject')) {
println "Excluding $excludeProject"
taskGraph.getAllTasks().each { task ->
if (task.getPath().contains(excludeProject)) {
task.enabled = false
}
}
}
}
def env = System.getProperty("env") ?: "eclipse" // eclipse or win10cmd
// print message
task print0 { project.logger.lifecycle("...........................................") }
task print1 { project.logger.lifecycle("...........builed env : OpenDGR............") }
task print2 { project.logger.lifecycle("...........................................") }