Files
spring-amqp/build.gradle
2022-01-11 15:29:42 -05:00

626 lines
17 KiB
Groovy

buildscript {
ext.kotlinVersion = '1.3.72'
repositories {
maven { url 'https://plugins.gradle.org/m2' }
maven { url 'https://repo.spring.io/plugins-release-local' }
}
dependencies {
classpath 'org.asciidoctor:asciidoctorj-pdf:1.5.0-beta.5'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
classpath "org.jetbrains.kotlin:kotlin-allopen:$kotlinVersion"
}
}
plugins {
id 'base'
id 'project-report'
id 'idea'
id 'org.sonarqube' version '2.7.1'
id 'org.asciidoctor.convert' version '1.6.1'
id 'org.ajoberstar.grgit' version '3.1.1'
id 'io.spring.nohttp' version '0.0.3.RELEASE'
id 'io.spring.dependency-management' version '1.0.9.RELEASE' apply false
}
description = 'Spring AMQP'
ext {
isTravisBuild = System.getenv().get('TRAVIS') == 'true'
linkHomepage = 'https://projects.spring.io/spring-amqp'
linkCi = 'https://build.spring.io/browse/AMQP'
linkIssue = 'https://jira.spring.io/browse/AMQP'
linkScmUrl = 'https://github.com/spring-projects/spring-amqp'
linkScmConnection = 'git://github.com/spring-projects/spring-amqp.git'
linkScmDevConnection = 'git@github.com:spring-projects/spring-amqp.git'
docResourcesVersion = '0.1.0.RELEASE'
modifiedFiles =
files(grgit.status().unstaged.modified).filter{ f -> f.name.endsWith('.java') || f.name.endsWith('.kt') }
assertjVersion = '3.15.0'
assertkVersion = '0.22'
commonsHttpClientVersion = '4.5.12'
googleJsr305Version = '3.0.2'
hamcrestVersion = '2.2'
jacksonBomVersion = '2.10.5.20201202'
jaywayJsonPathVersion = '2.4.0'
junit4Version = '4.13.2'
junitJupiterVersion = '5.8.2'
log4jVersion = '2.17.1'
logbackVersion = '1.2.3'
micrometerVersion = '1.3.20'
mockitoVersion = '3.1.0'
rabbitmqVersion = project.hasProperty('rabbitmqVersion') ? project.rabbitmqVersion : '5.7.3'
rabbitmqHttpClientVersion = '3.2.0.RELEASE'
reactorVersion = 'Dysprosium-SR25'
springDataCommonsVersion = '2.2.13.RELEASE'
springVersion = project.hasProperty('springVersion') ? project.springVersion : '5.2.19.RELEASE'
springRetryVersion = '1.2.5.RELEASE'
}
nohttp {
source.include '**/src/**'
source.exclude '**/*.gif', '**/*.ks'
}
allprojects {
group = 'org.springframework.amqp'
apply plugin: 'io.spring.dependency-management'
dependencyManagement {
resolutionStrategy {
cacheChangingModulesFor 0, 'seconds'
}
applyMavenExclusions = false
generatedPomCustomization {
enabled = false
}
imports {
mavenBom "com.fasterxml.jackson:jackson-bom:$jacksonBomVersion"
mavenBom "org.junit:junit-bom:$junitJupiterVersion"
mavenBom "org.springframework:spring-framework-bom:$springVersion"
mavenBom "io.projectreactor:reactor-bom:$reactorVersion"
mavenBom "org.apache.logging.log4j:log4j-bom:$log4jVersion"
}
}
repositories {
mavenCentral()
maven { url 'https://repo.spring.io/libs-release' }
if (version.endsWith('BUILD-SNAPSHOT')) {
maven { url 'https://repo.spring.io/libs-snapshot' }
}
// maven { url 'https://repo.spring.io/libs-staging-local' }
}
}
ext {
expandPlaceholders = '**/quick-tour.xml'
javadocLinks = [
'https://docs.oracle.com/javase/8/docs/api/',
'https://docs.oracle.com/javaee/7/api/',
'https://docs.spring.io/spring/docs/current/javadoc-api/'
] as String[]
}
subprojects { subproject ->
apply plugin: 'java'
apply from: "${rootProject.projectDir}/publish-maven.gradle"
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'project-report'
apply plugin: 'jacoco'
apply plugin: 'checkstyle'
apply plugin: 'kotlin'
apply plugin: 'kotlin-spring'
sourceCompatibility=1.8
targetCompatibility=1.8
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.apache.logging.log4j:log4j-core'
testCompile "org.hamcrest:hamcrest-core:$hamcrestVersion"
testCompile ("org.mockito:mockito-core:$mockitoVersion") {
exclude group: 'org.hamcrest', module: 'hamcrest-core'
}
testCompile "org.mockito:mockito-junit-jupiter:$mockitoVersion"
testCompile 'org.springframework:spring-test'
testRuntime 'org.apache.logging.log4j:log4j-jcl'
testCompile 'org.junit.jupiter:junit-jupiter-api'
testCompile 'org.junit.jupiter:junit-jupiter-params'
testRuntime 'org.junit.jupiter:junit-jupiter-engine'
testRuntime 'org.junit.platform:junit-platform-launcher'
// To avoid compiler warnings about @API annotations in JUnit code
testCompileOnly 'org.apiguardian:apiguardian-api:1.0.0'
testCompile 'org.jetbrains.kotlin:kotlin-reflect'
testCompile 'org.jetbrains.kotlin:kotlin-stdlib-jdk8'
}
// enable all compiler warnings; individual projects may customize further
ext.xLintArg = '-Xlint:all,-options,-processing'
[compileJava, compileTestJava]*.options*.compilerArgs = [xLintArg]
task checkTestConfigs {
inputs.files(
sourceSets.test.java.srcDirs.collect {
fileTree(it)
.include('**/*.xml')
.exclude('**/log4j2-test.xml')
})
outputs.dir('build/resources')
doLast {
def wrongConfigs = inputs.files.filter {
new XmlParser(false, false)
.parse(it)
.@'xsi:schemaLocation' ==~ /.*spring-[a-z-]*\d\.\d\.xsd.*/
}
if (!wrongConfigs.empty) {
throw new InvalidUserDataException('Hardcoded XSD version in the config files:\n' +
wrongConfigs.collect { relativePath(it) }.join('\n') +
'\nPlease, use versionless schemaLocations for Spring XSDs to avoid issues with builds ' +
'on different versions of dependencies.')
}
}
}
task updateCopyrights {
onlyIf { !System.getenv('TRAVIS') && !System.getenv('bamboo_buildKey') }
inputs.files(modifiedFiles.filter { f -> f.path.contains(subproject.name) })
outputs.dir('build/classes')
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.text = sourceCode
println "Copyright updated for file: $file"
}
break
}
}
}
}
}
}
compileKotlin.dependsOn updateCopyrights
test {
maxHeapSize = '2g'
jvmArgs '-XX:+HeapDumpOnOutOfMemoryError'
testLogging {
events "skipped", "failed"
showStandardStreams = project.hasProperty("showStandardStreams") ?: false
showExceptions = true
showStackTraces = true
exceptionFormat = 'full'
}
jacoco {
append = false
destinationFile = file("$buildDir/jacoco.exec")
}
if (isTravisBuild) {
// restrict memory usage, so tests don't fail with exit code 137 on travis
maxHeapSize = '256m'
}
}
task testAll(type: Test, dependsOn: check)
gradle.taskGraph.whenReady { graph ->
if (graph.hasTask(testAll)) {
test.enabled = false
}
}
tasks.withType(Test).all {
// suppress all console output during testing unless running `gradle -i`
logging.captureStandardOutput(LogLevel.INFO)
dependsOn checkTestConfigs
if (name ==~ /(testAll)/) {
systemProperty 'RUN_LONG_INTEGRATION_TESTS', 'true'
}
useJUnitPlatform()
}
task sourcesJar(type: Jar) {
classifier = 'sources'
from sourceSets.main.allJava
}
task javadocJar(type: Jar) {
classifier = 'javadoc'
from javadoc
}
checkstyle {
configFile = file("${rootDir}/src/checkstyle/checkstyle.xml")
toolVersion = '8.24'
}
artifacts {
archives sourcesJar
archives javadocJar
}
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)
}
}
check.dependsOn javadoc
build.dependsOn jacocoTestReport
}
project('spring-amqp') {
description = 'Spring AMQP Core'
dependencies {
compile 'org.springframework:spring-core'
compile ('org.springframework:spring-messaging', optional)
compile ('org.springframework:spring-oxm', optional)
compile ('org.springframework:spring-context', optional)
compile ("org.springframework.retry:spring-retry:$springRetryVersion") {
exclude group: 'org.springframework'
}
compile ('com.fasterxml.jackson.core:jackson-core', optional)
compile ('com.fasterxml.jackson.core:jackson-databind', optional)
compile ('com.fasterxml.jackson.dataformat:jackson-dataformat-xml', optional)
// Spring Data projection message binding support
compile ("org.springframework.data:spring-data-commons:$springDataCommonsVersion") {
optional(it)
exclude group: 'org.springframework'
}
compile ("com.jayway.jsonpath:json-path:$jaywayJsonPathVersion", optional)
testCompile "org.assertj:assertj-core:$assertjVersion"
}
}
project('spring-rabbit') {
description = 'Spring RabbitMQ Support'
dependencies {
compile project(':spring-amqp')
compile "com.rabbitmq:amqp-client:$rabbitmqVersion"
compile ("com.rabbitmq:http-client:$rabbitmqHttpClientVersion", optional)
compile ('org.springframework:spring-aop', optional)
compile 'org.springframework:spring-context'
compile 'org.springframework:spring-messaging'
compile 'org.springframework:spring-tx'
compile ('io.projectreactor:reactor-core', optional)
compile ("ch.qos.logback:logback-classic:$logbackVersion", optional)
compile ('org.apache.logging.log4j:log4j-core', optional)
compile ("io.micrometer:micrometer-core:$micrometerVersion", optional)
testCompile project(':spring-rabbit-junit')
testCompile("com.willowtreeapps.assertk:assertk-jvm:$assertkVersion")
testRuntime 'org.springframework:spring-web'
testRuntime "org.apache.httpcomponents:httpclient:$commonsHttpClientVersion"
testRuntime 'com.fasterxml.jackson.module:jackson-module-kotlin'
}
compileTestKotlin {
kotlinOptions {
jvmTarget = '1.8'
}
}
}
project('spring-rabbit-junit') {
description = 'Spring Rabbit JUnit Support'
dependencies { // no spring-amqp dependencies allowed
compile 'org.springframework:spring-core'
compile 'org.springframework:spring-test'
compile ("junit:junit:$junit4Version") {
optional(it)
exclude group: 'org.hamcrest', module: 'hamcrest-core'
}
compile "com.rabbitmq:amqp-client:$rabbitmqVersion"
compile ("com.rabbitmq:http-client:$rabbitmqHttpClientVersion") {
exclude group: 'org.springframework', module: 'spring-web'
}
compile 'org.springframework:spring-web'
compile ('org.junit.jupiter:junit-jupiter-api', optional)
compile "org.assertj:assertj-core:$assertjVersion"
compile ("ch.qos.logback:logback-classic:$logbackVersion", optional)
compile ('org.apache.logging.log4j:log4j-core', optional)
compileOnly 'org.apiguardian:apiguardian-api:1.0.0'
}
}
project('spring-rabbit-test') {
description = 'Spring Rabbit Test Support'
dependencies {
compile project(':spring-rabbit')
compile project(':spring-rabbit-junit')
compile "org.hamcrest:hamcrest-library:$hamcrestVersion"
compile "org.hamcrest:hamcrest-core:$hamcrestVersion"
compile "org.mockito:mockito-core:$mockitoVersion"
testCompile project(':spring-rabbit').sourceSets.test.output
}
}
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"
}
task reference(type: org.asciidoctor.gradle.AsciidoctorTask) {
backends = ['pdf']
sourceDir "$buildDir/asciidoc"
sources {
include 'index.adoc'
}
options doctype: 'book', eruby: 'erubis'
attributes 'source-highlighter': 'coderay',
'icons': 'font',
"project-version=$project.version"
}
reference.dependsOn asciidoctor
asciidoctor {
sourceDir "$buildDir/asciidoc"
sources {
include 'index.adoc'
}
resources {
from(sourceDir) {
include 'images/*', 'css/**', 'js/**'
}
}
logDocuments = true
backends = ['html5']
options doctype: 'book', eruby: 'erubis'
attributes 'docinfo': 'shared',
stylesdir: 'css/',
stylesheet: 'spring.css',
'linkcss': true,
'icons': 'font',
'source-highlighter=highlight.js',
'highlightjsdir=js/highlight',
'highlightjs-theme=atom-one-dark-reasonable',
"project-version=$project.version"
}
asciidoctor.dependsOn prepareAsciidocBuild
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'
options.stylesheetFile = file('src/api/stylesheet.css')
options.links(rootProject.ext.javadocLinks)
source subprojects.collect { project ->
project.sourceSets.main.allJava
}
destinationDir = new File(buildDir, 'api')
classpath = files(subprojects.collect { project ->
project.sourceSets.main.compileClasspath
})
}
task schemaZip(type: Zip) {
group = 'Distribution'
classifier = 'schema'
description = "Builds -${classifier} archive containing all " +
"XSDs for deployment at static.springframework.org/schema."
subprojects.each { subproject ->
def Properties schemas = new Properties();
def shortName = subproject.name.replaceFirst("${rootProject.name}-", '')
if (subproject.name.endsWith('-rabbit')) {
shortName = 'rabbit'
}
subproject.sourceSets.main.resources.find {
it.path.endsWith("META-INF${File.separator}spring.schemas")
}?.withInputStream { schemas.load(it) }
for (def key : schemas.keySet()) {
File xsdFile = subproject.sourceSets.main.resources.find {
it.path.replaceAll('\\\\', '/').endsWith(schemas.get(key))
}
assert xsdFile != null
into ("${shortName}") {
from xsdFile.path
}
}
}
}
task docsZip(type: Zip, dependsOn: [reference]) {
group = 'Distribution'
classifier = 'docs'
description = "Builds -${classifier} archive containing api and reference " +
"for deployment at static.springframework.org/spring-integration/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.md'
include 'apache-license.txt'
include 'epl-license.txt'
include 'notice.txt'
into "${baseDir}"
}
from(zipTree(docsZip.archivePath)) {
into "${baseDir}/docs"
}
from(zipTree(schemaZip.archivePath)) {
into "${baseDir}/schema"
}
subprojects.each { subproject ->
into ("${baseDir}/libs") {
from subproject.jar
from subproject.sourcesJar
from subproject.javadocJar
}
}
}
// Create an optional "with dependencies" distribution.
// Not published by default; only for use when building from source.
task depsZip(type: Zip, dependsOn: distZip) { zipTask ->
group = 'Distribution'
classifier = 'dist-with-deps'
description = "Builds -${classifier} archive, containing everything " +
"in the -${distZip.classifier} archive plus all dependencies."
from zipTree(distZip.archivePath)
gradle.taskGraph.whenReady { taskGraph ->
if (taskGraph.hasTask(":${zipTask.name}")) {
def projectNames = rootProject.subprojects*.name
def artifacts = new HashSet()
subprojects.each { subproject ->
subproject.configurations.runtime.resolvedConfiguration.resolvedArtifacts.each { artifact ->
def dependency = artifact.moduleVersion.id
if (!projectNames.contains(dependency.name)) {
artifacts << artifact.file
}
}
}
zipTask.from(artifacts) {
into "${distZip.baseDir}/deps"
}
}
}
}
tasks.build.dependsOn assemble
artifacts {
archives distZip
archives docsZip
archives schemaZip
}
task dist(dependsOn: assemble) {
group = 'Distribution'
description = 'Builds -dist, -docs and -schema distribution archives.'
}