Files
spring-cloud-app-broker/build.gradle
Gareth Clay 6fed6572cb Fix CI log interleaving
* Stop logs from parallel tests interleaving with each other
* Cut down on noise and reduce page load times by only logging std
streams for tests that fail
* @Validated AT cloud foundry configuration
* Remove unnecessary Gradle tasks from the AT job since they've already
been performed as part of `build`
* Stop tests and javadoc Gradle tasks being run against docs subproject
and causing failures

#380
2020-06-09 13:52:13 -04:00

370 lines
11 KiB
Groovy

import java.util.concurrent.ConcurrentHashMap
/*
* Copyright 2002-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
buildscript {
repositories {
maven { url "https://repo.spring.io/plugins-release" }
}
dependencies {
classpath("io.spring.gradle:propdeps-plugin:0.0.10.RELEASE")
classpath("io.spring.gradle:dependency-management-plugin:1.0.9.RELEASE")
classpath("org.jfrog.buildinfo:build-info-extractor-gradle:4.9.9")
classpath("io.spring.nohttp:nohttp-gradle:0.0.4.RELEASE")
}
}
ext {
springBootVersion = project.findProperty("springBootVersion") ?: "2.2.7.RELEASE"
springFrameworkVersion = project.findProperty("springFrameworkVersion") ?: "5.2.6.RELEASE"
reactorVersion = project.findProperty("reactorVersion") ?: "Dysprosium-SR7"
openServiceBrokerVersion = "3.1.1.RELEASE"
springCredhubVersion = "2.1.1.RELEASE"
cfJavaClientVersion = "4.7.0.RELEASE"
blockHoundVersion = "1.0.3.RELEASE"
junitPlatformLauncherVersion = "1.6.2"
checkstyleVersion = "8.33"
pmdVersion = "6.24.0"
javadocLinks = [
"https://docs.oracle.com/javase/8/docs/api/",
"https://docs.spring.io/spring/docs/${springFrameworkVersion}/javadoc-api/",
] as String[]
}
//override managed Spring Boot versions
if (project.hasProperty("springFrameworkVersion")) {
ext['spring-framework.version'] = ext.springFrameworkVersion
}
if (project.hasProperty("reactorVersion")) {
ext['reactor-bom.version'] = ext.reactorVersion
}
if (!project.hasProperty("onlyShowStandardStreamsOnTestFailure")) {
ext.onlyShowStandardStreamsOnTestFailure = false
}
apply plugin: "io.spring.nohttp"
configure(allprojects) {
group = "org.springframework.cloud"
apply plugin: "eclipse"
apply plugin: "idea"
apply plugin: "jacoco"
apply plugin: "propdeps"
apply plugin: "propdeps-idea"
apply plugin: "propdeps-eclipse"
apply plugin: "io.spring.dependency-management"
afterEvaluate { subproject ->
if (subproject.description == null || subproject.description.isEmpty()) {
throw new InvalidUserDataException("A project description is required for publishing to maven central")
}
tasks.withType(Test).forEach { Test task ->
task.with {
// enable JUnit 5
useJUnitPlatform()
scanForTestClasses = true
group = "verification"
testLogging {
exceptionFormat = "full"
events = ["passed", "skipped", "failed"]
showStandardStreams = !project.onlyShowStandardStreamsOnTestFailure
}
if (project.onlyShowStandardStreamsOnTestFailure) {
Map<String, StringBuilder> testOutput = new ConcurrentHashMap<>()
onOutput { TestDescriptor descriptor, TestOutputEvent event ->
testOutput.compute(descriptor.displayName, { k, v ->
v == null ? new StringBuilder(event.message) : v.append(event.message)
})
}
afterTest { TestDescriptor descriptor, TestResult result ->
if (result.resultType == TestResult.ResultType.FAILURE && testOutput.containsKey(descriptor.displayName)) {
logger.lifecycle("\n\n${testOutput.get(descriptor.displayName)}")
testOutput.remove(descriptor.displayName)
}
}
}
// print failed tests after the execution
def failedTests = []
afterTest { test, result ->
if (result.resultType == TestResult.ResultType.FAILURE) {
failedTests << test
}
}
// create a summary after the execution
afterSuite { desc, result ->
if (!desc.parent) {
println "\nTest result: ${result.resultType}"
println "Test summary: ${result.testCount} tests, " +
"${result.successfulTestCount} succeeded, " +
"${result.failedTestCount} failed, " +
"${result.skippedTestCount} skipped"
failedTests.each { test -> println "FAILED test: ${test.className} > ${test.name}" }
}
}
}
}
}
apply from: "${rootProject.projectDir}/publish-maven.gradle"
repositories {
mavenCentral()
maven { url "https://repo.spring.io/release" }
if (!version.endsWith('RELEASE')) {
maven { url "https://repo.spring.io/milestone" }
}
if (version.endsWith('BUILD-SNAPSHOT') || project.hasProperty("springFrameworkVersion") ||
project.hasProperty("springBootVersion") || project.hasProperty("reactorVersion")) {
maven { url "https://repo.spring.io/snapshot" }
}
}
}
configure(allprojects - [project(":spring-cloud-app-broker-docs")]) {
apply plugin: "checkstyle"
apply plugin: "pmd"
checkstyle {
configFile = file("${project.rootDir}/src/checkstyle/checkstyle.xml")
toolVersion = "${checkstyleVersion}"
showViolations = true
}
checkstyleMain {
source = "src/main/java"
}
checkstyleTest {
source = "src/test/java"
}
pmd {
toolVersion = "${pmdVersion}"
consoleOutput = true
}
pmdMain {
ruleSets = []
ruleSetFiles = files("${project.rootDir}/src/pmd/pmdRuleSet.xml")
source = "src/main/java"
}
pmdTest {
ruleSets = []
ruleSetFiles = files("${project.rootDir}/src/pmd/pmdTestRuleSet.xml")
source = "src/test/java"
}
}
subprojects {
task allDependencyInsight(type: DependencyInsightReportTask)
task dependencyReport(type: DependencyReportTask)
}
configure(subprojects - [project(":spring-cloud-starter-app-broker"),
project(":spring-cloud-starter-app-broker-cloudfoundry")]) {
sourceCompatibility = 1.8
targetCompatibility = 1.8
[compileJava, compileTestJava]*.options*.encoding = "UTF-8"
[compileJava, compileTestJava]*.options*.compilerArgs = [
"-Xlint:serial",
"-Xlint:varargs",
"-Xlint:cast",
"-Xlint:classfile",
"-Xlint:dep-ann",
"-Xlint:divzero",
"-Xlint:empty",
"-Xlint:finally",
"-Xlint:overrides",
"-Xlint:path",
"-Xlint:-processing",
"-Xlint:static",
"-Xlint:try",
"-Xlint:fallthrough",
"-Xlint:rawtypes",
"-Xlint:deprecation",
"-Xlint:unchecked",
"-Xlint:-options",
"-Werror"
]
jar {
manifest.attributes["Created-By"] =
"${System.getProperty("java.version")} (${System.getProperty("java.specification.vendor")})"
manifest.attributes["Implementation-Title"] = project.name
manifest.attributes["Implementation-Version"] = project.version
from("${rootProject.projectDir}/src/dist") {
include "license.txt"
include "notice.txt"
into "META-INF"
expand(copyright: new Date().format("yyyy"), version: project.version)
}
}
javadoc {
description = "Generates project-level javadoc for use in -javadoc jar"
options.memberLevel = org.gradle.external.javadoc.JavadocMemberLevel.PROTECTED
options.author = true
options.header = project.name
options.links(javadocLinks)
options.addStringOption('Xdoclint:none', '-quiet')
}
task sourcesJar(type: Jar, dependsOn:classes) {
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
archiveClassifier = "sources"
from sourceSets.main.allJava
}
task javadocJar(type: Jar) {
archiveClassifier = "javadoc"
from javadoc
}
artifacts {
archives sourcesJar
archives javadocJar
}
configurations {
// exclude JUnit 4 globally, in favor of JUnit 5
testImplementation.exclude group: "junit", module: "junit"
}
}
configure(rootProject) {
description = "Spring Cloud App Broker"
// don't publish the default jar for the root project
configurations.archives.artifacts.clear()
dependencies {
// for integration tests
}
task api(type: Javadoc) {
group = "Documentation"
description = "Generates aggregated Javadoc API documentation."
title = "${rootProject.description} ${version} API"
options.memberLevel = org.gradle.external.javadoc.JavadocMemberLevel.PROTECTED
options.author = true
options.header = rootProject.description
options.links(javadocLinks)
options.addStringOption('Xdoclint:none', '-quiet')
source subprojects.collect { project ->
project.sourceSets.main.allJava
}
classpath = files(subprojects.collect { project ->
project.sourceSets.main.compileClasspath
})
exclude 'org/springframework/cloud/appbroker/integration/**',
'org/springframework/cloud/appbroker/acceptance/**'
maxMemory = "1024m"
destinationDir = new File(buildDir, "api")
}
task docsZip(type: Zip, dependsOn: [':spring-cloud-app-broker-docs:asciidoctor']) {
group = "Distribution"
archiveClassifier = "docs"
description = "Builds -${archiveClassifier} archive containing api and reference " +
"for deployment."
from (api) { into "api" }
from(project.tasks.findByPath(':spring-cloud-app-broker-docs:asciidoctor')) {
into 'reference'
}
from(project.tasks.findByPath(':spring-cloud-app-broker-docs:asciidoctorPdf')) {
into 'reference'
}
}
task distZip(type: Zip, dependsOn: docsZip) {
group = "Distribution"
archiveClassifier = "dist"
description = "Builds -${archiveClassifier} archive, containing all jars and docs, " +
"suitable for community download page."
def baseDir = "${project.name}-${project.version}"
from(zipTree(docsZip.archivePath)) { into "${baseDir}/docs" }
def mainSubprojects = subprojects - [project(":spring-cloud-starter-app-broker"),
project(":spring-cloud-starter-app-broker-cloudfoundry"),
project(":spring-cloud-app-broker-docs"),
project(":spring-cloud-app-broker-acceptance-tests"),
project(":spring-cloud-app-broker-integration-tests")]
mainSubprojects.each { subproject ->
into ("${baseDir}/libs") {
from subproject.jar
if (subproject.tasks.findByPath("sourcesJar")) {
from subproject.sourcesJar
}
if (subproject.tasks.findByPath("javadocJar")) {
from subproject.javadocJar
}
}
}
}
artifacts {
archives docsZip
archives distZip
}
}
task codeCoverageReport(type: JacocoReport) {
executionData fileTree(project.rootDir.absolutePath).include("**/build/jacoco/*.exec")
subprojects.each { subproject ->
if (subproject.name.endsWith("-integration-tests") || subproject.name.endsWith("-acceptance-tests")) {
// Work-around for issue with jacoco and multiple-release jar files
// (like Log4J 2.10 and above)
// see https://github.com/jacoco/jacoco/issues/407
getSourceDirectories().from(subproject.sourceSets.main.java)
getClassDirectories().from(subproject.sourceSets.main.output.classesDirs)
} else {
sourceSets subproject.sourceSets.main
}
}
reports {
xml.enabled true
xml.destination new File("${buildDir}/reports/jacoco/report.xml")
html.enabled false
csv.enabled false
}
}
codeCoverageReport.dependsOn {
subprojects*.test
}
wrapper {
gradleVersion = "6.3"
}