From 8baf275c8f7035834e980f80864f2e86dc030320 Mon Sep 17 00:00:00 2001 From: Tom Hombergs Date: Sat, 14 Dec 2019 07:59:28 +1100 Subject: [PATCH] isolated all modules --- .gitignore | 3 + .idea/.gitignore | 2 - .idea/examples.iml | 12 -- .idea/inspectionProfiles/Project_Default.xml | 6 - ..._boot_starter_validation_2_1_3_RELEASE.xml | 9 -- .idea/misc.xml | 7 -- .idea/modules.xml | 85 -------------- .idea/modules/spring-boot-testing.iml | 13 --- .idea/vcs.xml | 6 - README.md | 29 ++--- build-all.sh | 106 ++++++++++-------- junit/assumptions/build.gradle | 3 + .../gradle/wrapper/gradle-wrapper.properties | 2 +- .../gradle}/wrapper/gradle-wrapper.jar | Bin .../gradle/wrapper/gradle-wrapper.properties | 0 gradlew => logging/gradlew | 0 gradlew.bat => logging/gradlew.bat | 0 pact/pact-message-consumer/README.md | 3 + .../gradle/wrapper/gradle-wrapper.properties | 2 +- settings.gradle | 32 ------ spring-boot/modular/application/build.gradle | 4 +- spring-boot/modular/build.gradle | 3 + .../gradle/wrapper/gradle-wrapper.jar | Bin .../gradle}/wrapper/gradle-wrapper.properties | 3 +- spring-boot/modular/{application => }/gradlew | 0 .../modular/{application => }/gradlew.bat | 0 spring-boot/modular/settings.gradle | 3 + spring-boot/spring-boot-logging/build.gradle | 2 +- .../gradle/wrapper/gradle-wrapper.properties | 2 +- build.gradle => spring-cloud/build.gradle | 0 .../settings.gradle | 0 spring-cloud/settings.gradle | 2 + .../sleuth-downstream-service/settings.gradle | 0 .../sleuth-upstream-service/settings.gradle | 0 .../build.gradle | 2 +- .../gradle/wrapper/gradle-wrapper.properties | 2 +- 36 files changed, 92 insertions(+), 251 deletions(-) create mode 100644 .gitignore delete mode 100644 .idea/.gitignore delete mode 100644 .idea/examples.iml delete mode 100644 .idea/inspectionProfiles/Project_Default.xml delete mode 100644 .idea/libraries/Gradle__org_springframework_boot_spring_boot_starter_validation_2_1_3_RELEASE.xml delete mode 100644 .idea/misc.xml delete mode 100644 .idea/modules.xml delete mode 100644 .idea/modules/spring-boot-testing.iml delete mode 100644 .idea/vcs.xml rename {gradle => logging/gradle}/wrapper/gradle-wrapper.jar (100%) rename {spring-boot/modular/application => logging}/gradle/wrapper/gradle-wrapper.properties (100%) rename gradlew => logging/gradlew (100%) mode change 100755 => 100644 rename gradlew.bat => logging/gradlew.bat (100%) delete mode 100644 settings.gradle rename spring-boot/modular/{application => }/gradle/wrapper/gradle-wrapper.jar (100%) rename {gradle => spring-boot/modular/gradle}/wrapper/gradle-wrapper.properties (79%) rename spring-boot/modular/{application => }/gradlew (100%) rename spring-boot/modular/{application => }/gradlew.bat (100%) create mode 100644 spring-boot/modular/settings.gradle rename build.gradle => spring-cloud/build.gradle (100%) create mode 100644 spring-cloud/feign-with-spring-data-rest/settings.gradle create mode 100644 spring-cloud/settings.gradle create mode 100644 spring-cloud/sleuth-downstream-service/settings.gradle create mode 100644 spring-cloud/sleuth-upstream-service/settings.gradle diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..07f8b1e --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +**/.idea/ +**/*.iml + diff --git a/.idea/.gitignore b/.idea/.gitignore deleted file mode 100644 index 5c98b42..0000000 --- a/.idea/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# Default ignored files -/workspace.xml \ No newline at end of file diff --git a/.idea/examples.iml b/.idea/examples.iml deleted file mode 100644 index 8b67393..0000000 --- a/.idea/examples.iml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml deleted file mode 100644 index df7825d..0000000 --- a/.idea/inspectionProfiles/Project_Default.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - \ No newline at end of file diff --git a/.idea/libraries/Gradle__org_springframework_boot_spring_boot_starter_validation_2_1_3_RELEASE.xml b/.idea/libraries/Gradle__org_springframework_boot_spring_boot_starter_validation_2_1_3_RELEASE.xml deleted file mode 100644 index 1ac682d..0000000 --- a/.idea/libraries/Gradle__org_springframework_boot_spring_boot_starter_validation_2_1_3_RELEASE.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml deleted file mode 100644 index 20295fe..0000000 --- a/.idea/misc.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml deleted file mode 100644 index 906af1a..0000000 --- a/.idea/modules.xml +++ /dev/null @@ -1,85 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/modules/spring-boot-testing.iml b/.idea/modules/spring-boot-testing.iml deleted file mode 100644 index d059007..0000000 --- a/.idea/modules/spring-boot-testing.iml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml deleted file mode 100644 index 35eb1dd..0000000 --- a/.idea/vcs.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/README.md b/README.md index da933d1..cc2ab3d 100644 --- a/README.md +++ b/README.md @@ -5,32 +5,17 @@ This repo contains example projects which show how to use different (not only) Java technologies. The examples are usually accompanied by a blog post on [https://reflectoring.io](https://reflectoring.io). -See the READMEs in each subdirectory of this repo for more information. +See the READMEs in each subdirectory of this repo for more information on each module. -# Java -All modules require **Java 11** to compile and run. +## Java Modules +All Java modules require **Java 11** to compile and run. -# Building with Gradle +### Building with Gradle -Modules should be as independent as possible. There are groups of modules that only work together, but other than that, a module should have its own build. +Each module should be an independent build and can be built by calling `./gradlew clean build` in the module directory. -See [build-all.sh](build-all.sh) for all builds that are run in the CI pipeline. +All modules are listed in [build-all.sh](build-all.sh) to run in the CI pipeline. -## Building all Modules at Once - -In the main folder, run -``` -./gradlew clean build -``` - -## Building a Module Separately - -In the folder of the module, run - -``` -./gradlew clean build -``` - -## Non-Java Modules +### Non-Java Modules Some folders contain non-Java projects. For those, refer to the README within the module folder. diff --git a/build-all.sh b/build-all.sh index 0ef5b91..bface02 100644 --- a/build-all.sh +++ b/build-all.sh @@ -1,50 +1,62 @@ +#!/bin/bash + +MAIN_DIR=$PWD + +build_gradle_module() { + MODULE_PATH=$1 + echo "+++" + echo "+++ BUILDING MODULE $MODULE_PATH" + echo "+++" + cd $MODULE_PATH && { + chmod +x gradlew + ./gradlew clean build --info --stacktrace + if [ $? -ne 0 ] + then + echo "+++" + echo "+++ BUILDING MODULE $MODULE_PATH FAILED" + echo "+++" + exit 1 + else + echo "+++" + echo "+++ BUILDING MODULE $MODULE_PATH SUCCESSFUL" + echo "+++" + echo "" + fi + cd $MAIN_DIR + } +} + chmod +x gradlew -./gradlew clean build --info -cd spring-boot/starter && { - chmod +x gradlew - ./gradlew clean build --info - cd ../../ -} +build_gradle_module "junit/assumptions" +build_gradle_module "logging" +build_gradle_module "pact/pact-feign-consumer" +# currently disabled since the consumer build won't run +# build_gradle_module "pact/pact-message-consumer" +# build_gradle_module "pact/pact-message-producer" +build_gradle_module "pact/pact-spring-provider" +build_gradle_module "patterns" +build_gradle_module "spring-boot/conditionals" +build_gradle_module "spring-boot/configuration" +build_gradle_module "spring-boot/mocking" +build_gradle_module "spring-boot/modular" +build_gradle_module "spring-boot/paging" +build_gradle_module "spring-boot/rabbitmq-event-brokering" +build_gradle_module "spring-boot/spring-boot-logging" +build_gradle_module "spring-boot/spring-boot-testing" +build_gradle_module "spring-boot/starter" +build_gradle_module "spring-boot/startup" +build_gradle_module "spring-boot/static" +build_gradle_module "spring-boot/validation" +build_gradle_module "spring-cloud/feign-with-spring-data-rest" +build_gradle_module "spring-cloud/sleuth-downstream-service" +build_gradle_module "spring-cloud/sleuth-upstream-service" +build_gradle_module "spring-cloud/spring-cloud-contract-consumer" +build_gradle_module "spring-cloud/spring-cloud-contract-provider" +build_gradle_module "spring-data/spring-data-rest-associations" +build_gradle_module "spring-data/spring-data-rest-springfox" +build_gradle_module "tools/jacoco" -cd spring-boot/validation && { - chmod +x gradlew - ./gradlew clean build --info - cd ../../ -} - -cd spring-boot/mocking && { - chmod +x gradlew - ./gradlew clean build --info - cd ../../ -} - -cd patterns && { - chmod +x gradlew - ./gradlew clean build --info - cd ../ -} - -cd spring-boot/static && { - chmod +x gradlew - ./gradlew clean build --info - cd ../../ -} - -cd spring-boot/startup && { - chmod +x gradlew - ./gradlew clean build --info - cd ../../ -} - -cd spring-data/spring-data-rest-associations && { - chmod +x gradlew - ./gradlew clean build --info - cd ../../ -} - -cd spring-data/spring-data-rest-springfox && { - chmod +x gradlew - ./gradlew clean build --info - cd ../../ -} +echo "+++" +echo "+++ ALL MODULES SUCCESSFUL" +echo "+++" \ No newline at end of file diff --git a/junit/assumptions/build.gradle b/junit/assumptions/build.gradle index ef9de65..f0f0aab 100644 --- a/junit/assumptions/build.gradle +++ b/junit/assumptions/build.gradle @@ -23,3 +23,6 @@ dependencies { testCompile 'junit:junit:4.12' } +test { + useJUnitPlatform() +} \ No newline at end of file diff --git a/junit/assumptions/gradle/wrapper/gradle-wrapper.properties b/junit/assumptions/gradle/wrapper/gradle-wrapper.properties index 1498dd7..4c46317 100644 --- a/junit/assumptions/gradle/wrapper/gradle-wrapper.properties +++ b/junit/assumptions/gradle/wrapper/gradle-wrapper.properties @@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-bin.zip diff --git a/gradle/wrapper/gradle-wrapper.jar b/logging/gradle/wrapper/gradle-wrapper.jar similarity index 100% rename from gradle/wrapper/gradle-wrapper.jar rename to logging/gradle/wrapper/gradle-wrapper.jar diff --git a/spring-boot/modular/application/gradle/wrapper/gradle-wrapper.properties b/logging/gradle/wrapper/gradle-wrapper.properties similarity index 100% rename from spring-boot/modular/application/gradle/wrapper/gradle-wrapper.properties rename to logging/gradle/wrapper/gradle-wrapper.properties diff --git a/gradlew b/logging/gradlew old mode 100755 new mode 100644 similarity index 100% rename from gradlew rename to logging/gradlew diff --git a/gradlew.bat b/logging/gradlew.bat similarity index 100% rename from gradlew.bat rename to logging/gradlew.bat diff --git a/pact/pact-message-consumer/README.md b/pact/pact-message-consumer/README.md index b123aeb..efc6cda 100644 --- a/pact/pact-message-consumer/README.md +++ b/pact/pact-message-consumer/README.md @@ -2,3 +2,6 @@ This module shows how to use Pact to implement a contract test for a message provider. +## Companion Articles +[Testing a Spring Message Producer and Consumer against a Contract with Pact](https://reflectoring.io/cdc-pact-messages/) + diff --git a/pact/pact-message-consumer/gradle/wrapper/gradle-wrapper.properties b/pact/pact-message-consumer/gradle/wrapper/gradle-wrapper.properties index 1498dd7..4c46317 100644 --- a/pact/pact-message-consumer/gradle/wrapper/gradle-wrapper.properties +++ b/pact/pact-message-consumer/gradle/wrapper/gradle-wrapper.properties @@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-bin.zip diff --git a/settings.gradle b/settings.gradle deleted file mode 100644 index fafd513..0000000 --- a/settings.gradle +++ /dev/null @@ -1,32 +0,0 @@ -include 'spring-cloud:feign-with-spring-data-rest' -include 'spring-cloud:sleuth-downstream-service' -include 'spring-cloud:sleuth-upstream-service' -include 'spring-cloud:spring-cloud-contract-provider' -include 'spring-cloud:spring-cloud-contract-consumer' - -include 'pact:pact-spring-provider' -include 'pact:pact-feign-consumer' -include 'pact:pact-message-consumer' -include 'pact:pact-message-producer' - - -include 'spring-boot:rabbitmq-event-brokering' -include 'spring-boot:modular:security-module' -include 'spring-boot:modular:booking-module' -include 'spring-boot:modular:application' -include 'spring-boot:spring-boot-testing' -include 'spring-boot:spring-boot-logging' -include 'spring-boot:conditionals' -include 'spring-boot:configuration' -include 'spring-boot:paging' - -include 'logging' - -include 'junit:conditions' - -include 'tools:jacoco' - -include 'java' - - - diff --git a/spring-boot/modular/application/build.gradle b/spring-boot/modular/application/build.gradle index b3c8480..19e1c95 100644 --- a/spring-boot/modular/application/build.gradle +++ b/spring-boot/modular/application/build.gradle @@ -24,8 +24,8 @@ repositories { dependencies { compile('org.springframework.boot:spring-boot-starter-web') - compile project(':spring-boot:modular:security-module') - compile project(':spring-boot:modular:booking-module') + compile project(':security-module') + compile project(':booking-module') testCompile('org.springframework.boot:spring-boot-starter-test') } diff --git a/spring-boot/modular/build.gradle b/spring-boot/modular/build.gradle index e69de29..db45cf0 100644 --- a/spring-boot/modular/build.gradle +++ b/spring-boot/modular/build.gradle @@ -0,0 +1,3 @@ +tasks.withType(JavaCompile) { + options.fork = true; +} \ No newline at end of file diff --git a/spring-boot/modular/application/gradle/wrapper/gradle-wrapper.jar b/spring-boot/modular/gradle/wrapper/gradle-wrapper.jar similarity index 100% rename from spring-boot/modular/application/gradle/wrapper/gradle-wrapper.jar rename to spring-boot/modular/gradle/wrapper/gradle-wrapper.jar diff --git a/gradle/wrapper/gradle-wrapper.properties b/spring-boot/modular/gradle/wrapper/gradle-wrapper.properties similarity index 79% rename from gradle/wrapper/gradle-wrapper.properties rename to spring-boot/modular/gradle/wrapper/gradle-wrapper.properties index 2e22622..1498dd7 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/spring-boot/modular/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,5 @@ -#Sun Jul 30 16:58:54 CEST 2017 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-bin.zip diff --git a/spring-boot/modular/application/gradlew b/spring-boot/modular/gradlew similarity index 100% rename from spring-boot/modular/application/gradlew rename to spring-boot/modular/gradlew diff --git a/spring-boot/modular/application/gradlew.bat b/spring-boot/modular/gradlew.bat similarity index 100% rename from spring-boot/modular/application/gradlew.bat rename to spring-boot/modular/gradlew.bat diff --git a/spring-boot/modular/settings.gradle b/spring-boot/modular/settings.gradle new file mode 100644 index 0000000..33ad7bc --- /dev/null +++ b/spring-boot/modular/settings.gradle @@ -0,0 +1,3 @@ +include "application" +include "booking-module" +include "security-module" \ No newline at end of file diff --git a/spring-boot/spring-boot-logging/build.gradle b/spring-boot/spring-boot-logging/build.gradle index 8c71796..b54524b 100644 --- a/spring-boot/spring-boot-logging/build.gradle +++ b/spring-boot/spring-boot-logging/build.gradle @@ -1,6 +1,6 @@ buildscript { ext { - springBootVersion = '2.0.4.RELEASE' + springBootVersion = '2.2.1.RELEASE' } repositories { mavenCentral() diff --git a/spring-boot/spring-boot-logging/gradle/wrapper/gradle-wrapper.properties b/spring-boot/spring-boot-logging/gradle/wrapper/gradle-wrapper.properties index 448cc64..afa1eac 100644 --- a/spring-boot/spring-boot-logging/gradle/wrapper/gradle-wrapper.properties +++ b/spring-boot/spring-boot-logging/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.8.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-bin.zip diff --git a/build.gradle b/spring-cloud/build.gradle similarity index 100% rename from build.gradle rename to spring-cloud/build.gradle diff --git a/spring-cloud/feign-with-spring-data-rest/settings.gradle b/spring-cloud/feign-with-spring-data-rest/settings.gradle new file mode 100644 index 0000000..e69de29 diff --git a/spring-cloud/settings.gradle b/spring-cloud/settings.gradle new file mode 100644 index 0000000..d1202cc --- /dev/null +++ b/spring-cloud/settings.gradle @@ -0,0 +1,2 @@ +include "spring-cloud-contract-consumer" +include "spring-cloud-contract-provider" \ No newline at end of file diff --git a/spring-cloud/sleuth-downstream-service/settings.gradle b/spring-cloud/sleuth-downstream-service/settings.gradle new file mode 100644 index 0000000..e69de29 diff --git a/spring-cloud/sleuth-upstream-service/settings.gradle b/spring-cloud/sleuth-upstream-service/settings.gradle new file mode 100644 index 0000000..e69de29 diff --git a/spring-cloud/spring-cloud-contract-consumer/build.gradle b/spring-cloud/spring-cloud-contract-consumer/build.gradle index 0d21f0a..a85b1f0 100644 --- a/spring-cloud/spring-cloud-contract-consumer/build.gradle +++ b/spring-cloud/spring-cloud-contract-consumer/build.gradle @@ -31,7 +31,7 @@ dependencies { compile('com.h2database:h2:1.4.196') // This dependency is only included so that the gradle build executes the provider build first! // It should not be included in a real project. - compile project(':spring-cloud:spring-cloud-contract-provider') + compile project(':spring-cloud-contract-provider') testCompile("org.springframework.cloud:spring-cloud-starter-contract-stub-runner") testCompile("org.springframework.boot:spring-boot-starter-test") } diff --git a/spring-data/spring-data-rest-associations/gradle/wrapper/gradle-wrapper.properties b/spring-data/spring-data-rest-associations/gradle/wrapper/gradle-wrapper.properties index 90a06ce..1d5b29f 100644 --- a/spring-data/spring-data-rest-associations/gradle/wrapper/gradle-wrapper.properties +++ b/spring-data/spring-data-rest-associations/gradle/wrapper/gradle-wrapper.properties @@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-3.5.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.3-bin.zip