From 98bd4dcd7658795d17ae059532871b38f674140a Mon Sep 17 00:00:00 2001
From: Simon Ehrenstein <simon.ehrenstein@gmail.com>
Date: Tue, 2 Jun 2020 00:01:30 +0200
Subject: [PATCH] Fix gradle setuo

---
 build.gradle                           | 65 ++++++++++++++++++++++----
 settings.gradle                        |  6 +--
 uc1-workload-generator/build.gradle    |  4 --
 uc2-workload-generator/build.gradle    |  6 +--
 uc3-workload-generator/build.gradle    |  4 --
 uc4-workload-generator/build.gradle    |  4 --
 workload-generator-common/build.gradle | 24 ----------
 7 files changed, 59 insertions(+), 54 deletions(-)

diff --git a/build.gradle b/build.gradle
index 682786086..f0887c989 100644
--- a/build.gradle
+++ b/build.gradle
@@ -10,20 +10,28 @@ buildscript {
   }
 }
 
-// Plugins for all projects
+// Variables used to distinct different subprojects
+def useCaseProjects = subprojects.findAll {it -> it.name.matches('uc(.)*')}
+def useCaseApplications = subprojects.findAll {it -> it.name.matches('uc[0-9]+-application')}
+def useCaseGenerators = subprojects.findAll {it -> it.name.matches('uc[0-9]+-workload-generator*')}
+def commonProjects = subprojects.findAll {it -> it.name.matches('(.)*common(s?)(.)*')}
+
+// Plugins
 allprojects {
   apply plugin: 'eclipse'
 }
 
-// Plugins for subprojects
 subprojects {
-  apply plugin: 'application'
   apply plugin: 'checkstyle'
   apply plugin: 'pmd'
   apply plugin: 'com.github.spotbugs'
   apply plugin: 'java-library'
 }
 
