From: Gustavo Martin Morcuende Date: Sun, 22 Jan 2017 19:59:08 +0000 (+0100) Subject: Comments in Gradle build files X-Git-Url: https://git.gumartinm.name/?a=commitdiff_plain;h=1dce421ca2f3b6f7230c71b448052bdb7eec317c;p=JavaForFun Comments in Gradle build files --- diff --git a/SpringJava/Gradle/build-integTest.gradle b/SpringJava/Gradle/build-integTest.gradle index 43604e9..177e2ed 100644 --- a/SpringJava/Gradle/build-integTest.gradle +++ b/SpringJava/Gradle/build-integTest.gradle @@ -1,3 +1,11 @@ + +// ***************** INTEGRATION TESTS, COMMON CONFIGURATION ***************** + +// Using another directory for integration tests enable me to run all the unit tests quickly from my IDE (InteliJ or Eclipse) +// If I had in the same directory both types of test when I want to run all the unit tests from the root of the src/test directory +// I would be also running the integration tests, and they are slower :( + +// Integration tests will be located in this path: src/integTest sourceSets { integTest { compileClasspath += main.output + test.output diff --git a/SpringJava/Gradle/build-test.gradle b/SpringJava/Gradle/build-test.gradle index 2d043e8..5ee6dad 100644 --- a/SpringJava/Gradle/build-test.gradle +++ b/SpringJava/Gradle/build-test.gradle @@ -1,3 +1,6 @@ + +// ***************** UNIT TESTS, COMMON CONFIGURATION ***************** + test { // explicitly include or exclude tests diff --git a/SpringJava/Gradle/build.gradle b/SpringJava/Gradle/build.gradle index 73fc112..be5d22e 100644 --- a/SpringJava/Gradle/build.gradle +++ b/SpringJava/Gradle/build.gradle @@ -1,3 +1,5 @@ + +// ***************** USING PROPERTIES FOR VERSIONING, WE MANAGE FROM HERE THE SUBPROJECTS' DEPENDENCIES ***************** project.ext { // Compile dependencies @@ -46,6 +48,7 @@ project.ext { } +// Be aware: I am not using allprojects because the main build.gradle should not create a jar file :) subprojects { apply plugin: 'java' apply plugin: 'idea' @@ -61,17 +64,22 @@ subprojects { sourceCompatibility = 1.8 + // ***************** COMMON REPOSITORIES FOR DEPENDENCIES ***************** repositories { mavenCentral() maven { url 'https://dl.bintray.com/palantir/releases' } } + + // ***************** PUBLISH TO REPOSITORY ***************** + // Calls javadoc plugin and creates jar with the generated docs task javadocJar(type: Jar) { from javadoc classifier 'javadoc' } + // Calls java plugin and creates jar with the sources task sourceJar(type: Jar) { from sourceSets.main.java classifier 'sources' @@ -80,15 +88,18 @@ subprojects { publishing { publications { mavenJava(MavenPublication) { + // Publishes war or jar file depending on whether we are using the war plugin. if (plugins.withType(WarPlugin)) { from components.web } else { from components.java } + // Publishes jar with sources artifact sourceJar { classifier 'sources' } + // Publishes jar with javadoc artifact javadocJar { classifier 'javadoc' } @@ -110,6 +121,8 @@ subprojects { } } + + // ***************** COMMON DEPENDENCIES ***************** dependencies { // 1/3 Required dependency for log4j 2 with slf4j: binding between log4j2 and slf4j compile("org.apache.logging.log4j:log4j-slf4j-impl:${slf4jVersion}") @@ -134,6 +147,7 @@ subprojects { } + // ***************** COMMON PLUGINS ***************** buildscript { repositories { mavenCentral() @@ -144,6 +158,7 @@ subprojects { } } + // ***************** MANIFEST FILE ***************** jar { manifest { attributes('Implementation-Title': 'Spring JPA Persistence, gradle example', @@ -156,7 +171,7 @@ subprojects { } - // Coverage + // ***************** COVERAGE ***************** apply plugin: 'jacoco' apply from: "$rootProject.projectDir/build-test.gradle" apply from: "$rootProject.projectDir/build-integTest.gradle" @@ -175,6 +190,7 @@ subprojects { } + // ***************** JAVADOC ***************** javadoc { source = sourceSets.main.allJava classpath = configurations.compile