From c848f6a5342474f23c3e778f2528874cb2955617 Mon Sep 17 00:00:00 2001 From: Gustavo Martin Morcuende Date: Mon, 9 Jan 2017 00:22:07 +0100 Subject: [PATCH] Gradle getting ready for multi project configuration --- SpringJava/Gradle/build-integTest.gradle | 36 ++++++++++++ SpringJava/Gradle/build-test.gradle | 12 ++++ SpringJava/Gradle/build.gradle | 52 ++++++++++++++++++ SpringJava/Gradle/settings.gradle | 1 + .../spring-jpa-persistence/build-integTest.gradle | 54 ------------------ .../spring-jpa-persistence/build-test.gradle | 12 ---- .../Gradle/spring-jpa-persistence/build.gradle | 64 +++++----------------- .../Gradle/spring-jpa-persistence/settings.gradle | 1 - 8 files changed, 116 insertions(+), 116 deletions(-) create mode 100644 SpringJava/Gradle/build-integTest.gradle create mode 100644 SpringJava/Gradle/build-test.gradle create mode 100644 SpringJava/Gradle/build.gradle create mode 100644 SpringJava/Gradle/settings.gradle delete mode 100644 SpringJava/Gradle/spring-jpa-persistence/build-integTest.gradle delete mode 100644 SpringJava/Gradle/spring-jpa-persistence/build-test.gradle delete mode 100644 SpringJava/Gradle/spring-jpa-persistence/settings.gradle diff --git a/SpringJava/Gradle/build-integTest.gradle b/SpringJava/Gradle/build-integTest.gradle new file mode 100644 index 0000000..575fc86 --- /dev/null +++ b/SpringJava/Gradle/build-integTest.gradle @@ -0,0 +1,36 @@ +sourceSets { + integTest { + compileClasspath += main.output + test.output + runtimeClasspath += main.output + test.output + } +} + +configurations { + integTestCompile.extendsFrom testCompile + integTestRuntime.extendsFrom testRuntime +} + + +task integTest(type: Test) { + // dependsOn startApp + // finalizedBy stopApp + description = 'Runs integration tests'; + group = 'verification'; + + testClassesDir = sourceSets.integTest.output.classesDir + classpath = sourceSets.integTest.runtimeClasspath + + testLogging { + events "PASSED", "FAILED", "SKIPPED" + } + + jacoco { + append = false + destinationFile = file("$buildDir/jacoco/jacoco-it.exec") + classDumpFile = file("$buildDir/jacoco/classpathIntegdumps") + } + + // mustRunAfter test +} + +project.tasks.check.dependsOn(integTest) diff --git a/SpringJava/Gradle/build-test.gradle b/SpringJava/Gradle/build-test.gradle new file mode 100644 index 0000000..3cc22f6 --- /dev/null +++ b/SpringJava/Gradle/build-test.gradle @@ -0,0 +1,12 @@ +test { + testLogging { + events "PASSED", "FAILED", "SKIPPED" + } + + jacoco { + append = false + destinationFile = file("$buildDir/jacoco/jacoco.exec") + classDumpFile = file("$buildDir/jacoco/classpathdumps") + } +} + diff --git a/SpringJava/Gradle/build.gradle b/SpringJava/Gradle/build.gradle new file mode 100644 index 0000000..c6f6aba --- /dev/null +++ b/SpringJava/Gradle/build.gradle @@ -0,0 +1,52 @@ +subprojects { + apply plugin: 'java' + apply plugin: 'idea' + apply plugin: 'jacoco' + apply plugin: 'eclipse' + apply plugin: 'idea' + + group 'de.spring.jpa' + version '1.0-SNAPSHOT' + + targetCompatibility = 1.8 + sourceCompatibility = 1.8 + + + repositories { + mavenCentral() + maven { url 'https://dl.bintray.com/palantir/releases' } + } + + buildscript { + repositories { + mavenCentral() + maven { url 'https://plugins.gradle.org/m2/' } + } + } + + jar { + manifest { + attributes 'Implementation-Title': 'Spring JPA Persistence, gradle example', 'Implementation-Version': version + } + } + + apply plugin: 'jacoco' + + apply from: "$rootProject.projectDir/build-test.gradle" + apply from: "$rootProject.projectDir/build-integTest.gradle" + + jacoco { + toolVersion = '0.7.6.201602180812' + reportsDir = file("$buildDir/reports/jacoco") + } + + jacocoTestReport { + reports { + xml.enabled false + csv.enabled false + html.destination "${buildDir}/jacoco/" + } + } + +} + diff --git a/SpringJava/Gradle/settings.gradle b/SpringJava/Gradle/settings.gradle new file mode 100644 index 0000000..89575c1 --- /dev/null +++ b/SpringJava/Gradle/settings.gradle @@ -0,0 +1 @@ +include 'spring-jpa-persistence' diff --git a/SpringJava/Gradle/spring-jpa-persistence/build-integTest.gradle b/SpringJava/Gradle/spring-jpa-persistence/build-integTest.gradle deleted file mode 100644 index 78b70fd..0000000 --- a/SpringJava/Gradle/spring-jpa-persistence/build-integTest.gradle +++ /dev/null @@ -1,54 +0,0 @@ -sourceSets { - integTest { - compileClasspath += main.output + test.output - runtimeClasspath += main.output + test.output - } -} - -configurations { - integTestCompile.extendsFrom testCompile - integTestRuntime.extendsFrom testRuntime -} - - -task integTest(type: Test) { - // dependsOn startApp - // finalizedBy stopApp - description = 'Runs integration tests'; - group = 'verification'; - - testClassesDir = sourceSets.integTest.output.classesDir - classpath = sourceSets.integTest.runtimeClasspath - - testLogging { - events "PASSED", "FAILED", "SKIPPED" - } - - jacoco { - append = false - destinationFile = file("$buildDir/jacoco/jacoco-it.exec") - classDumpFile = file("$buildDir/jacoco/classpathIntegdumps") - } - - // mustRunAfter test -} - -integTest.doFirst { - // It is required in order to run data bases in random ports. - // We need it for running tests from IDE and from command console but - // also it will be required by systems like Travis where we do not control - // the available ports. - def mysqlInfo = dockerCompose.servicesInfos.mysql - systemProperty 'DATABASE_PORT', mysqlInfo.ports[3306] -} - -dockerCompose.isRequiredBy(integTest) -dockerCompose { - useComposeFiles = ['src/integTest/resources/docker/docker-compose.yml'] - captureContainersOutput = false - stopContainers = true - removeContainers = true - buildBeforeUp = false -} - -project.tasks.check.dependsOn(integTest) diff --git a/SpringJava/Gradle/spring-jpa-persistence/build-test.gradle b/SpringJava/Gradle/spring-jpa-persistence/build-test.gradle deleted file mode 100644 index 3cc22f6..0000000 --- a/SpringJava/Gradle/spring-jpa-persistence/build-test.gradle +++ /dev/null @@ -1,12 +0,0 @@ -test { - testLogging { - events "PASSED", "FAILED", "SKIPPED" - } - - jacoco { - append = false - destinationFile = file("$buildDir/jacoco/jacoco.exec") - classDumpFile = file("$buildDir/jacoco/classpathdumps") - } -} - diff --git a/SpringJava/Gradle/spring-jpa-persistence/build.gradle b/SpringJava/Gradle/spring-jpa-persistence/build.gradle index d726f95..25b3053 100644 --- a/SpringJava/Gradle/spring-jpa-persistence/build.gradle +++ b/SpringJava/Gradle/spring-jpa-persistence/build.gradle @@ -1,46 +1,14 @@ -group 'de.spring.jpa' -version '1.0-SNAPSHOT' - - buildscript { - repositories { - mavenCentral() - maven { url 'https://plugins.gradle.org/m2/' } - } + dependencies { classpath 'gradle.plugin.com.ewerk.gradle.plugins:querydsl-plugin:1.0.7' classpath 'com.avast.gradle:docker-compose-gradle-plugin:0.3.16' } } -apply plugin: 'java' -apply plugin: 'eclipse' -apply plugin: 'idea' -apply plugin: 'jacoco' apply plugin: 'com.ewerk.gradle.plugins.querydsl' apply plugin: 'docker-compose' -apply from: 'build-test.gradle' -apply from: 'build-integTest.gradle' - - -targetCompatibility = 1.8 -sourceCompatibility = 1.8 - - - -repositories { - mavenCentral() - maven { url 'https://dl.bintray.com/palantir/releases' } -} - -eclipse { - classpath { - downloadJavadoc = true - downloadSources = true - } -} - dependencies { // 1/3 Required dependency for log4j 2 with slf4j: binding between log4j2 and slf4j compile('org.apache.logging.log4j:log4j-slf4j-impl:2.7') @@ -140,22 +108,20 @@ querydsl { jpa = true } - -jar { - manifest { - attributes 'Implementation-Title': 'Spring JPA Persistence, gradle example', 'Implementation-Version': version - } -} - -jacoco { - toolVersion = '0.7.6.201602180812' - reportsDir = file("$buildDir/reports/jacoco") +integTest.doFirst { + // It is required in order to run data bases in random ports. + // We need it for running tests from IDE and from command console but + // also it will be required by systems like Travis where we do not control + // the available ports. + def mysqlInfo = dockerCompose.servicesInfos.mysql + systemProperty 'DATABASE_PORT', mysqlInfo.ports[3306] } -jacocoTestReport { - reports { - xml.enabled false - csv.enabled false - html.destination "${buildDir}/jacoco/" - } +dockerCompose.isRequiredBy(integTest) +dockerCompose { + useComposeFiles = ['src/integTest/resources/docker/docker-compose.yml'] + captureContainersOutput = false + stopContainers = true + removeContainers = true + buildBeforeUp = false } diff --git a/SpringJava/Gradle/spring-jpa-persistence/settings.gradle b/SpringJava/Gradle/spring-jpa-persistence/settings.gradle deleted file mode 100644 index a07f836..0000000 --- a/SpringJava/Gradle/spring-jpa-persistence/settings.gradle +++ /dev/null @@ -1 +0,0 @@ -rootProject.name = 'gradle-spring-jpa-persistence' -- 2.1.4