Guest User

Untitled

a guest
Jul 19th, 2022
41
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Groovy 3.50 KB | None | 0 0
  1. plugins {
  2.     id 'java'
  3.     id 'application'
  4.     // shadow plugin to produce fat JARs
  5.     id 'com.github.johnrengelman.shadow' version '7.1.2'
  6. }
  7.  
  8. repositories {
  9.     mavenCentral()
  10.     maven {
  11.         url "https://repository.apache.org/content/repositories/snapshots"
  12.         mavenContent {
  13.             snapshotsOnly()
  14.         }
  15.     }
  16. }
  17.  
  18. group = 'com.maker'
  19. version = System.getenv('VERSION')
  20. mainClassName = "${group}.Main"
  21. description = "Maker"
  22.  
  23. ext {
  24.     javaVersion = '15'
  25.     flinkVersion = '1.15.1'
  26. }
  27.  
  28. sourceCompatibility = javaVersion
  29. targetCompatibility = javaVersion
  30.  
  31. tasks.withType(JavaCompile) {
  32.     options.encoding = 'UTF-8'
  33. }
  34.  
  35. configurations {
  36.     flinkShadowJar // dependencies which go into the shadowJar
  37.  
  38.     // always exclude these (also from transitive dependencies) since they are provided by Flink
  39.     flinkShadowJar.exclude group: 'org.apache.flink', module: 'force-shading'
  40.     flinkShadowJar.exclude group: 'com.google.code.findbugs', module: 'jsr305'
  41.     flinkShadowJar.exclude group: 'org.slf4j'
  42.     flinkShadowJar.exclude group: 'org.apache.logging.log4j'
  43. }
  44.  
  45. dependencies {
  46.     // --------------------------------------------------------------
  47.     // `implementation`:
  48.     // Compile-time dependencies that should NOT be part of the
  49.     // shadow jar and are provided in the lib folder of Flink
  50.     // --------------------------------------------------------------
  51.     implementation "org.apache.flink:flink-java:${flinkVersion}"
  52.     implementation "org.apache.flink:flink-streaming-java:${flinkVersion}"
  53.     implementation "org.apache.flink:flink-table-api-java:${flinkVersion}"
  54.     implementation "org.apache.flink:flink-table-api-java-bridge:${flinkVersion}"
  55.     implementation "org.apache.flink:flink-clients:${flinkVersion}"
  56.  
  57.     implementation "org.apache.logging.log4j:log4j-slf4j-impl:2.17.1"
  58.     implementation "org.apache.logging.log4j:log4j-api:2.17.1"
  59.     implementation "org.apache.logging.log4j:log4j-core:2.17.1"
  60.  
  61.     testImplementation 'org.junit.jupiter:junit-jupiter:5.7.2'
  62.  
  63.     // --------------------------------------------------------------
  64.     // `flinkShadowJar`:
  65.     // Dependencies that should be part of the shadow jar, e.g.
  66.     // connectors. These must be in the flinkShadowJar configuration!
  67.     // --------------------------------------------------------------
  68.     flinkShadowJar 'com.google.guava:guava:31.1-jre'
  69.  
  70.     flinkShadowJar 'org.postgresql:postgresql:42.4.0'
  71.  
  72.     flinkShadowJar "org.apache.flink:flink-sql-connector-kafka:${flinkVersion}"
  73.     flinkShadowJar "org.apache.flink:flink-connector-kafka:${flinkVersion}"
  74.     flinkShadowJar "org.apache.flink:flink-connector-jdbc:${flinkVersion}"
  75. }
  76.  
  77. sourceSets {
  78.     main.compileClasspath += configurations.flinkShadowJar
  79.     main.runtimeClasspath += configurations.flinkShadowJar
  80.  
  81.     test.compileClasspath += configurations.flinkShadowJar
  82.     test.runtimeClasspath += configurations.flinkShadowJar
  83.  
  84.     javadoc.classpath += configurations.flinkShadowJar
  85. }
  86.  
  87. run.classpath = sourceSets.main.runtimeClasspath
  88.  
  89. application {
  90.     mainClass = "${mainClassName}"
  91. }
  92.  
  93. applicationDefaultJvmArgs = ["-Dlog4j.configurationFile=log4j2.properties"]
  94.  
  95. tasks.named('test') {
  96.     useJUnitPlatform()
  97. }
  98.  
  99. jar {
  100.     manifest {
  101.         attributes "Main-Class": "${mainClassName}",
  102.             "Built-By": System.getProperty("user.name"),
  103.             "Build-Jdk": System.getProperty("java.version")
  104.     }
  105. }
  106.  
  107. shadowJar {
  108.     configurations = [project.configurations.flinkShadowJar]
  109. }
  110.  
Advertisement
Add Comment
Please, Sign In to add comment