This repository has been archived by the owner on Jun 27, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.gradle
213 lines (169 loc) · 6.02 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
plugins {
id 'java'
id 'com.github.ben-manes.versions' version '0.39.0'
id 'org.sonarqube' version '3.2.0'
id 'com.github.spotbugs' version '4.7.1'
id 'checkstyle'
id 'jacoco'
}
group 'com.github.ayltai'
version '3.3.7'
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
repositories {
jcenter()
}
ext {
awsSdkVersion = '1.11.1034'
awsLambdaCoreVersion = '1.2.1'
awsLambdaEventsVersion = '3.9.0'
jacksonVersion = '2.12.2'
gsonVersion = '2.8.7'
jsonVersion = '20210307'
lombokVersion = '1.18.20'
spotBugsVersion = '4.2.3'
jetBrainsVersion = '21.0.1'
junitVersion = '5.7.2'
mockitoVersion = '3.11.0'
}
configurations {
all {
resolutionStrategy {
force "com.fasterxml.jackson.core:jackson-core:$jacksonVersion"
force "com.fasterxml.jackson.dataformat:jackson-databind:$jacksonVersion"
force "com.fasterxml.jackson.dataformat:jackson-dataformat-cbor:$jacksonVersion"
}
}
compileOnly {
extendsFrom annotationProcessor
}
}
dependencies {
// AWS SDK libraries
implementation platform("com.amazonaws:aws-java-sdk-bom:$awsSdkVersion")
implementation 'com.amazonaws:aws-java-sdk-dynamodb'
// AWS Lambda libraries
implementation "com.amazonaws:aws-lambda-java-core:$awsLambdaCoreVersion"
implementation "com.amazonaws:aws-lambda-java-events:$awsLambdaEventsVersion"
// JSON and XML
implementation "com.fasterxml.jackson.dataformat:jackson-dataformat-xml:$jacksonVersion"
implementation "com.google.code.gson:gson:$gsonVersion"
implementation "org.json:json:$jsonVersion"
// Code generation
compileOnly "org.projectlombok:lombok:$lombokVersion"
annotationProcessor "org.projectlombok:lombok:$lombokVersion"
testCompileOnly "org.projectlombok:lombok:$lombokVersion"
testAnnotationProcessor "org.projectlombok:lombok:$lombokVersion"
// Utilities
compileOnly "com.github.spotbugs:spotbugs-annotations:$spotBugsVersion"
compileOnly "org.jetbrains:annotations:$jetBrainsVersion"
testCompileOnly "org.jetbrains:annotations:$jetBrainsVersion"
// Unit testing
testImplementation "org.mockito:mockito-core:$mockitoVersion"
testImplementation "org.junit.jupiter:junit-jupiter-api:$junitVersion"
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:$junitVersion"
}
//region Checkstyle
checkstyle {
toolVersion = '8.40'
configFile = file('./checkstyle.xml')
ignoreFailures = true
showViolations = true
}
tasks.withType(Checkstyle) {
source = 'src/main/java'
include '**/*.java'
exclude '**/*Test.java'
reports {
xml.enabled = Boolean.valueOf(System.getenv('CI'))
html.enabled = !System.getenv('CI')
xml.destination file("$project.buildDir/reports/checkstyle/checkstyle-output.xml")
html.destination file("$project.buildDir/reports/checkstyle/checkstyle-output.html")
}
}
//endregion
//region SpotBugs
spotbugs {
toolVersion.set(spotBugsVersion)
ignoreFailures.set(true)
excludeFilter.set(file('./spotbugs-exclude.xml'))
effort 'max'
reportLevel 'medium'
}
spotbugsMain {
reports {
xml.enabled = Boolean.valueOf(System.getenv('CI'))
html.enabled = !System.getenv('CI')
}
}
//endregion
//region JaCoCo
jacoco {
toolVersion '0.8.6'
}
jacocoTestReport {
dependsOn 'test'
reports {
xml.enabled = true
html.enabled = true
}
}
tasks.withType(Test) {
jacoco.includeNoLocationClasses = true
jacoco.excludes = [ 'jdk.internal.*', ]
}
//endregion
sonarqube {
properties {
property 'sonar.host.url', 'https://sonarcloud.io'
property 'sonar.organization', 'ayltai'
property 'sonar.projectKey', 'ayltai_hknews'
property 'sonar.login', System.getenv('SONAR_TOKEN')
property 'sonar.sources', 'src/main/java,src/main/javascript'
property 'sonar.tests', 'src/test/java,src/test/javascript'
property 'sonar.javascript.lcov.reportPaths', 'coverage/lcov.info'
}
}
test {
useJUnitPlatform()
dependsOn 'startDynamoDbLocal'
finalizedBy 'stopDynamoDbLocal'
}
Process process
task startDynamoDbLocal {
group 'test setup'
description 'Start Amazon DynamoDB Local server'
def packagePath = "$buildDir/tmp/downloadDynamoDbLocal/dynamodb_local_latest.tar.gz"
doLast {
if (!file("$buildDir/tmp/downloadDynamoDbLocal/DynamoDBLocal.jar").exists()) {
if (!file(packagePath).exists()) {
file("$buildDir/tmp/downloadDynamoDbLocal").mkdirs()
new FileOutputStream(packagePath).channel.transferFrom java.nio.channels.Channels.newChannel(new URL('https://s3.ap-southeast-1.amazonaws.com/dynamodb-local-singapore/dynamodb_local_latest.tar.gz').openStream()), 0, Long.MAX_VALUE
copy {
from tarTree(packagePath)
into file("$buildDir/tmp/downloadDynamoDbLocal/")
}
}
}
process = new ProcessBuilder("/usr/bin/java", "-Djava.library.path=$buildDir/tmp/downloadDynamoDbLocal/DynamoDBLocal_lib", "-jar", "$buildDir/tmp/downloadDynamoDbLocal/DynamoDBLocal.jar", "-inMemory").start()
}
}
task stopDynamoDbLocal {
group 'test setup'
description 'Stop Amazon DynamoDB Local server'
doLast {
if (process != null) process.destroy()
}
}
task packageZip(dependsOn : assemble, type : Zip) {
group 'deploy'
description 'Package a distributable zip file'
archiveFileName = 'hknews.zip'
dirMode = 0755
fileMode = 0644
from compileJava
from processResources
into('lib') {
from configurations.runtimeClasspath
}
}