-
Notifications
You must be signed in to change notification settings - Fork 2
/
build.gradle
299 lines (260 loc) · 9.69 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
/*
SPDX-FileCopyrightText: (C)2021 SAP SE or an affiliate company and aas4j-transformation-library contributors. All rights reserved.
SPDX-License-Identifier: Apache-2.0
*/
plugins {
id 'java'
id 'jacoco'
id 'application'
id 'com.diffplug.spotless' version '5.15.1'
id 'com.github.ksoichiro.console.reporter' version '0.6.2'
id 'se.bjurr.violations.violations-gradle-plugin' version '1.40'
id 'com.github.johnrengelman.shadow' version '6.1.0'
id 'eclipse'
id 'idea'
id 'maven-publish'
}
group = 'org.eclipse.digitaltwin.aas4j'
version = '0.1.3'
application {
group = group
version = version
mainClass.set('org.eclipse.digitaltwin.aas4j.ConsoleApplication')
}
mainClassName = application.mainClass.get()
shadowDistZip.enabled(false)
shadowDistTar.enabled(false)
configurations {
// Configure this for lombok
annotationProcessor {
extendsFrom implementation
}
}
java {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
test {
useJUnitPlatform {
includeEngines 'junit-jupiter'
excludeTags 'integration-test'
}
ignoreFailures = false
testLogging {
events = ['passed', 'skipped', 'failed', 'standardOut', 'standardError']
exceptionFormat = org.gradle.api.tasks.testing.logging.TestExceptionFormat.FULL
showStandardStreams = false
}
reports {
junitXml {
enabled = true
destination = file("${buildDir}/reports/junit/xml")
}
html {
enabled = true
destination = file("${buildDir}/reports/junit/html")
}
}
finalizedBy jacocoTestReport
}
task integrationTest(type: Test) {
useJUnitPlatform {
includeEngines 'junit-jupiter'
includeTags 'integration-test'
}
ignoreFailures = false
testLogging {
events = ['passed', 'skipped', 'failed', 'standardOut', 'standardError']
exceptionFormat = org.gradle.api.tasks.testing.logging.TestExceptionFormat.FULL
showStandardStreams = true
}
reports {
junitXml {
enabled = true
destination = file("${buildDir}/reports/integration/xml")
}
html {
enabled = true
destination = file("${buildDir}/reports/integration/html")
}
}
shouldRunAfter test
}
consoleReporter {
jacoco {
enabled true
onlyWhenCoverageTaskExecuted false
reportAfterBuildFinished true
failIfLessThanThresholdError true
autoconfigureCoverageConfig true
coverageTaskName 'jacocoTestReport'
reportFile project.file("${buildDir}/reports/jacoco/xml/jacoco.xml")
thresholdFine 80
thresholdWarning 65
thresholdError 50
brokenCoverageErrorMessage 'Code Coverage has fallen below the defined threshold.'
colorEnabled true
}
}
jacoco {
toolVersion = '0.8.6'
reportsDir = file("${buildDir}/reports/jacoco")
}
jacocoTestReport {
dependsOn test
reports {
csv {
enabled true
destination file("${buildDir}/reports/jacoco/csv/jacoco.csv")
}
xml {
enabled true
destination file("${buildDir}/reports/jacoco/xml/jacoco.xml")
}
html {
enabled true
destination file("${buildDir}/reports/jacoco/html")
}
}
// Display the code coverage every time after the jacocoTestReport run
finalizedBy project.tasks.reportCoverage
}
javadoc {
options.addBooleanOption('html5', true)
}
spotless {
enforceCheck = false
format 'misc', {
target('.gitignore')
trimTrailingWhitespace()
indentWithSpaces()
endWithNewline()
}
format 'gradle', {
target('*.gradle')
trimTrailingWhitespace()
indentWithSpaces()
endWithNewline()
licenseHeader('/* \n SPDX-FileCopyrightText: (C)$YEAR SAP SE or an affiliate company and aas4j-transformation-library contributors. All rights reserved. \n\n SPDX-License-Identifier: Apache-2.0 \n */','\\w')
}
// format 'xmlaml', {
// target('src/**/*.xml','src/**/*.aml')
// trimTrailingWhitespace()
// indentWithSpaces()
// endWithNewline()
// licenseHeader('<!-- \n SPDX-FileCopyrightText: (C)$YEAR SAP SE or an affiliate company and aas4j-transformation-library contributors. All rights reserved. \n\n SPDX-License-Identifier: Apache-2.0 \n -->','<[^!]')
// }
java {
encoding("UTF8")
trimTrailingWhitespace()
removeUnusedImports()
endWithNewline()
eclipse('4.12.0').configFile 'codestyle/EclipseFormatterProfile.xml'
importOrderFile('codestyle/EclipseOrganizeImports.importorder')
licenseHeader('/* \n SPDX-FileCopyrightText: (C)$YEAR SAP SE or an affiliate company and aas4j-transformation-library contributors. All rights reserved. \n\n SPDX-License-Identifier: Apache-2.0 \n */')
}
}
import java.text.SimpleDateFormat
distZip.enabled(false)
distTar.enabled(false)
task sourcesJar(type: Jar) {
from sourceSets.main.allJava
destinationDirectory.set(file("${buildDir}/libs"))
doFirst {
manifest {
attributes(
'Asset-Administration-Shell-Artifact-Name' : "${rootProject.name}",
'Asset-Administration-Shell-Artifact-Git-Version' : archiveVersion.get(),
'Asset-Administration-Shell-Artifact-Build-Date' : "${new SimpleDateFormat("dd-MM-yyyy HH:mm:ss").format(new Date())}"
)
}
manifest.writeTo("${buildDir}/tmp/jar/MANIFEST.MF")
}
archiveAppendix.set('composable')
archiveClassifier.set('sources')
archiveExtension.set('jar')
}
task buildJar (type: Jar) {
destinationDirectory.set(file("${buildDir}/libs"))
doFirst {
manifest {
attributes(
'Asset-Administration-Shell-Artifact-Name' : "${rootProject.name}",
'Asset-Administration-Shell-Artifact-Git-Version' : archiveVersion.get(),
'Asset-Administration-Shell-Artifact-Build-Date' : "${new SimpleDateFormat("dd-MM-yyyy HH:mm:ss").format(new Date())}"
)
}
manifest.writeTo("${buildDir}/tmp/jar/MANIFEST.MF")
}
exclude 'META-INF/*.RSA', 'META-INF/*.SF', 'META-INF/*.DSA', 'META-INF/NOTICE', 'META-INF/LICENSE', 'META-INF/DEPENDENCIES'
with jar
archiveExtension.set('jar')
}
task build(overwrite: true) {
dependsOn('buildJar', 'sourcesJar')
}
shadowJar {
destinationDirectory = file("${buildDir}/distributions")
exclude 'META-INF/*.RSA', 'META-INF/*.SF', 'META-INF/*.DSA', 'META-INF/NOTICE', 'META-INF/LICENSE', 'META-INF/LICENSE'
archiveBaseName.set("aas4j-transformation-library")
archiveAppendix.set("shadow")
archiveClassifier.set("shadedJar")
archiveExtension.set("jar")
}
repositories {
mavenCentral()
}
publishing {
repositories {
maven {
name = "GitHubPackages"
url = uri("https://maven.pkg.github.com/" + System.getenv("GITHUB_REPOSITORY"))
credentials {
username = System.getenv("GITHUB_ACTOR")
password = System.getenv("GITHUB_TOKEN")
}
}
}
publications {
gpr(MavenPublication) {
from components.java
}
}
}
dependencies {
def guava_version = "30.0-jre"
def commons_version = "1.4"
def junit_version = "5.7.0"
def mockito_version = "3.2.4"
def dom4j_version = "2.1.3"
def apache_poi_version = "4.1.2"
def jackson_version = "2.14.2"
def truth_version = "1.1"
def slf4j_version = "1.7.30"
def json_schema_validator_version = "1.0.45"
def jaxen_version = "1.1.6"
def aas_dataformat_json = "1.2.0"
def aas_model_version = "1.2.0"
implementation group: "com.google.guava", name: "guava", version: guava_version
implementation group: "commons-cli", name: "commons-cli", version: commons_version
implementation (group: "org.dom4j", name: "dom4j", version: dom4j_version) {
transitive = false
}
implementation group: "org.apache.poi", name: "poi", version: apache_poi_version
implementation group: "org.apache.poi", name: "poi-ooxml", version: apache_poi_version
implementation group: "com.fasterxml.jackson.core", name: "jackson-core", version: jackson_version
implementation group: "com.fasterxml.jackson.core", name: "jackson-databind", version: jackson_version
implementation group: "com.fasterxml.jackson.core", name: "jackson-annotations", version: jackson_version
implementation group: "org.slf4j", name: "slf4j-simple", version: slf4j_version
implementation group: "jaxen", name: "jaxen", version: jaxen_version
implementation group: 'io.admin-shell.aas', name: 'dataformat-json', version: aas_dataformat_json
implementation group: 'io.admin-shell.aas', name: 'model', version: aas_model_version
testImplementation group: "org.junit.jupiter", name: "junit-jupiter", version: junit_version
testImplementation group: "org.junit.jupiter", name: "junit-jupiter-api", version: junit_version
testImplementation group: "org.junit.jupiter", name: "junit-jupiter-engine", version: junit_version
testImplementation group: "org.mockito", name: "mockito-core", version: mockito_version
testImplementation group: "org.mockito", name: "mockito-junit-jupiter", version: mockito_version
testImplementation group: "com.google.truth", name: "truth", version: truth_version
testImplementation group: "com.google.truth.extensions", name: "truth-java8-extension", version: truth_version
testImplementation group: "com.networknt", name: "json-schema-validator", version: json_schema_validator_version
}