199 lines
4.9 KiB
Groovy
199 lines
4.9 KiB
Groovy
apply plugin: 'java'
|
|
apply plugin: 'groovy'
|
|
|
|
sourceCompatibility = 1.7
|
|
targetCompatibility = 1.7
|
|
|
|
apply plugin: "io.franzbecker.gradle-lombok"
|
|
|
|
lombok { // optional: values below are the defaults
|
|
version = versions.lombok
|
|
sha256 = ""
|
|
}
|
|
|
|
apply plugin: "net.ltgt.errorprone"
|
|
tasks.withType(JavaCompile) {
|
|
options.compilerArgs += ['-Xep:FutureReturnValueIgnored:OFF']
|
|
// workaround for: https://github.com/google/error-prone/issues/780
|
|
options.compilerArgs += ['-Xep:ParameterName:OFF']
|
|
options.compilerArgs += ['-XepDisableWarningsInGeneratedCode']
|
|
}
|
|
|
|
apply plugin: "eclipse"
|
|
eclipse {
|
|
classpath {
|
|
downloadSources = true
|
|
downloadJavadoc = true
|
|
}
|
|
}
|
|
if (configurations.find { it.name == 'jmh' }) {
|
|
eclipse.classpath.plusConfigurations += [configurations.jmh]
|
|
}
|
|
|
|
jar {
|
|
/*
|
|
Make Jar build fail on duplicate files
|
|
|
|
By default Gradle Jar task can put multiple files with the same name
|
|
into a Jar. This may lead to confusion. For example if auto-service
|
|
annotation processing creates files with same name in `scala` and
|
|
`java` directory this would result in Jar having two files with the
|
|
same name in it. Which in turn would result in only one of those
|
|
files being actually considered when that Jar is used leading to very
|
|
confusing failures.
|
|
|
|
Instead we should 'fail early' and avoid building such Jars.
|
|
*/
|
|
duplicatesStrategy = 'fail'
|
|
}
|
|
|
|
task packageSources(type: Jar) {
|
|
classifier = 'sources'
|
|
from sourceSets.main.allSource
|
|
}
|
|
artifacts.archives packageSources
|
|
|
|
repositories {
|
|
mavenLocal()
|
|
jcenter()
|
|
mavenCentral()
|
|
}
|
|
|
|
dependencies {
|
|
testCompile deps.junit
|
|
testCompile group: 'org.assertj', name: 'assertj-core', version: '2.9.+'
|
|
testCompile group: 'org.mockito', name: 'mockito-core', version: '2.19.0'
|
|
|
|
testCompile deps.spock
|
|
testCompile deps.groovy
|
|
testCompile deps.testLogging
|
|
testCompile 'info.solidsoft.spock:spock-global-unroll:0.5.1'
|
|
testCompile group: 'com.github.stefanbirkner', name: 'system-rules', version: '1.17.1'
|
|
|
|
testCompile group: 'com.anotherchrisberry', name: 'spock-retry', version: '0.6.4'
|
|
}
|
|
|
|
tasks.withType(Javadoc) {
|
|
options.encoding = "utf-8"
|
|
options.docEncoding = "utf-8"
|
|
options.charSet = "utf-8"
|
|
|
|
options.addStringOption('Xdoclint:none', '-quiet')
|
|
|
|
doFirst {
|
|
if (project.ext.has("apiLinks")) {
|
|
options.links(*project.apiLinks)
|
|
}
|
|
}
|
|
}
|
|
|
|
javadoc {
|
|
source = sourceSets.main.allJava
|
|
classpath = configurations.compileClasspath
|
|
|
|
options {
|
|
setMemberLevel JavadocMemberLevel.PUBLIC
|
|
setAuthor true
|
|
|
|
links "https://docs.oracle.com/javase/8/docs/api/"
|
|
}
|
|
}
|
|
|
|
task sourceJar(type: Jar) {
|
|
from sourceSets.main.allJava
|
|
classifier = 'sources'
|
|
}
|
|
|
|
task javaDocJar(type: Jar, dependsOn: javadoc) {
|
|
from javadoc.destinationDir
|
|
classifier = 'javadoc'
|
|
}
|
|
|
|
artifacts {
|
|
archives sourceJar
|
|
archives javaDocJar
|
|
}
|
|
|
|
if (project.plugins.hasPlugin('com.github.johnrengelman.shadow')) {
|
|
// Remove the no-deps jar from the archives to prevent publication
|
|
configurations.archives.with {
|
|
artifacts.remove artifacts.find {
|
|
if (it.hasProperty("delegate")) {
|
|
it.delegate.archiveTask.is jar
|
|
} else {
|
|
it.archiveTask.is jar
|
|
}
|
|
}
|
|
}
|
|
artifacts {
|
|
archives shadowJar
|
|
}
|
|
}
|
|
|
|
if (project.hasProperty("removeJarVersionNumbers") && removeJarVersionNumbers) {
|
|
tasks.withType(AbstractArchiveTask) {
|
|
version = null
|
|
}
|
|
}
|
|
|
|
|
|
project.ext.testJava8Only = []
|
|
project.ext.testJava8Minimum = []
|
|
|
|
tasks.withType(Test) {
|
|
if (name.endsWith("Java7") || name.endsWith("Java9") || name.endsWith("Java10")) {
|
|
return
|
|
}
|
|
|
|
def cloned = it
|
|
|
|
def java7Home = System.getenv("JAVA7_HOME")
|
|
if (java7Home != null) {
|
|
def testJ7 = task "${cloned.name}Java7"(type: cloned.class) {
|
|
description "Runs $cloned.name under java 7"
|
|
executable = "$java7Home/bin/java"
|
|
afterEvaluate {
|
|
exclude project.testJava8Only
|
|
exclude project.testJava8Minimum
|
|
}
|
|
}
|
|
tasks.check.dependsOn testJ7
|
|
}
|
|
|
|
def java9Home = System.getenv("JAVA9_HOME")
|
|
if (java9Home != null) {
|
|
def testJ9 = task "${cloned.name}Java9"(type: cloned.class) {
|
|
description "Runs $cloned.name under java 9"
|
|
executable = "$java9Home/bin/java"
|
|
project.afterEvaluate {
|
|
exclude project.testJava8Only
|
|
}
|
|
}
|
|
tasks.check.dependsOn testJ9
|
|
}
|
|
|
|
def java10Home = System.getenv("JAVA10_HOME")
|
|
if (java10Home != null) {
|
|
def testJ10 = task "${cloned.name}Java10"(type: cloned.class) {
|
|
description "Runs $cloned.name under java 10"
|
|
executable = "$java10Home/bin/java"
|
|
project.afterEvaluate {
|
|
exclude project.testJava8Only
|
|
}
|
|
}
|
|
tasks.check.dependsOn testJ10
|
|
}
|
|
}
|
|
|
|
apply from: "$rootDir/gradle/checkstyle.gradle"
|
|
apply from: "$rootDir/gradle/codenarc.gradle"
|
|
apply from: "$rootDir/gradle/jacoco.gradle"
|
|
|
|
plugins.withType(BasePlugin) {
|
|
project.afterEvaluate {
|
|
def deleteTasks = tasks.withType(Delete) + project.tasks.findByPath('clean')
|
|
def otherTasks = tasks - deleteTasks
|
|
otherTasks*.mustRunAfter deleteTasks
|
|
}
|
|
}
|