+configure(useCaseProjects){
+    apply plugin: 'application'
+}
+
 // Java version for all subprojects
 subprojects {
   java {
@@ -44,22 +52,59 @@ allprojects {
 	    maven {
 	    	url "https://oss.sonatype.org/content/repositories/snapshots/"
 	    }
+      maven {
+        url 'https://packages.confluent.io/maven/'
+    }
 	}
 }
 
-// Dependencies
-subprojects {
+// Dependencies for all use case applications
+configure(useCaseApplications) {
   dependencies {
-      // These dependencies is exported to consumers, that is to say found on their compile classpath.
-      api('org.industrial-devops:titan-ccp-common:0.0.3-SNAPSHOT') { changing = true }
-      api 'net.kieker-monitoring:kieker:1.14-SNAPSHOT'
-      api 'net.sourceforge.teetime:teetime:3.0'
+      // These dependencies are used internally, and not exposed to consumers on their own compile classpath.
+      implementation('org.industrial-devops:titan-ccp-common:0.0.3-SNAPSHOT') { changing = true }      // This branch depends still on old version of titan-ccp-common
+      implementation('org.industrial-devops:titan-ccp-common-kafka:0.1.0-SNAPSHOT') { changing = true }
+      implementation 'com.google.guava:guava:24.1-jre'
+      implementation 'org.jctools:jctools-core:2.1.1'
+      implementation 'org.slf4j:slf4j-simple:1.6.1'
 
+      // Use JUnit test framework
+      testImplementation 'junit:junit:4.12'
+      
+      implementation('org.industrial-devops:titan-ccp-common:0.0.3-SNAPSHOT') { changing = true }
+  }
+}
+
+// Dependencies for all use case generators
+configure(useCaseGenerators) {
+  dependencies {
       // These dependencies are used internally, and not exposed to consumers on their own compile classpath.
-      implementation 'org.apache.kafka:kafka-clients:2.1.0'
+      // implementation('org.industrial-devops:titan-ccp-common:0.1.0-SNAPSHOT') { changing = true }
+      implementation('org.industrial-devops:titan-ccp-common-kafka:0.0.1-SNAPSHOT') { changing = true }
       implementation 'com.google.guava:guava:24.1-jre'
       implementation 'org.jctools:jctools-core:2.1.1'
       implementation 'org.slf4j:slf4j-simple:1.6.1'
+      implementation project(':workload-generator-common')
+
+      // maintain build of generators
+      implementation 'net.kieker-monitoring:kieker:1.14-SNAPSHOT'
+      implementation('org.industrial-devops:titan-ccp-common:0.0.3-SNAPSHOT') { changing = true }
+
+      // Use JUnit test framework
+      testImplementation 'junit:junit:4.12'
+  }
+}
+
+// Dependencies for all commons
+configure(commonProjects) {
+  dependencies {
+      // These dependencies is exported to consumers, that is to say found on their compile classpath.
+      api 'org.apache.kafka:kafka-clients:2.4.0'
+      
+      // These dependencies are used internally, and not exposed to consumers on their own compile classpath.
+      implementation 'org.slf4j:slf4j-simple:1.6.1'
+      implementation('org.industrial-devops:titan-ccp-common:0.0.3-SNAPSHOT') { changing = true }      // This branch depends still on old version of titan-ccp-common
+      implementation('org.industrial-devops:titan-ccp-common-kafka:0.1.0-SNAPSHOT') { changing = true }
 
       // Use JUnit test framework
       testImplementation 'junit:junit:4.12'
diff --git a/settings.gradle b/settings.gradle
index a8da5d5df..4a8dfe3a6 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -1,5 +1,7 @@
 rootProject.name = 'scalability-benchmarking'
 
+include 'workload-generator-common'
+
 include 'uc1-workload-generator'
 include 'uc1-application'
 
@@ -10,6 +12,4 @@ include 'uc3-workload-generator'
 include 'uc3-application'
 
 include 'uc4-workload-generator'
-include 'uc4-application'
-
-include 'workload-generator-common'
\ No newline at end of file
+include 'uc4-application'
\ No newline at end of file
diff --git a/uc1-workload-generator/build.gradle b/uc1-workload-generator/build.gradle
index cba0ffcbc..d934bd09d 100644
--- a/uc1-workload-generator/build.gradle
+++ b/uc1-workload-generator/build.gradle
@@ -1,5 +1 @@
 mainClassName = "spesb.uc1.workloadgenerator.LoadGenerator"
-
-dependencies {
-    compile project(':workload-generator-common')
-}
\ No newline at end of file
diff --git a/uc2-workload-generator/build.gradle b/uc2-workload-generator/build.gradle
index 660079168..9b35bdaa4 100644
--- a/uc2-workload-generator/build.gradle
+++ b/uc2-workload-generator/build.gradle
@@ -1,5 +1 @@
-mainClassName = "spesb.uc2.workloadgenerator.LoadGenerator"
-
-dependencies {
-    compile project(':workload-generator-common')
-}
\ No newline at end of file
+mainClassName = "spesb.uc2.workloadgenerator.LoadGenerator"
\ No newline at end of file
diff --git a/uc3-workload-generator/build.gradle b/uc3-workload-generator/build.gradle
index a635010f4..e27cf26d2 100644
--- a/uc3-workload-generator/build.gradle
+++ b/uc3-workload-generator/build.gradle
@@ -1,5 +1 @@
 mainClassName = "spesb.uc3.workloadgenerator.LoadGenerator"
-
-dependencies {
-    compile project(':workload-generator-common')
-}
\ No newline at end of file
diff --git a/uc4-workload-generator/build.gradle b/uc4-workload-generator/build.gradle
index de0d5028d..8bbdedf4f 100644
--- a/uc4-workload-generator/build.gradle
+++ b/uc4-workload-generator/build.gradle
@@ -1,5 +1 @@
 mainClassName = "spesb.uc4.workloadgenerator.LoadGenerator"
-
-dependencies {
-    compile project(':workload-generator-common')
-}
\ No newline at end of file
diff --git a/workload-generator-common/build.gradle b/workload-generator-common/build.gradle
index fa81c5036..5ce6a38be 100644
--- a/workload-generator-common/build.gradle
+++ b/workload-generator-common/build.gradle
@@ -1,27 +1,3 @@
-apply plugin: 'java-library'
-
-buildscript {
-  repositories {
-    maven {
-      url "https://plugins.gradle.org/m2/"
-    }
-  }
-}
-
-sourceCompatibility = "1.11"
-targetCompatibility = "1.11"
-
 dependencies {
     compile 'org.apache.curator:curator-recipes:4.3.0'
-    compile 'org.slf4j:slf4j-simple:1.6.1'
-
-    // Use JUnit test framework
-    testCompile 'junit:junit:4.12'
-}
-
-eclipse {
-    classpath {
-       downloadSources=true
-       downloadJavadoc=true
-    }
 }
\ No newline at end of file
-- 
GitLab