Files
spring-kafka/build.gradle
2020-06-10 10:33:00 -04:00

412 lines
11 KiB
Groovy

buildscript {
ext.kotlinVersion = '1.3.30'
repositories {
maven { url 'https://repo.spring.io/plugins-release' }
}
dependencies {
classpath 'org.asciidoctor:asciidoctorj-pdf:1.5.0-alpha.16'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
classpath "org.jetbrains.kotlin:kotlin-allopen:$kotlinVersion"
}
}
plugins {
id 'org.sonarqube' version '2.7'
id 'base'
id 'project-report'
id 'idea'
id 'org.asciidoctor.convert' version '1.5.10'
id 'org.ajoberstar.grgit' version '3.1.1'
}
description = 'Spring Kafka'
ext {
linkHomepage = 'https://github.com/spring-projects/spring-kafka'
linkCi = 'https://build.spring.io/browse/SK'
linkIssue = 'https://github.com/spring-projects/spring-kafka/issues'
linkScmUrl = 'https://github.com/spring-projects/spring-kafka'
linkScmConnection = 'https://github.com/spring-projects/spring-kafka.git'
linkScmDevConnection = 'git@github.com:spring-projects/spring-kafka.git'
docResourcesVersion = '0.1.0.RELEASE'
modifiedFiles =
files(grgit.status().unstaged.modified).filter{ f -> f.name.endsWith('.java') || f.name.endsWith('.kt') }
}
allprojects {
group = 'org.springframework.kafka'
repositories {
maven { url 'https://repo.spring.io/libs-milestone' }
if (version.endsWith('BUILD-SNAPSHOT')) {
maven { url 'https://repo.spring.io/libs-snapshot' }
}
}
}
subprojects { subproject ->
apply plugin: 'java'
apply from: "${rootProject.projectDir}/publish-maven.gradle"
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'jacoco'
apply plugin: 'checkstyle'
apply plugin: 'kotlin'
apply plugin: 'kotlin-spring'
compileJava {
sourceCompatibility = 1.8
targetCompatibility = 1.8
}
compileTestKotlin {
kotlinOptions {
jvmTarget = '1.8'
}
}
ext {
assertjVersion = '3.12.2'
googleJsr305Version = '3.0.2'
hamcrestVersion = '1.3'
hibernateValidationVersion = '6.0.19.Final'
jacksonVersion = '2.9.10'
jacksonDataBindVersion = '2.9.10.4'
jaywayJsonPathVersion = '2.4.0'
junit4Version = '4.12'
junitJupiterVersion = '5.4.2'
junitPlatformVersion = '1.4.2'
kafkaVersion = '2.0.1'
log4jVersion = '2.11.2'
mockitoVersion = '2.26.0'
scalaVersion = '2.11'
springDataCommonsVersion = '2.1.18.RELEASE'
springRetryVersion = '1.2.5.RELEASE'
springVersion = '5.1.16.RELEASE'
idPrefix = 'kafka'
}
eclipse.project.natures += 'org.springframework.ide.eclipse.core.springnature'
jacoco {
toolVersion = '0.8.4'
}
// dependencies that are common across all java projects
dependencies {
compileOnly "com.google.code.findbugs:jsr305:$googleJsr305Version"
testCompile "org.junit.jupiter:junit-jupiter-api:$junitJupiterVersion"
testRuntime "org.junit.jupiter:junit-jupiter-engine:$junitJupiterVersion"
testRuntime "org.junit.platform:junit-platform-launcher:$junitPlatformVersion"
// To support JUnit 4 tests
testRuntime "org.junit.vintage:junit-vintage-engine:$junitJupiterVersion"
// To avoid compiler warnings about @API annotations in JUnit code
testCompileOnly 'org.apiguardian:apiguardian-api:1.0.0'
testRuntime "org.apache.logging.log4j:log4j-slf4j-impl:$log4jVersion"
testCompile "org.jetbrains.kotlin:kotlin-reflect"
testCompile "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
}
// enable all compiler warnings; individual projects may customize further
[compileJava, compileTestJava]*.options*.compilerArgs = ['-Xlint:all,-options']
test {
// suppress all console output during testing unless running `gradle -i`
logging.captureStandardOutput(LogLevel.INFO)
maxHeapSize = '1024m'
jacoco {
append = false
destinationFile = file("$buildDir/jacoco.exec")
}
useJUnitPlatform()
}
checkstyle {
configFile = file("${rootDir}/src/checkstyle/checkstyle.xml")
toolVersion = "8.20"
}
jacocoTestReport {
reports {
xml.enabled false
csv.enabled false
html.destination file("${buildDir}/reports/jacoco/html")
}
}
build.dependsOn jacocoTestReport
task updateCopyrights {
onlyIf { !System.getenv('TRAVIS') && !System.getenv('bamboo_buildKey') }
inputs.files(modifiedFiles.filter { f -> f.path.contains(subproject.name) })
outputs.dir('build')
doLast {
def now = Calendar.instance.get(Calendar.YEAR) as String
inputs.files.each { file ->
def line
file.withReader { reader ->
while (line = reader.readLine()) {
def matcher = line =~ /Copyright (20\d\d)-?(20\d\d)?/
if (matcher.count) {
def beginningYear = matcher[0][1]
if (now != beginningYear && now != matcher[0][2]) {
def years = "$beginningYear-$now"
def sourceCode = file.text
sourceCode = sourceCode.replaceFirst(/20\d\d(-20\d\d)?/, years)
file.write(sourceCode)
println "Copyright updated for file: $file"
}
break
}
}
}
}
}
}
processResources.dependsOn updateCopyrights
task sourcesJar(type: Jar) {
classifier = 'sources'
from sourceSets.main.allJava
}
task javadocJar(type: Jar) {
classifier = 'javadoc'
from javadoc
}
jar {
manifest {
attributes(
'Implementation-Version': version,
'Created-By': "JDK ${System.properties['java.version']} (${System.properties['java.specification.vendor']})",
'Implementation-Title': subproject.name,
'Implementation-Vendor-Id': subproject.group,
'Implementation-Vendor': 'Pivotal Software, Inc.',
'Implementation-URL': linkHomepage,
'Automatic-Module-Name': subproject.name.replace('-', '.') // for Jigsaw
)
}
from("${rootProject.projectDir}/src/dist") {
include "license.txt"
include "notice.txt"
into "META-INF"
expand(copyright: new Date().format("yyyy"), version: project.version)
}
}
artifacts {
archives sourcesJar
archives javadocJar
}
}
project ('spring-kafka') {
description = 'Spring Kafka Support'
dependencies {
compile "org.springframework:spring-context:$springVersion"
compile "org.springframework:spring-messaging:$springVersion"
compile "org.springframework:spring-tx:$springVersion"
compile ("org.springframework.retry:spring-retry:$springRetryVersion") {
exclude group: 'org.springframework', module: 'spring-core'
}
compile "org.apache.kafka:kafka-clients:$kafkaVersion"
compile ("org.apache.kafka:kafka-streams:$kafkaVersion", optional)
compile ("com.fasterxml.jackson.core:jackson-core:$jacksonVersion", optional)
compile ("com.fasterxml.jackson.core:jackson-databind:$jacksonDataBindVersion", optional)
// Spring Data projection message binding support
compile ("org.springframework.data:spring-data-commons:$springDataCommonsVersion", optional)
compile ("com.jayway.jsonpath:json-path:$jaywayJsonPathVersion", optional)
testCompile project (":spring-kafka-test")
testCompile "org.hibernate.validator:hibernate-validator:$hibernateValidationVersion"
}
}
project ('spring-kafka-test') {
description = 'Spring Kafka Test Support'
dependencies {
compile "org.springframework:spring-context:$springVersion"
compile "org.springframework:spring-test:$springVersion"
compile "org.springframework.retry:spring-retry:$springRetryVersion"
compile ("org.apache.kafka:kafka-clients:$kafkaVersion:test")
compile "org.apache.kafka:kafka_$scalaVersion:$kafkaVersion"
compile "org.apache.kafka:kafka_$scalaVersion:$kafkaVersion:test"
compile ("org.hamcrest:hamcrest-all:$hamcrestVersion", optional)
compile ("org.mockito:mockito-core:$mockitoVersion", optional)
compile ("junit:junit:$junit4Version", optional)
compile ("org.assertj:assertj-core:$assertjVersion", optional)
compile ("org.apache.logging.log4j:log4j-core:$log4jVersion", optional)
}
}
configurations {
docs
}
dependencies {
docs "io.spring.docresources:spring-doc-resources:${docResourcesVersion}@zip"
}
task prepareAsciidocBuild(type: Sync) {
dependsOn configurations.docs
from {
configurations.docs.collect { zipTree(it) }
}
from 'src/reference/asciidoc/'
into "$buildDir/asciidoc"
}
asciidoctor {
dependsOn 'prepareAsciidocBuild'
sourceDir "$buildDir/asciidoc"
sources {
include 'index.adoc'
}
resources {
from(sourceDir) {
include 'images/*', 'css/*', 'js/**'
}
}
backends = ['html5', 'pdf']
options doctype: 'book', eruby: 'erubis'
attributes 'icons': 'font',
'idprefix': '',
'idseparator': '-',
docinfo: 'shared',
sectanchors: '',
sectnums: '',
stylesdir: 'css/',
stylesheet: 'spring.css',
'linkcss': true,
'source-highlighter=highlight.js',
'highlightjsdir=js/highlight',
'highlightjs-theme=atom-one-dark-reasonable',
'project-version': project.version,
'allow-uri-read': ''
}
task reference(dependsOn: asciidoctor) {
group = 'Documentation'
description = 'Generate the reference documentation'
}
reference.onlyIf { "$System.env.NO_REFERENCE_TASK" != 'true' || project.hasProperty('ignoreEnvToStopReference') }
sonarqube {
properties {
property "sonar.jacoco.reportPath", "${buildDir.name}/jacoco.exec"
property "sonar.links.homepage", linkHomepage
property "sonar.links.ci", linkCi
property "sonar.links.issue", linkIssue
property "sonar.links.scm", linkScmUrl
property "sonar.links.scm_dev", linkScmDevConnection
property "sonar.java.coveragePlugin", "jacoco"
}
}
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.overview = 'src/api/overview.html'
source subprojects.collect { project ->
project.sourceSets.main.allJava
}
classpath = files(subprojects.collect { project ->
project.sourceSets.main.compileClasspath
})
destinationDir = new File(buildDir, "api")
}
task docsZip(type: Zip, dependsOn: [reference]) {
group = 'Distribution'
classifier = 'docs'
description = "Builds -${classifier} archive containing api and reference " +
"for deployment at static.spring.io/spring-kafka/docs."
from('src/dist') {
include 'changelog.txt'
}
from(api) {
into 'api'
}
from ('build/asciidoc/html5') {
into 'reference/html'
}
from ('build/asciidoc/pdf') {
include 'index.pdf'
into 'reference/pdf'
}
}
task distZip(type: Zip, dependsOn: [docsZip]) { //, schemaZip]) {
group = 'Distribution'
classifier = 'dist'
description = "Builds -${classifier} archive, containing all jars and docs, " +
"suitable for community download page."
ext.baseDir = "${project.name}-${project.version}";
from('src/dist') {
include 'readme.txt'
include 'license.txt'
include 'notice.txt'
into "${baseDir}"
}
from(zipTree(docsZip.archivePath)) {
into "${baseDir}/docs"
}
subprojects.each { subproject ->
into ("${baseDir}/libs") {
from subproject.jar
from subproject.sourcesJar
from subproject.javadocJar
}
}
}
artifacts {
archives distZip
archives docsZip
}
task dist(dependsOn: assemble) {
group = 'Distribution'
description = 'Builds -dist, -docs distribution archives.'
}