+
+// ***************** 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
+
+// ***************** USING PROPERTIES FOR VERSIONING, WE MANAGE FROM HERE THE SUBPROJECTS' DEPENDENCIES *****************
project.ext {
// Compile dependencies
}
+// 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'
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'
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'
}
}
}
+
+ // ***************** 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}")
}
+ // ***************** COMMON PLUGINS *****************
buildscript {
repositories {
mavenCentral()
}
}
+ // ***************** MANIFEST FILE *****************
jar {
manifest {
attributes('Implementation-Title': 'Spring JPA Persistence, gradle example',
}
- // Coverage
+ // ***************** COVERAGE *****************
apply plugin: 'jacoco'
apply from: "$rootProject.projectDir/build-test.gradle"
apply from: "$rootProject.projectDir/build-integTest.gradle"
}
+ // ***************** JAVADOC *****************
javadoc {
source = sourceSets.main.allJava
classpath = configurations.compile