From 5e2719c06c0795ff47826d931b8c25692e906163 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Vonheiden?= <bjoern.vonheiden@hotmail.de> Date: Thu, 14 May 2020 17:59:30 +0200 Subject: [PATCH] Configure different dependencies for subprojects in gradle - Define variables for commons projects and uc projects - Add different dependencies to the different subprojects - Apply application plugin only to ucs - allow uc to use the commons project as dependency diff --git a/build.gradle b/build.gradle index 6827860..694a127 100644 --- a/build.gradle +++ b/build.gradle @@ -10,20 +10,27 @@ buildscript { } } -// Plugins for all projects +// Variables used to distinct different subprojects +def useCaseProjects = subprojects.findAll {it -> it.name.matches('uc(.)*')} +def commonProjects = subprojects.findAll {it -> it.name.matches('(.)*commons(.)*')} + + +// 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 { @@ -47,8 +54,8 @@ allprojects { } } -// Dependencies -subprojects { +// Dependencies for all use cases +configure(useCaseProjects) { 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 } @@ -60,6 +67,22 @@ subprojects { 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(':application-kafkastreams-commons') + + // 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 } // Use JUnit test framework testImplementation 'junit:junit:4.12' --- build.gradle | 33 ++++++++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/build.gradle b/build.gradle index 682786086..694a127ca 100644 --- a/build.gradle +++ b/build.gradle @@ -10,20 +10,27 @@ buildscript { } } -// Plugins for all projects +// Variables used to distinct different subprojects +def useCaseProjects = subprojects.findAll {it -> it.name.matches('uc(.)*')} +def commonProjects = subprojects.findAll {it -> it.name.matches('(.)*commons(.)*')} + + +// 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 { @@ -47,8 +54,8 @@ allprojects { } } -// Dependencies -subprojects { +// Dependencies for all use cases +configure(useCaseProjects) { 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 } @@ -60,6 +67,22 @@ subprojects { 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(':application-kafkastreams-commons') + + // 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 } // Use JUnit test framework testImplementation 'junit:junit:4.12' -- GitLab