From: Gustavo Martin Morcuende Date: Thu, 29 Dec 2016 14:17:06 +0000 (+0100) Subject: Using another gradle file for integTest task X-Git-Url: https://git.gumartinm.name/?a=commitdiff_plain;h=d6c7b5b8133ed4a07c21b186ab747a045771b896;p=JavaForFun Using another gradle file for integTest task --- diff --git a/SpringJava/Gradle/spring-jpa-persistence/build-integTest.gradle b/SpringJava/Gradle/spring-jpa-persistence/build-integTest.gradle new file mode 100644 index 0000000..e5fa060 --- /dev/null +++ b/SpringJava/Gradle/spring-jpa-persistence/build-integTest.gradle @@ -0,0 +1,45 @@ +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 + + testClassesDir = sourceSets.integTest.output.classesDir + classpath = sourceSets.integTest.runtimeClasspath + + testLogging { + events "PASSED", "FAILED", "SKIPPED" + } + + // 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 +} diff --git a/SpringJava/Gradle/spring-jpa-persistence/build.gradle b/SpringJava/Gradle/spring-jpa-persistence/build.gradle index abcc14c..c9c25f3 100644 --- a/SpringJava/Gradle/spring-jpa-persistence/build.gradle +++ b/SpringJava/Gradle/spring-jpa-persistence/build.gradle @@ -20,6 +20,8 @@ apply plugin: 'jacoco' apply plugin: 'com.ewerk.gradle.plugins.querydsl' apply plugin: 'docker-compose' +apply from: 'build-integTest.gradle' + targetCompatibility = 1.8 sourceCompatibility = 1.8 @@ -145,58 +147,6 @@ test { } -// ****************** CUSTOM TASK FOR INTEGRATION TESTS (something like maven-failsafe-plugin) ********************* - -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 - - testClassesDir = sourceSets.integTest.output.classesDir - classpath = sourceSets.integTest.runtimeClasspath - - testLogging { - events "PASSED", "FAILED", "SKIPPED" - } - - // 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 -} - -// ************************************************************************************************************************ - - - querydsl { library = 'com.querydsl:querydsl-apt:4.1.3' querydslSourcesDir = "$buildDir/generated-sources/querydsl"