Files
spring-cloud-open-service-b…/build.gradle
2021-04-20 12:05:17 -04:00

274 lines
7.0 KiB
Groovy

/*
* 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.
*/
plugins {
id 'io.spring.nohttp'
}
ext {
javaApi = "https://docs.oracle.com/javase/8/docs/api/"
if (JavaVersion.current() >= JavaVersion.VERSION_11) {
javaApi = "https://docs.oracle.com/en/java/javase/11/docs/api"
}
javadocLinks = [
javaApi,
"https://docs.spring.io/spring/docs/${springFrameworkVersion}/javadoc-api/",
] as String[]
}
description = "Spring Cloud Open Service Broker"
nohttp {
allowlistFile = rootProject.file("src/nohttp/allowlist.lines")
}
configure(allprojects) {
group = "org.springframework.cloud"
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'idea'
repositories {
mavenCentral()
maven { url 'https://repo.spring.io/release' }
}
if (version =~ /((-M|-RC)[0-9]+|-SNAPSHOT)$/) {
repositories {
maven { url 'https://repo.spring.io/milestone' }
}
}
if (version.endsWith('-SNAPSHOT')) {
repositories {
maven { url 'https://repo.spring.io/snapshot' }
}
}
configurations {
all {
exclude group: 'commons-logging', module: 'commons-logging'
}
}
}
// configure submodules with published java artifacts
configure(allprojects - [project(':spring-cloud-open-service-broker-acceptance-webflux'),
project(':spring-cloud-open-service-broker-acceptance-webmvc'),
project(':spring-cloud-open-service-broker-contract-tests'),
project(':spring-cloud-open-service-broker-docs')]) {
apply plugin: 'java-library'
apply from: "${rootProject.projectDir}/publish-maven.gradle"
}
// perform lint checks on all code, except for sample code used in docs
configure(allprojects - [project(':spring-cloud-open-service-broker-docs')]) {
apply plugin: 'checkstyle'
apply plugin: 'pmd'
checkstyle {
configFile = rootProject.file("src/checkstyle/checkstyle.xml")
configProperties = [config_path : rootProject.file("src/checkstyle")]
toolVersion = "${checkstyleVersion}"
showViolations = true
}
checkstyleMain {
source = "src/main/java"
}
checkstyleTest {
source = "src/test/java"
}
pmd {
toolVersion = "${pmdVersion}"
consoleOutput = true
}
pmdMain {
ruleSets = []
ruleSetFiles = rootProject.files("src/pmd/pmdRuleSet.xml")
source = "src/main/java"
}
pmdTest {
ruleSets = []
ruleSetFiles = rootProject.files("src/pmd/pmdTestRuleSet.xml")
source = "src/test/java"
}
test {
useJUnitPlatform()
testLogging {
events "passed", "skipped", "failed"
}
reports.junitXml.enabled = true
}
}
subprojects {
task dependencyReport(type: DependencyReportTask)
}
// configure java compilation for all java source
configure(subprojects - [project(':spring-cloud-starter-open-service-broker')]) {
[compileJava, compileTestJava]*.options*.encoding = "UTF-8"
def 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"
]
if (JavaVersion.current() == JavaVersion.VERSION_1_8) {
// Java 8 is the baseline, so don't fail on warnings with newer versions
compilerArgs << "-Werror"
}
[compileJava, compileTestJava]*.options*.compilerArgs = compilerArgs
// see https://github.com/reactor/BlockHound/issues/33
tasks.withType(Test).all {
if (JavaVersion.current() >= JavaVersion.VERSION_13) {
jvmArgs += [
"-XX:+AllowRedefinitionToAddDeleteMethods"
]
}
}
javadoc {
description = "Generates project-level javadoc for use in -javadoc jar"
options.memberLevel = JavadocMemberLevel.PROTECTED
options.author = true
options.header = project.name
options.use = true
options.links(javadocLinks)
options.addStringOption('Xdoclint:none', '-quiet')
if (JavaVersion.current() == JavaVersion.VERSION_11) {
options.addBooleanOption('-no-module-directories', true)
}
}
// see https://docs.gradle.org/current/userguide/java_plugin.html
java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
disableAutoTargetJvm()
withSourcesJar()
withJavadocJar()
// define 'optional' dependency feature variant
// see https://docs.gradle.org/current/userguide/feature_variants.html
registerFeature('optional') {
usingSourceSet(sourceSets.main)
}
}
task testsJar(type: Jar) {
archiveClassifier.set("tests")
from sourceSets.test.output
}
artifacts {
archives testsJar
}
}
// consolidate and package the javadoc, apidoc and sources
configure(rootProject) {
task sourcesJar(type: Jar, dependsOn: classes) {
archiveClassifier.set("sources")
from sourceSets.main.allSource
}
task javadocJar(type: Jar, dependsOn: javadoc) {
archiveClassifier.set("javadoc")
from javadoc.destinationDir
}
// filter unwanted subprojects from published javadoc
def sourceProjects = subprojects - [project(':spring-cloud-open-service-broker-acceptance-webflux'),
project(':spring-cloud-open-service-broker-acceptance-webmvc'),
project(':spring-cloud-open-service-broker-contract-tests'),
project(':spring-cloud-open-service-broker-docs')]
task apidocs(type: Javadoc) {
group = "Documentation"
description = "Generates aggregated Javadoc API documentation."
title = "${rootProject.description} ${version} API"
options.memberLevel = JavadocMemberLevel.PROTECTED
options.author = true
options.header = rootProject.description
options.links(javadocLinks)
source sourceProjects.collect { project ->
project.sourceSets.main.allJava
}
classpath = files(sourceProjects.collect { project ->
project.sourceSets.main.compileClasspath
})
maxMemory = "1024m"
destinationDir = new File(buildDir, "apidocs")
}
task docsZip(type: Zip, dependsOn: [':spring-cloud-open-service-broker-docs:asciidoctor']) {
group = "Distribution"
archiveClassifier.set("docs")
description = "Builds -${archiveClassifier} archive containing api and reference " +
"for deployment."
from(apidocs) {
into "apidocs"
}
from(project.tasks.findByPath(':spring-cloud-open-service-broker-docs:asciidoctor')) {
into 'reference'
}
}
publishing {
publications {
mavenJava(MavenPublication) {
artifact sourcesJar
artifact javadocJar
artifact docsZip
}
}
}
task dist(dependsOn: assemble) {
group = "Distribution"
description = "Builds -dist and -docs distribution archives."
}
}
wrapper {
gradleVersion = "6.8.3"
distributionType = Wrapper.DistributionType.ALL
}