-
Notifications
You must be signed in to change notification settings - Fork 12
/
build.gradle
456 lines (391 loc) · 13.5 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
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
buildscript {
repositories {
maven {
url "https://plugins.gradle.org/m2/"
}
mavenCentral()
}
dependencies {
classpath 'org.jfrog.buildinfo:build-info-extractor-gradle:5.2.3'
classpath 'org.owasp:dependency-check-gradle:10.0.2'
}
}
apply plugin: 'org.owasp.dependencycheck'
ext {
undef = 'undef'
sharedDir = file('shared')
coreXsdDir = file('clearth-core/xsd')
jetty_9_4 = 'jetty9.4'
jetty_12 = 'jetty12'
jetty_9_4_version = '9.4.55.v20240627'
jetty_12_version = '12.0.12'
if (!project.hasProperty('cth_version')) {
cth_version = '1.0.0-SNAPSHOT'
}
if (!project.hasProperty('git_commit')) {
git_commit = ''
}
if (!project.hasProperty('newProjectDir')) {
newProjectDir = undef
}
oldProjectName = 'newproject'
if (!project.hasProperty('newProjectName')) {
newProjectName = undef
}
if (!project.hasProperty('checkApiKey')) {
checkApiKey = ''
}
if (!project.hasProperty('knownExploitedVulnerabilitiesUrl')) {
knownExploitedVulnerabilitiesUrl = null
}
if (!project.hasProperty('server'))
server = jetty_9_4
if (server == jetty_9_4) {
def version = jetty_9_4_version
jettyName = "jetty-distribution-${version}"
jettyUrl = "https://repo1.maven.org/maven2/org/eclipse/jetty/jetty-distribution/${version}/${jettyName}.zip"
}
else if (server == jetty_12) {
def version = jetty_12_version
jettyName = "jetty-home-${version}"
jettyUrl = "https://repo1.maven.org/maven2/org/eclipse/jetty/jetty-home/${version}/${jettyName}.zip"
}
else
throw new GradleException("'server' must be '${jetty_9_4}' or '${jetty_12}'")
jettyHome = 'jetty/jetty-home'
}
subprojects {
repositories {
// mavenLocal()
maven {
name 'MavenLocal' // for local builds only
url sharedDir
}
mavenCentral()
}
apply plugin: 'java'
apply plugin: 'java-library'
apply plugin: 'com.jfrog.artifactory'
apply plugin: 'maven-publish'
defaultTasks 'build'
compileJava.options.debugOptions.debugLevel = 'source,lines,vars' // Include debug information
ext {
xsdDir = file('xsd')
genDir = file("${buildDir}/generated-src")
genJavaDir = file("${genDir}/java")
genJaxbDir = file("${genDir}/jaxb")
if (!project.hasProperty('versionMark')) {
versionMark = ''
}
}
version = cth_version
group = 'com.exactprosystems.clearth'
sourceSets {
main {
java {
srcDir genJavaDir
}
}
}
configurations {
all {
transitive = true
resolutionStrategy {
failOnVersionConflict()
def kotlinVersion = '1.8.22'
def jacksonVersion = '2.18.1'
def nettyVersion = '4.1.115.Final'
def bouncycastleVersion = '1.78.1'
def protobufVersion = '3.25.5'
//common dependenices are written explicilty to force modules use correct and expected versions
force 'commons-codec:commons-codec:1.16.0',
'commons-beanutils:commons-beanutils:1.9.4',
'commons-io:commons-io:2.17.0',
'javax.xml.bind:jaxb-api:2.3.0',
'commons-codec:commons-compress:1.21',
'junit:junit:4.13.1',
'org.hamcrest:hamcrest-core:1.3',
'org.slf4j:slf4j-api:1.7.36',
'org.apache.commons:commons-lang3:3.17.0',
'org.apache.commons:commons-compress:1.26.0',
'org.apache.commons:commons-text:1.12.0',
'commons-logging:commons-logging:1.2',
'org.apache.logging.log4j:log4j-core:2.21.1',
'org.apache.logging.log4j:log4j-api:2.21.1',
'org.apache.logging.log4j:log4j-jcl:2.21.1',
'org.apache.logging.log4j:log4j-slf4j-impl:2.21.1',
"com.fasterxml.jackson.core:jackson-databind:${jacksonVersion}",
"com.fasterxml.jackson:jackson-bom:${jacksonVersion}",
"com.fasterxml.jackson.core:jackson-annotations:${jacksonVersion}",
"com.fasterxml.jackson.core:jackson-core:${jacksonVersion}",
"com.fasterxml.jackson.datatype:jackson-datatype-jsr310:${jacksonVersion}",
'org.apache.mina:mina-core:2.1.5',
"org.bouncycastle:bcprov-jdk18on:${bouncycastleVersion}",
"org.bouncycastle:bcpkix-jdk18on:${bouncycastleVersion}",
"org.bouncycastle:bcutil-jdk18on:${bouncycastleVersion}",
"org.jetbrains.kotlin:kotlin-stdlib:${kotlinVersion}",
"org.jetbrains.kotlin:kotlin-stdlib-jdk8:${kotlinVersion}",
"org.jetbrains.kotlin:kotlin-stdlib-common:${kotlinVersion}",
"org.jetbrains.kotlin:kotlin-reflect:${kotlinVersion}",
'org.jetbrains:annotations:24.1.0',
'com.google.guava:guava:33.3.1-jre',
'com.google.errorprone:error_prone_annotations:2.28.0',
'com.squareup.okio:okio:3.8.0',
'com.squareup.okhttp3:okhttp:4.12.0',
'com.squareup.okhttp3:logging-interceptor:4.12.0',
'com.exactpro.th2:grpc-common:4.5.0',
'com.google.code.gson:gson:2.11.0',
'org.checkerframework:checker-qual:3.43.0',
"com.google.protobuf:protobuf-java-util:${protobufVersion}",
"com.google.protobuf:protobuf-java:${protobufVersion}",
"io.netty:netty-all:${nettyVersion}",
"io.netty:netty-handler:${nettyVersion}",
"io.netty:netty-codec-http2:${nettyVersion}",
"io.netty:netty-handler-proxy:${nettyVersion}",
"io.netty:netty-transport-native-unix-common:${nettyVersion}",
"io.netty:netty-codec-http:${nettyVersion}",
"io.netty:netty-common:${nettyVersion}",
"io.netty:netty-resolver:${nettyVersion}",
"io.netty:netty-buffer:${nettyVersion}",
"io.netty:netty-transport:${nettyVersion}",
"io.netty:netty-codec:${nettyVersion}",
"io.netty:netty-codec-socks:${nettyVersion}"
cacheChangingModulesFor 0, 'seconds'
}
exclude module: 'guava-jdk5'
exclude group: 'log4j', module: 'log4j'
exclude group: 'org.slf4j', module: 'slf4j-log4j12'
}
jaxb
}
test {
ignoreFailures = Boolean.getBoolean("test.ignoreFailures")
}
task testNg(type: Test) {
ignoreFailures = Boolean.getBoolean("test.ignoreFailures")
useTestNG()
}
check {
dependsOn.add("testNg")
}
dependencies {
jaxb 'com.sun.xml.bind:jaxb-xjc:2.3.9'
jaxb 'com.sun.xml.bind:jaxb-impl:2.3.9'
jaxb 'javax.xml.bind:jaxb-api:2.3.0'
jaxb 'javax.xml:jsr173:1.0'
testImplementation 'junit:junit:4.13.1'
testImplementation 'org.mockito:mockito-all:2.0.2-beta'
testImplementation 'org.testng:testng:6.14.3'
testImplementation 'org.xerial:sqlite-jdbc:3.45.3.0'
testImplementation group: 'com.h2database', name: 'h2', version: '1.4.200'
testImplementation 'org.assertj:assertj-core:3.15.0'
if(JavaVersion.current() > JavaVersion.VERSION_1_8)
implementation 'javax.annotation:javax.annotation-api:1.3.2'
if (project.getParent().getName() == 'clearth-modules')
implementation project(':clearth-core')
}
task createDir {
doLast {
genJavaDir.mkdirs()
genJaxbDir.mkdirs()
}
}
task generateJavaFromXsd(dependsOn: 'createDir', group: 'generation')
compileJava {
dependsOn.add('generateJavaFromXsd')
}
jar {
manifest {
attributes('Created-By': System.getProperty('java.version') + ' (' + System.getProperty('java.vendor') + ')')
attributes('Specification-Title': '')
attributes('Specification-Vendor': 'Exactpro Systems LLC')
attributes('Implementation-Title': "${project.name}")
attributes('Implementation-Vendor': 'Exactpro Systems LLC')
attributes('Implementation-Vendor-Id': 'com.exactprosystems')
attributes('Implementation-Version': "${archiveVersion.get()}")
if (versionMark != '')
attributes('Implementation-Version-Mark': "${versionMark}")
attributes('Implementation-Version-Date': getDate())
if (git_commit != '')
attributes('Git-Commit': "${git_commit}")
}
}
publishing {
repositories {
maven {
name 'sharedDir'
url sharedDir
}
}
}
}
static def getDate() {
def date = new Date()
def formattedDate = date.format('ddMMyyyy-HH:mm:ss.SSS')
return formattedDate
}
task createCommitMessage {
doLast {
def sinceCommit = project.getProperty("since")
def untilCommit = project.getProperty("until")
def interval = sinceCommit.toString() + '...' + untilCommit.toString()
def gitHistory = new ByteArrayOutputStream()
exec {
commandLine 'git', 'log', interval, '--grep=^Bug', '--grep=^Feature', '--pretty=format:"%s"'
standardOutput = gitHistory
}
def message = "Applied new Core and modules (" +
untilCommit.toString() +
") with the following improvements:\n\n" +
gitHistory.toString().replace('"', '')
def commitCommentFile = new File("./core_update")
try {
commitCommentFile.write(message.toString())
println("Core update info has been written to 'core_update' file")
}
catch (IOException e) {
println("Error occured while writing core update info:")
println(e.toString())
}
}
}
project(':clearth-modules') {
artifactoryPublish.skip = true
}
task assembleAll(group: 'build', description: 'Assembles all ClearTH components, i.e. Core and all of its modules', dependsOn: subprojects*.assemble)
task buildAll(group: 'build', description: 'Builds and tests all ClearTH components, i.e. Core and all of its modules', dependsOn: subprojects*.build)
task publishAll(group: 'publishing', description: 'Publishes all ClearTH components, i.e. Core and all of its modules', dependsOn: subprojects*.publish)
task downloadJetty() {
def f = new File("${projectDir}/jetty/")
def jettyZip = new File(f, "${jettyName}.zip")
outputs.upToDateWhen { jettyZip.exists() }
doLast {
copy {
def url = new URL(jettyUrl)
f.mkdirs()
println('Downloading Jetty: ' + url)
url.withInputStream { i -> jettyZip.withOutputStream { it << i } }
println('Unpacking Jetty')
from zipTree(jettyZip)
into f
}
}
}
task zipTestReports(type: Zip, group: 'other', description: 'Creates archive with test reports'){
archiveBaseName = "TestReports"
archiveAppendix = new Date().format('ddMMyyyy-HH-mm-ss-SSS')
def reportsDir = "$projectDir/testOutput/SchedulerTestData/automation/reports"
destinationDirectory = file("$projectDir/testOutput/SchedulerTestData")
from reportsDir
doLast{
delete reportsDir
}
}
task createProject(group: 'ClearTH',
description: 'Creates directory with new ClearTH-based project',
dependsOn: 'prepareJettyInNewProject') {
doLast {
def work = new File(newProjectDir, 'jetty/work')
work.mkdirs()
}
}
task prepareJettyInNewProject(type: JavaExec,
group: 'ClearTH',
description: 'Prepares Jetty to work in directory with new ClearTH-based project',
dependsOn: 'copyNewProjectFiles') {
workingDir = file("${newProjectDir}/jetty")
classpath = files("${newProjectDir}/${jettyHome}/start.jar")
mainClass = 'org.eclipse.jetty.start.Main'
if (server == jetty_9_4)
args '--add-to-start=server,http,deploy,apache-jsp,websocket'
else if (server == jetty_12)
args '--add-modules=server,http,ee8-deploy,ee8-apache-jsp,ee8-websocket-javax'
}
task copyNewProjectFiles(type: Copy,
group: 'ClearTH',
description: 'Copies files to directory of new ClearTH-based project',
dependsOn: 'downloadJetty') {
doFirst {
if (newProjectDir == undef) {
throw new GradleException('You must set "newProjectDir" property via "-PnewProjectDir=<path_to_new_project>" key')
}
if (newProjectName == undef) {
throw new GradleException('You must set "newProjectName" property via "-PnewProjectName=<project_name>" key')
}
if (!newProjectName.find('^[_*\\w*\\d*]+$')) {
throw new GradleException("Project name contains illegal characters")
}
}
newProjectName = newProjectName.toLowerCase()
outputs.upToDateWhen { false }
from("${projectDir}/for_new_project/src/main/java/com/exactprosystems/clearth/${oldProjectName}") {
into "src/main/java/com/exactprosystems/clearth/${newProjectName}"
filter {
line -> line.replaceAll(oldProjectName, newProjectName)
}
}
from("${projectDir}/for_new_project/src/main/webapp/") {
into "src/main/webapp"
filter {
line -> line.replaceAll("com.exactprosystems.clearth.${oldProjectName}", "com.exactprosystems.clearth.${newProjectName}")
}
}
from ("${projectDir}/for_new_project") {
include "build.gradle"
include "gradle.properties"
filter( org.apache.tools.ant.filters.ReplaceTokens, tokens: ["JETTY_9_4_VERSION": jetty_9_4_version.toString(),
"JETTY_12_VERSION": jetty_12_version.toString(),
"CORE_SHARED_DIR": sharedDir.toString().replace('\\', '/'),
"CORE_VERSION": cth_version] )
}
from (new File("${projectDir}/cfg/")) {
into "cfg/"
}
from (new File("${projectDir}/clearth-modules/clearth-gui/src/main/webapp/")) {
exclude 'WEB-INF/faces-config.xml'
into "src/main/webapp/"
}
from (new File(projectDir, "jetty/${jettyName}")) {
exclude 'demo-base'
into jettyHome
}
def jettyXmlName;
if (server == jetty_9_4)
jettyXmlName = 'jetty94.xml'
else if (server == jetty_12)
jettyXmlName = 'jetty12.xml'
from (new File(newProjectDir, "${jettyHome}/etc/")) {
include 'jetty.xml'
rename('jetty.xml', jettyXmlName)
}
from (new File("${projectDir}")) {
include 'gradle/'
include 'gradlew.bat'
include 'gradlew'
}
from (new File("${projectDir}/docker")) {
include 'Dockerfile'
include 'clearth.cfg'
include 'start.ini'
include 'log.properties'
into "docker"
}
into newProjectDir
}
dependencyCheck {
skipConfigurations = ['grettyProductRuntime', 'grettyRunnerJetty93', 'grettyRunnerJetty94', 'grettyRunnerJetty8', 'grettyStarter',
'grettyRunnerJetty9', 'grettyRunnerTomcat85', 'grettyRunnerTomcat7', 'grettyRunnerTomcat8', 'grettyRunnerJetty7', 'grettyRunnerTomcat9',
'grettyNoSpringBoot', 'gretty']
format = 'ALL'
failBuildOnCVSS = 7.6
suppressionFile = "${projectDir}/dependency-check/suppressions.xml"
nvd {
apiKey = checkApiKey
}
analyzers {
knownExploitedURL = knownExploitedVulnerabilitiesUrl
}
}
wrapper {
gradleVersion = '8.8'
}