-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.gradle
188 lines (147 loc) · 6.38 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
plugins {
// https://docs.gradle.org/current/userguide/idea_plugin.html
id 'idea'
// https://docs.gradle.org/current/userguide/application_plugin.html
id 'application'
// https://plugins.gradle.org/plugin/com.adarshr.test-logger
id 'com.adarshr.test-logger' version '3.0.0'
// https://imperceptiblethoughts.com/shadow/introduction/
id 'com.github.johnrengelman.shadow' version '7.1.2'
// http://xvik.github.io/gradle-quality-plugin/4.3.0/getting-started/
id 'ru.vyarus.quality' version '4.7.0' // no config out of the box
}
// artifact properties
group = 'org.myorg.quickstart'
version = '1.0'
mainClassName = 'org.myorg.quickstart.StreamingJob'
description = """Flink Quickstart Job"""
application {
applicationDefaultJvmArgs = ["-Dlog4j.configurationFile=conf/flink/log4j-local.properties"]
}
run {
environment "FLINK_ENV", "local"
}
ext {
javaVersion = '1.11'
junitVersion = '5.8.2'
assertjVersion = '3.20.2'
flinkVersion = '1.14.2'
scalaVersion = '2.11'
slf4jVersion = '1.7.32'
log4jVersion = '2.17.0'
}
task kafkaUp(type: Exec) {
commandLine "docker-compose", "-p", "kafka", "-f", "docker/kafka-cluster.yml", "up"
}
task kafkaDown(type: Exec) {
commandLine "docker-compose", "-p", "kafka", "-f", "docker/kafka-cluster.yml", "down"
}
task stopJob(type: Exec) {
commandLine "docker-compose", "-p", "flink", "-f", "docker/flink-job-cluster.yml", "down"
}
task startJob(type: Exec, dependsOn: 'stopJob') {
commandLine "docker-compose", "-p", "flink", "-f", "docker/flink-job-cluster.yml", "up", "-d"
}
task createTopics(type: Exec) {
commandLine "./scripts/create-topics.sh", "source", "destination"
}
task grafanaDown(type: Exec) {
commandLine "docker-compose", "-p", "grafana", "-f", "docker/grafana-elastic-logstash.yml", "down"
}
task grafanaUp(type: Exec) {
commandLine "docker-compose", "-p", "grafana", "-f", "docker/grafana-elastic-logstash.yml", "up"
}
sourceCompatibility = javaVersion
targetCompatibility = javaVersion
tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
}
wrapper {
gradleVersion = '7.3.3'
}
// declare where to find the dependencies of your project
repositories {
mavenCentral()
gradlePluginPortal()
}
// 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: 'com.google.code.findbugs', module: 'jsr305'
flinkShadowJar.exclude group: 'org.slf4j'
flinkShadowJar.exclude group: 'org.apache.logging.log4j'
// https://logging.apache.org/log4j/2.x/faq.html#exclusions
// Good Explanation: https://stackoverflow.com/questions/42348755/class-path-contains-multiple-slf4j-bindings-error
all*.exclude group: 'log4j', module: 'log4j'
all*.exclude group: 'org.slf4j', module: 'slf4j-log4j12'
}
test {
useJUnitPlatform()
}
// For details see https://github.com/radarsh/gradle-test-logger-plugin
testlogger {
theme 'mocha'
slowThreshold 5000
showStandardStreams true
showFullStackTraces false
logLevel 'QUIET'
}
// declare the dependencies for your production and test code
dependencies {
// --------------------------------------------------------------
// Dependencies that should be part of the shadow jar, e.g.
// connectors. These must be in the flinkShadowJar configuration!
// --------------------------------------------------------------
// Core
implementation "org.apache.flink:flink-streaming-java_${scalaVersion}:${flinkVersion}"
implementation "org.apache.flink:flink-runtime-web_${scalaVersion}:${flinkVersion}"
// Connectors & Formats
implementation group: 'org.apache.flink', name: "flink-connector-kafka_${scalaVersion}", version: "${flinkVersion}"
// Logging
implementation "org.apache.logging.log4j:log4j-api:${log4jVersion}"
implementation "org.apache.logging.log4j:log4j-core:${log4jVersion}"
implementation "org.apache.logging.log4j:log4j-slf4j-impl:${log4jVersion}"
implementation "org.slf4j:slf4j-log4j12:${slf4jVersion}"
// Supplementary Libraries
implementation group: 'com.typesafe', name: 'config', version: '1.4.0'
// -----------------------------------------------------------------
// Dependencies that should be part of the shadow jar, e.g connectors.
// -----------------------------------------------------------------
flinkShadowJar "org.apache.flink:flink-connector-kafka_${scalaVersion}:${flinkVersion}"
// Supplementary Libraries
flinkShadowJar group: 'com.typesafe', name: 'config', version: '1.4.0'
// -----------------------------------------------------------------
// Add test dependencies here.
// -----------------------------------------------------------------
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:${junitVersion}"
testImplementation "org.junit.jupiter:junit-jupiter-api:${junitVersion}"
testImplementation group: 'org.assertj', name:'assertj-core', version: "${assertjVersion}"
testImplementation "org.apache.flink:flink-test-utils_${scalaVersion}:${flinkVersion}"
testImplementation "org.apache.flink:flink-runtime:${flinkVersion}:tests"
testImplementation "org.apache.flink:flink-streaming-java_${scalaVersion}:${flinkVersion}:tests"
}
// 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')
}
}
shadowJar {
baseName 'flink-stream-job'
zip64 true
configurations = [project.configurations.flinkShadowJar]
}