-
Notifications
You must be signed in to change notification settings - Fork 2
/
build.gradle
252 lines (214 loc) · 10.2 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
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath "org.sonatype.gradle.plugins:scan-gradle-plugin:2.2.0"
}
}
plugins {
id 'java'
id 'application'
// shadow plugin to produce fat JARs
id 'com.github.johnrengelman.shadow' version '5.2.0'
id 'maven-publish'
id 'jacoco'
id "org.sonarqube" version "3.3"
}
allprojects {
group = 'org.alvearie.hri.flink'
version = '3.2-1.1.1'
description = """Flink Passthrough Validation Job"""
applicationDefaultJvmArgs = ["-Dlog4j.configuration=log4j.properties"]
mainClassName = 'org.alvearie.hri.flink.PassthroughStreamingJob'
apply plugin: "org.sonatype.gradle.plugins.scan"
ext {
pipelineCoreVersion = '3.2-1.1.1'
javaVersion = '1.8'
flinkVersion = '1.14.3'
scalaBinaryVersion = '2.12'
scalaVersion = '2.12.11'
scalaTestVersion = '3.1.1'
slf4jVersion = '1.7.35'
log4jVersion = '2.17.1'
jacksonVersion = '2.12.0'
}
sourceCompatibility = javaVersion
targetCompatibility = javaVersion
tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
}
repositories {
maven {
credentials {
username = findProperty('GITHUB_ACTOR') ?: System.getenv('GITHUB_ACTOR')
password = findProperty('GITHUB_TOKEN') ?: System.getenv('GITHUB_TOKEN')
}
url "https://maven.pkg.github.com/Alvearie/hri-flink-pipeline-core"
}
mavenCentral()
mavenLocal()
}
ext {
branch = System.getenv('BRANCH_NAME') != null
? System.getenv('BRANCH_NAME')
: getWorkingBranch()
ossPassword = findProperty("SONATYPE_OSS_PASSWORD") ?: System.getenv("SONATYPE_OSS_PASSWORD")
}
// If not running in Actions add 'local' to the version to support local development
if (System.getenv('BRANCH_NAME') == null || System.getenv('BRANCH_NAME') == "") {
version = "${branch}-local-SNAPSHOT"
} else if (System.getenv('ACTIONS_TAG') == null || System.getenv('ACTIONS_TAG') == "") {
version = "${branch}-SNAPSHOT"
} else if (System.getenv('ACTIONS_TAG') == "v${version}") {
version = "${version}"
} else {
throw new InvalidUserDataException(String.format("The tag '%s' does not match with the current release version '%s'",System.getenv('ACTIONS_TAG'),"${version}"));
}
ossIndexAudit {
username = '[email protected]'
password = "${ossPassword}"
allConfigurations = true // if true includes the dependencies in all resolvable configurations. By default is false, meaning only 'compileClasspath', 'runtimeClasspath', 'releaseCompileClasspath' and 'releaseRuntimeClasspath' are considered
useCache = true // true by default
cacheExpiration = 'PT86400S' // note: time in seconds (24hrs); 12 hours if omitted. It must follow the Joda Time specification at https://www.javadoc.io/doc/joda-time/joda-time/2.10.4/org/joda/time/Duration.html#parse-java.lang.String-
colorEnabled = true // if true prints vulnerability description in color. By default is true.
printBanner = true // if true will print ASCII text banner. By default is true.
// Vulnerabilities that can safely be ignored
excludeVulnerabilityIds = [
// pkg:maven/org.apache.zookeeper/[email protected] (from flink-test-utils)
'1775f19b-5e9c-48f8-8c8f-ef245350531b', '43b8cbe5-324d-416b-b613-3dcaba1b5a6c', 'bec057e0-9945-49c4-92c9-4be669bb5331', '1e65ed27-7a06-4464-a115-c8421c879281',
// pkg:maven/io.netty/[email protected] (from flink-test-utils)
'20be5124-16a3-4d77-8668-d83f04a67808', '20167979-f872-4765-85ef-9b7be870cecb', 'f2a31abe-1af6-4f6f-aeeb-60e0e0d3e981', '6ff63cbd-c4ae-4268-be95-43322746b6be',
'8b7d8928-61ee-4708-bf37-feece927a872', 'cbde3175-9c07-491c-836d-2a146b61e3b6', '846fbf13-a0b9-4cab-b820-8415a30326bd', 'b3c3a56f-37c0-4706-bf54-2f61c5c9786f',
'a3df5795-2bdb-4ec6-b9c2-babe9ec470e5', '20b79835-7a43-4bea-a985-5e12df1d0b0a', 'b6a1cffe-6f90-4b44-ad18-df9dc7dc6fc4',
// pkg:maven/io.netty/[email protected] (from Snappy and Bzip2 compression components. Can’t force Flink to upgrade, and not used in Flink.)
'14ed6543-1974-4241-b353-3afd846eadc9', '99b9cf63-0f91-43fb-b227-e53917370ed9',
// pkg:maven/com.google.guava/[email protected] (from flink-test-utils)
'24585a7f-eb6b-4d8d-a2a9-a6f16cc7c1d0', '8e973be2-4220-410d-a4cb-2de7a755bdbe',
// pkg:maven/junit/[email protected] (from flink-test-utils)
'7ea56ad4-8a8b-4e51-8ed9-5aad83d8efb1',
//pkg:maven/org.apache.logging.log4j/[email protected] (from org.scala-sbt:zinc_2.12:1.3.5 - Used by gradle scala plugin only)
'd3477f9c-032a-44a7-a5e1-02ae35e4737c',
//pkg:maven/log4j/[email protected] (from com.vladsch.flexmark:flexmark-all:0.35.10 - Used in Unit Test runs only)
'e6e4ebea-da12-4bde-8f24-6272925ad093',
//pkg:maven/log4j/[email protected] (from flink-test-utils)
'4a7955ac-037c-42bc-a83e-b51efe2490af'
]
// excludeCoordinates = ['commons-fileupload:commons-fileupload:1.3'] // list containing coordinate of components which if vulnerable should be ignored
}
}
// NOTE: We cannot use "compileOnly" or "shadow" configurations since then we could not run code
// in the IDE or with "gradle run". We also cannot exclude transitive dependencies from the
// shadowJar yet (see https://github.com/johnrengelman/shadow/issues/159).
// -> Explicitly define the // libraries we want to be included in the "flinkShadowJar" configuration!
configurations {
flinkShadowJar // dependencies which go into the shadowJar
// always exclude these (also from transitive dependencies) since they are provided by Flink
flinkShadowJar.exclude group: 'org.apache.flink', module: 'force-shading'
flinkShadowJar.exclude group: 'org.scala-lang', module: 'scala-compiler'
flinkShadowJar.exclude group: 'com.google.code.findbugs', module: 'jsr305'
flinkShadowJar.exclude group: 'org.slf4j'
flinkShadowJar.exclude group: 'log4j'
}
sonarqube {
properties {
property "sonar.projectKey", "Alvearie_hri-flink-validation-passthrough"
property "sonar.organization", "alvearie"
property "sonar.host.url", "https://sonarcloud.io"
property "sonar.exclusions", "./test/**"
property "sonar.coverage.jacoco.xmlReportPaths", "${project.buildDir}/reports/jacoco/test/jacocoTestReport.xml"
property "sonar.sourceEncoding", "UTF-8"
}
}
// declare the dependencies for your production and test code
dependencies {
implementation "org.apache.flink:flink-scala_${scalaBinaryVersion}:${flinkVersion}"
implementation "org.apache.flink:flink-streaming-scala_${scalaBinaryVersion}:${flinkVersion}"
implementation("org.scala-lang:scala-compiler") {
version {
require("${scalaVersion}")
}
}
testImplementation "org.apache.flink:flink-tests:${flinkVersion}:tests"
testImplementation "org.apache.flink:flink-test-utils_${scalaBinaryVersion}:${flinkVersion}"
implementation "org.apache.logging.log4j:log4j-core:${log4jVersion}"
implementation "org.slf4j:slf4j-log4j12:${slf4jVersion}"
// --------------------------------------------------------------
// Dependencies that should be part of the shadow jar, e.g.
// connectors. These must be in the flinkShadowJar configuration!
// --------------------------------------------------------------
flinkShadowJar "org.alvearie.hri.flink:hri-flink-pipeline-core:${pipelineCoreVersion}"
flinkShadowJar "info.picocli:picocli:4.2.0"
// Add test dependencies here.
flinkShadowJar "org.alvearie.hri.flink:hri-flink-pipeline-core:${pipelineCoreVersion}:tests"
testImplementation "junit:junit:4.12"
testImplementation "com.github.stefanbirkner:system-rules:1.19.0"
}
// make compileOnly dependencies available for tests:
sourceSets {
main.compileClasspath += configurations.flinkShadowJar
main.runtimeClasspath += configurations.flinkShadowJar
test.compileClasspath += configurations.flinkShadowJar
test.runtimeClasspath += configurations.flinkShadowJar
javadoc.classpath += configurations.flinkShadowJar
}
run.classpath = sourceSets.main.runtimeClasspath
jar {
manifest {
attributes 'Built-By': System.getProperty('user.name'),
'Build-Jdk': System.getProperty('java.version')
baseName = 'hri-flink-validation-passthrough'
}
}
shadowJar {
configurations = [project.configurations.flinkShadowJar]
baseName = 'hri-flink-validation-passthrough'
archiveClassifier.set('')
}
publishing {
publications {
shadow(MavenPublication) { publication ->
project.shadow.component(publication)
artifactId = 'hri-flink-validation-passthrough'
}
}
repositories {
maven {
url 'https://maven.pkg.github.com/Alvearie/hri-flink-validation-passthrough'
credentials {
username findProperty('GITHUB_ACTOR') ?: System.getenv('GITHUB_ACTOR')
password findProperty('GITHUB_TOKEN') ?: System.getenv('GITHUB_TOKEN')
}
}
}
}
// this is for App Scan
task copyDependencies(type: Copy) {
from configurations.flinkShadowJar
into 'dependencies'
}
test {
finalizedBy jacocoTestReport // report is always generated after tests run
}
jacocoTestReport {
dependsOn test // tests are required to run before generating the report
reports {
xml.enabled = true
}
}
jacocoTestReport.doLast {
println "Jacoco report:\n file:///$buildDir/reports/jacoco/test/html/index.html"
}
/**
* Get the name of the working branch of the project
*
* @return Name of the working branch
*/
def getWorkingBranch() {
// Triple double-quotes for the breaklines
def workingBranch = """git --git-dir=${rootDir}/.git
--work-tree=${rootDir}
rev-parse --abbrev-ref HEAD""".execute().text.trim()
println "Working branch: " + workingBranch
return workingBranch
}