Skip to content

Commit

Permalink
Streaming Movie Ratings: Updated dependencies and refactoring (conflu…
Browse files Browse the repository at this point in the history
…entinc#117)

* Fixing raw rating generator groovy script

* Masive (ish) refactoring

- updated Gradle wrapper (6.3)
- fixed Gradle warnings
- updated libs (kafka, streams, spring)
- fixed a bunch of stupid errors/warnings
  • Loading branch information
gAmUssA authored Apr 22, 2020
1 parent 448b807 commit fba1bf9
Show file tree
Hide file tree
Showing 49 changed files with 371 additions and 300 deletions.
129 changes: 45 additions & 84 deletions streams-movie-demo/build.gradle
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
buildscript {
ext {
springBootVersion = '2.2.1.RELEASE'
springBootVersion = '2.2.6.RELEASE'
shadowPluginVersion = '5.0.0'
kotlinVersion = '1.3.21'
kotlinVersion = '1.3.72'
jibPluginVersion = '1.3.0'
confluentVersion = '5.2.1'
kafkaVersion = '2.2.0'
confluentVersion = '5.3.1'
kafkaVersion = '2.3.1'
lombokVersion = '1.18.8'
}
repositories {
Expand All @@ -16,7 +16,7 @@ buildscript {
}

dependencies {
classpath "com.commercehub.gradle.plugin:gradle-avro-plugin:0.14.2"
classpath "com.commercehub.gradle.plugin:gradle-avro-plugin:0.9.1"
classpath "org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}"
classpath "com.github.jengelman.gradle.plugins:shadow:${shadowPluginVersion}"
classpath "gradle.plugin.com.google.cloud.tools:jib-gradle-plugin:${jibPluginVersion}"
Expand All @@ -35,11 +35,16 @@ subprojects {

repositories {
jcenter()
maven { url 'http://packages.confluent.io/maven/' }
maven { url 'https://packages.confluent.io/maven/' }
maven { url "https://kotlin.bintray.com/kotlinx" }
maven { url "https://repo.spring.io/milestone" }
maven { url 'https://jitpack.io' }
}

task copyRuntimeLibs(type: Copy) {
into "build/libs-runtime"
from configurations.runtimeClasspath
}
}

configure(subprojects.findAll { (it.name == "streams") }) {
Expand All @@ -48,18 +53,19 @@ configure(subprojects.findAll { (it.name == "streams") }) {

project(':core') {
apply plugin: "com.commercehub.gradle.plugin.avro"
apply plugin: 'java-library'

avro {
// stringType = "CharSequence"
}

dependencies {
compile 'org.apache.avro:avro:1.8.2'
compile "org.apache.kafka:kafka-clients:${kafkaVersion}"
compile 'javax.json:javax.json-api:1.1.4'
runtime 'org.glassfish:javax.json:1.1.4'
compile "io.confluent:kafka-streams-avro-serde:${confluentVersion}"
compile("com.github.gAmUssA:streaming-utils:-SNAPSHOT") {
api 'org.apache.avro:avro:1.9.2'
api "org.apache.kafka:kafka-clients:${kafkaVersion}"
api 'javax.json:javax.json-api:1.1.4'
runtimeOnly 'org.glassfish:javax.json:1.1.4'
api "io.confluent:kafka-streams-avro-serde:${confluentVersion}"
api ("com.github.gAmUssA:streaming-utils:-SNAPSHOT") {
exclude group: 'org.slf4j', module: 'slf4j-log4j12'
}
}
Expand All @@ -69,10 +75,10 @@ project(':core') {
project(':loader') {
apply plugin: 'groovy'
dependencies {
compile project(':core')
compile 'org.codehaus.groovy:groovy-all:2.4.15'
compile 'mysql:mysql-connector-java:5.1.48'
compile "org.slf4j:slf4j-log4j12:1.7.25"
implementation project(':core')
implementation 'org.codehaus.groovy:groovy-all:2.4.15'
implementation 'mysql:mysql-connector-java:5.1.48'
implementation "org.slf4j:slf4j-log4j12:1.7.25"
}

def env = System.getenv()
Expand Down Expand Up @@ -103,7 +109,7 @@ project(':loader') {
}

from {
configurations.compile.collect { it.isDirectory() ? it : zipTree(it) }
configurations.compileClasspath.collect { it.isDirectory() ? it : zipTree(it) }
}
}

Expand All @@ -114,10 +120,10 @@ project(':spring-web-loader') {
apply plugin: 'io.spring.dependency-management'

dependencies {
compile project(':streams')
implementation project(':streams')

compile "org.springframework.boot:spring-boot-starter-web"
compile 'org.springframework.kafka:spring-kafka'
implementation "org.springframework.boot:spring-boot-starter-web"
implementation 'org.springframework.kafka:spring-kafka'
}

configurations.all {
Expand All @@ -126,20 +132,19 @@ project(':spring-web-loader') {
}

project(':streams') {
apply plugin: 'java-library'
mainClassName = "io.confluent.demo.StreamsDemo"

dependencies {
compile project(':core')

compile "org.slf4j:slf4j-log4j12:1.7.25"
compile "org.apache.kafka:kafka-streams:${kafkaVersion}"
compile "io.confluent:monitoring-interceptors:${confluentVersion}"

// compile 'io.confluent:kafka-avro-serializer:3.3.0'
// compile 'io.confluent:kafka-schema-registry-client:3.3.0'
testCompile 'junit:junit:4.12'
testCompile "org.apache.kafka:kafka-streams-test-utils:${kafkaVersion}"
testCompileOnly "org.projectlombok:lombok:${lombokVersion}"
api project(':core')

implementation "org.slf4j:slf4j-log4j12:1.7.25"
api "org.apache.kafka:kafka-streams:${kafkaVersion}"
implementation "io.confluent:monitoring-interceptors:${confluentVersion}"

testImplementation 'junit:junit:4.12'
testImplementation "org.apache.kafka:kafka-streams-test-utils:${kafkaVersion}"
testImplementation "org.projectlombok:lombok:${lombokVersion}"
testAnnotationProcessor "org.projectlombok:lombok:${lombokVersion}"
}

Expand All @@ -160,12 +165,12 @@ project(':spring-streams') {
}

dependencies {
compile project(':streams')
implementation project(':streams')

compile "org.springframework.boot:spring-boot-starter-web"
compile 'org.springframework.kafka:spring-kafka'
testCompile "org.springframework.boot:spring-boot-starter-test"
testCompile 'junit:junit'
implementation "org.springframework.boot:spring-boot-starter-web"
implementation 'org.springframework.kafka:spring-kafka'
testImplementation "org.springframework.boot:spring-boot-starter-test"
testImplementation 'junit:junit'
}

configurations.all {
Expand All @@ -184,57 +189,13 @@ def getConfigPath() {
new File(project.getProperty('configPath')).absolutePath
}

/**
* Project to build docker image for Kubernetes + deployment scripts
*/
project(':streams-kubernetes') {
apply plugin: 'com.github.johnrengelman.shadow'
apply plugin: 'com.google.cloud.tools.jib'

def imageBaseName = "streaming-movie-ratings"

/**
* Build an image based on «streams» project
*/
dependencies {
compile project(':streams')
}

// tag::jibConfig[]
jib {
to {
image = "gamov-docker.jfrog.io/dev/${imageBaseName}" // <1>
//image = "gcr.io/cloud-private-dev/gamussa/${imageBaseName}" // <2>
//credHelper = 'gcr' <3>
// end::jibConfig[]
from {
image = "gcr.io/distroless/java:8"
//image = "gcr.io/distroless/java:debug"
//image = "bellsoft/liberica-openjdk-alpine:8u202"
//image = "bellsoft/liberica-openjre-debian:8u202"
}

container {
mainClass = project(":streams").mainClass
args = [
'/config'
]
}
}

// TODO: configure via environment variables/configMaps in Kubernetes
extraDirectory = file("${System.properties['user.home']}/.ccloud")
}
}

project(':streams-kotlin') {
apply plugin: 'kotlin'
apply plugin: "kotlin"
apply plugin: 'kotlinx-serialization'

dependencies {
compile project(':streams')
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
compile "org.jetbrains.kotlin:kotlin-reflect"
compile "org.slf4j:slf4j-log4j12:1.7.25"
implementation project(':streams')
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
implementation "org.slf4j:slf4j-log4j12:1.7.25"
}
}
2 changes: 1 addition & 1 deletion streams-movie-demo/core/src/main/avro/countsum.avsc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"namespace": "io.confluent.demo",
"namespace": "io.confluent.developer",
"type": "record",
"name": "CountAndSum",
"fields": [
Expand Down
2 changes: 1 addition & 1 deletion streams-movie-demo/core/src/main/avro/movie.avsc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"namespace": "io.confluent.demo",
"namespace": "io.confluent.developer",
"type": "record",
"name": "Movie",
"fields": [
Expand Down
2 changes: 1 addition & 1 deletion streams-movie-demo/core/src/main/avro/rated-movie.avsc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"namespace": "io.confluent.demo",
"namespace": "io.confluent.developer",
"type": "record",
"name": "RatedMovie",
"fields": [
Expand Down
2 changes: 1 addition & 1 deletion streams-movie-demo/core/src/main/avro/rating.avsc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"namespace": "io.confluent.demo",
"namespace": "io.confluent.developer",
"type": "record",
"name": "Rating",
"fields": [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.confluent.demo;
package io.confluent.developer;

import java.util.Collections;
import java.util.List;
Expand Down
1 change: 1 addition & 0 deletions streams-movie-demo/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#configPath=/Users/tlberglund/.ccloud/config
configPath=cli-install.properties
mainClass=io.confluent.demo.StreamsDemo
org.gradle.warning.mode=all
Binary file modified streams-movie-demo/gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
6 changes: 3 additions & 3 deletions streams-movie-demo/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Tue Apr 16 17:18:10 EDT 2019
distributionUrl=https\://services.gradle.org/distributions/gradle-5.3.1-all.zip
#Mon Apr 20 18:16:39 EDT 2020
distributionUrl=https\://services.gradle.org/distributions/gradle-6.3-all.zip
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
35 changes: 15 additions & 20 deletions streams-movie-demo/gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
Expand Down Expand Up @@ -125,8 +125,8 @@ if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi

# For Cygwin, switch paths to Windows format before running java
if $cygwin ; then
# For Cygwin or MSYS, switch paths to Windows format before running java
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
Expand Down Expand Up @@ -154,19 +154,19 @@ if $cygwin ; then
else
eval `echo args$i`="\"$arg\""
fi
i=$((i+1))
i=`expr $i + 1`
done
case $i in
(0) set -- ;;
(1) set -- "$args0" ;;
(2) set -- "$args0" "$args1" ;;
(3) set -- "$args0" "$args1" "$args2" ;;
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
0) set -- ;;
1) set -- "$args0" ;;
2) set -- "$args0" "$args1" ;;
3) set -- "$args0" "$args1" "$args2" ;;
4) set -- "$args0" "$args1" "$args2" "$args3" ;;
5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi

Expand All @@ -175,14 +175,9 @@ save () {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}
APP_ARGS=$(save "$@")
APP_ARGS=`save "$@"`

# Collect all arguments for the java command, following the shell quoting and substitution rules
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"

# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
cd "$(dirname "$0")"
fi

exec "$JAVACMD" "$@"
5 changes: 4 additions & 1 deletion streams-movie-demo/gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
@rem you may not use this file except in compliance with the License.
@rem You may obtain a copy of the License at
@rem
@rem http://www.apache.org/licenses/LICENSE-2.0
@rem https://www.apache.org/licenses/LICENSE-2.0
@rem
@rem Unless required by applicable law or agreed to in writing, software
@rem distributed under the License is distributed on an "AS IS" BASIS,
Expand All @@ -29,6 +29,9 @@ if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%

@rem Resolve any "." and ".." in APP_HOME to make it shorter.
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi

@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"

Expand Down
17 changes: 15 additions & 2 deletions streams-movie-demo/legacy-movies-app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,17 +1,26 @@
buildscript{
ext{
tcVersion = "1.14.0"
}
}
plugins {
id 'org.springframework.boot'
id 'io.spring.dependency-management'
id 'java'
id 'io.franzbecker.gradle-lombok' version '3.2.0'
}

repositories {
maven { url 'https://jitpack.io' }
}

group = 'io.confluent.developer'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '1.8'

dependencies {
// avro generated pojos
compile project(':core')
implementation project(':core')

implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-jdbc'
Expand All @@ -22,6 +31,10 @@ dependencies {
exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
}
testImplementation 'org.springframework.kafka:spring-kafka-test'
testImplementation "org.testcontainers:testcontainers:$tcVersion"
testImplementation "org.testcontainers:kafka:$tcVersion"
testImplementation 'com.github.gAmUssA:testcontainers-java-module-confluent-platform:master-SNAPSHOT'

}

configurations.all {
Expand All @@ -30,4 +43,4 @@ configurations.all {

test {
useJUnitPlatform()
}
}
Loading

0 comments on commit fba1bf9

Please sign in to comment.