Skip to content

Commit 6ae8f73

Browse files
committed
Resolve Gradle deprecation warnings
* Use `optional` and `provided` variants instead of `registerFeature` * Simplify setting `<scope>provided</scope>` for generate POM * Use lazy-load for `Javadoc.classpath` to avoid early configuration resolution * Use actual Mark Fisher's e-mail for author. Thank you, Mark! **Auto-cherry-pick to `6.2.x`**
1 parent 3933605 commit 6ae8f73

File tree

2 files changed

+80
-58
lines changed

2 files changed

+80
-58
lines changed

build.gradle

Lines changed: 79 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,30 @@ configure(javaProjects) { subproject ->
204204

205205
apply from: "${rootDir}/gradle/publish-maven.gradle"
206206

207+
def scopeAttribute = Attribute.of('dependency.scope', String)
208+
209+
configurations {
210+
optional {
211+
attributes {
212+
attribute(scopeAttribute, 'optional')
213+
}
214+
}
215+
provided {
216+
attributes {
217+
attribute(scopeAttribute, 'provided')
218+
}
219+
}
220+
}
221+
222+
components.java.with {
223+
it.addVariantsFromConfiguration(configurations.optional) {
224+
mapToOptional()
225+
}
226+
it.addVariantsFromConfiguration(configurations.provided) {
227+
mapToMavenScope('compile') // This is temporary. Gradle doesn't natively support the provided scope
228+
}
229+
}
230+
207231
sourceSets {
208232
test {
209233
resources {
@@ -212,15 +236,16 @@ configure(javaProjects) { subproject ->
212236
}
213237
}
214238

239+
[configurations.optional, configurations.provided].each { scoped ->
240+
sourceSets.all {
241+
compileClasspath += scoped
242+
runtimeClasspath += scoped
243+
}
244+
}
245+
215246
java {
216247
withJavadocJar()
217248
withSourcesJar()
218-
registerFeature('optional') {
219-
usingSourceSet(sourceSets.main)
220-
}
221-
registerFeature('provided') {
222-
usingSourceSet(sourceSets.main)
223-
}
224249
}
225250

226251
compileJava {
@@ -256,6 +281,10 @@ configure(javaProjects) { subproject ->
256281

257282
// dependencies that are common across all java projects
258283
dependencies {
284+
attributesSchema {
285+
attribute(scopeAttribute)
286+
}
287+
259288
if (!(subproject.name ==~ /.*-test.*/)) {
260289
testImplementation(project(':spring-integration-test-support')) {
261290
exclude group: 'org.hamcrest'
@@ -426,14 +455,8 @@ configure(javaProjects) { subproject ->
426455
from components.java
427456
pom.withXml {
428457
def pomDeps = asNode().dependencies.first()
429-
subproject.configurations.providedImplementation.allDependencies.each { dep ->
430-
pomDeps.remove(pomDeps.'*'.find { it.artifactId.text() == dep.name })
431-
pomDeps.appendNode('dependency').with {
432-
it.appendNode('groupId', dep.group)
433-
it.appendNode('artifactId', dep.name)
434-
it.appendNode('version', dep.version)
435-
it.appendNode('scope', 'provided')
436-
}
458+
subproject.configurations.provided.allDependencies.each { dep ->
459+
pomDeps.'*'.find { it.artifactId.text() == dep.name }.scope.first().value = 'provided'
437460
}
438461
}
439462
}
@@ -451,19 +474,19 @@ project('spring-integration-test-support') {
451474
api 'org.springframework:spring-context'
452475
api 'org.springframework:spring-messaging'
453476
api 'org.springframework:spring-test'
454-
optionalApi("junit:junit:$junit4Version") {
477+
optional("junit:junit:$junit4Version") {
455478
exclude group: 'org.hamcrest'
456479
}
457-
optionalApi 'org.junit.jupiter:junit-jupiter-api'
458-
optionalApi 'org.apache.logging.log4j:log4j-core'
480+
optional 'org.junit.jupiter:junit-jupiter-api'
481+
optional 'org.apache.logging.log4j:log4j-core'
459482
}
460483
}
461484

462485
project('spring-integration-amqp') {
463486
description = 'Spring Integration AMQP Support'
464487
dependencies {
465488
api 'org.springframework.amqp:spring-rabbit'
466-
optionalApi 'org.springframework.amqp:spring-rabbit-stream'
489+
optional 'org.springframework.amqp:spring-rabbit-stream'
467490

468491
testImplementation 'org.springframework.amqp:spring-rabbit-junit'
469492
testImplementation project(':spring-integration-stream')
@@ -514,23 +537,23 @@ project('spring-integration-core') {
514537
api 'io.projectreactor:reactor-core'
515538
api 'io.micrometer:micrometer-observation'
516539

517-
optionalApi 'com.fasterxml.jackson.core:jackson-databind'
518-
optionalApi 'com.fasterxml.jackson.datatype:jackson-datatype-jdk8'
519-
optionalApi 'com.fasterxml.jackson.datatype:jackson-datatype-jsr310'
520-
optionalApi 'com.fasterxml.jackson.datatype:jackson-datatype-joda'
521-
optionalApi('com.fasterxml.jackson.module:jackson-module-kotlin') {
540+
optional 'com.fasterxml.jackson.core:jackson-databind'
541+
optional 'com.fasterxml.jackson.datatype:jackson-datatype-jdk8'
542+
optional 'com.fasterxml.jackson.datatype:jackson-datatype-jsr310'
543+
optional 'com.fasterxml.jackson.datatype:jackson-datatype-joda'
544+
optional('com.fasterxml.jackson.module:jackson-module-kotlin') {
522545
exclude group: 'org.jetbrains.kotlin'
523546
}
524-
optionalApi "com.google.protobuf:protobuf-java:$protobufVersion"
525-
optionalApi "com.jayway.jsonpath:json-path:$jsonpathVersion"
526-
optionalApi "com.esotericsoftware:kryo:$kryoVersion"
527-
optionalApi 'io.micrometer:micrometer-core'
528-
optionalApi('io.micrometer:micrometer-tracing') {
547+
optional "com.google.protobuf:protobuf-java:$protobufVersion"
548+
optional "com.jayway.jsonpath:json-path:$jsonpathVersion"
549+
optional "com.esotericsoftware:kryo:$kryoVersion"
550+
optional 'io.micrometer:micrometer-core'
551+
optional('io.micrometer:micrometer-tracing') {
529552
exclude group: 'aopalliance'
530553
}
531-
optionalApi "io.github.resilience4j:resilience4j-ratelimiter:$resilience4jVersion"
532-
optionalApi "org.apache.avro:avro:$avroVersion"
533-
optionalApi 'org.jetbrains.kotlinx:kotlinx-coroutines-reactor'
554+
optional "io.github.resilience4j:resilience4j-ratelimiter:$resilience4jVersion"
555+
optional "org.apache.avro:avro:$avroVersion"
556+
optional 'org.jetbrains.kotlinx:kotlinx-coroutines-reactor'
534557

535558
testImplementation "com.google.protobuf:protobuf-java-util:$protobufVersion"
536559
testImplementation "org.aspectj:aspectjweaver:$aspectjVersion"
@@ -543,7 +566,7 @@ project('spring-integration-core') {
543566
}
544567

545568
dokkaHtmlPartial {
546-
outputDirectory.set(new File(buildDir, 'kdoc'))
569+
outputDirectory.set(new File('build', 'kdoc'))
547570
dokkaSourceSets {
548571
main {
549572
sourceRoots.setFrom(file('src/main/kotlin'))
@@ -618,7 +641,7 @@ project('spring-integration-ftp') {
618641
api project(':spring-integration-file')
619642
api "commons-net:commons-net:$commonsNetVersion"
620643
api 'org.springframework:spring-context-support'
621-
optionalApi "org.apache.ftpserver:ftpserver-core:$ftpServerVersion"
644+
optional "org.apache.ftpserver:ftpserver-core:$ftpServerVersion"
622645

623646
testImplementation project(':spring-integration-file').sourceSets.test.output
624647
}
@@ -677,9 +700,9 @@ project('spring-integration-http') {
677700
description = 'Spring Integration HTTP Support'
678701
dependencies {
679702
api 'org.springframework:spring-webmvc'
680-
providedImplementation "jakarta.servlet:jakarta.servlet-api:$servletApiVersion"
681-
optionalApi "com.rometools:rome:$romeToolsVersion"
682-
optionalApi 'org.springframework:spring-webflux'
703+
provided "jakarta.servlet:jakarta.servlet-api:$servletApiVersion"
704+
optional "com.rometools:rome:$romeToolsVersion"
705+
optional 'org.springframework:spring-webflux'
683706

684707
testImplementation "org.hamcrest:hamcrest-core:$hamcrestVersion"
685708
testImplementation 'org.springframework.security:spring-security-messaging'
@@ -711,7 +734,7 @@ project('spring-integration-jdbc') {
711734
description = 'Spring Integration JDBC Support'
712735
dependencies {
713736
api 'org.springframework:spring-jdbc'
714-
optionalApi "org.postgresql:postgresql:$postgresVersion"
737+
optional "org.postgresql:postgresql:$postgresVersion"
715738

716739
testImplementation "com.h2database:h2:$h2Version"
717740
testImplementation "org.hsqldb:hsqldb:$hsqldbVersion"
@@ -736,7 +759,7 @@ project('spring-integration-jms') {
736759
description = 'Spring Integration JMS Support'
737760
dependencies {
738761
api 'org.springframework:spring-jms'
739-
providedImplementation "jakarta.jms:jakarta.jms-api:$jmsApiVersion"
762+
provided "jakarta.jms:jakarta.jms-api:$jmsApiVersion"
740763

741764
testImplementation("org.apache.activemq:artemis-server:$artemisVersion") {
742765
exclude group: 'org.jboss.logmanager'
@@ -759,7 +782,7 @@ project('spring-integration-jpa') {
759782
description = 'Spring Integration JPA Support'
760783
dependencies {
761784
api 'org.springframework:spring-orm'
762-
optionalApi "jakarta.persistence:jakarta.persistence-api:$jpaApiVersion"
785+
optional "jakarta.persistence:jakarta.persistence-api:$jpaApiVersion"
763786

764787
testImplementation 'org.springframework.data:spring-data-jpa'
765788
testImplementation "com.h2database:h2:$h2Version"
@@ -782,7 +805,7 @@ project('spring-integration-mail') {
782805
dependencies {
783806
api 'org.springframework:spring-context-support'
784807

785-
providedImplementation "org.eclipse.angus:jakarta.mail:$mailVersion"
808+
provided "org.eclipse.angus:jakarta.mail:$mailVersion"
786809

787810
testImplementation "com.icegreen:greenmail:$greenmailVersion"
788811

@@ -795,8 +818,8 @@ project('spring-integration-mongodb') {
795818
dependencies {
796819
api 'org.springframework.data:spring-data-mongodb'
797820

798-
optionalApi "org.mongodb:mongodb-driver-sync:$mongoDriverVersion"
799-
optionalApi "org.mongodb:mongodb-driver-reactivestreams:$mongoDriverVersion"
821+
optional "org.mongodb:mongodb-driver-sync:$mongoDriverVersion"
822+
optional "org.mongodb:mongodb-driver-reactivestreams:$mongoDriverVersion"
800823

801824
testImplementation 'org.testcontainers:mongodb'
802825
}
@@ -817,7 +840,7 @@ project('spring-integration-mqtt') {
817840
dependencies {
818841
api "org.eclipse.paho:org.eclipse.paho.client.mqttv3:$pahoMqttClientVersion"
819842

820-
optionalApi "org.eclipse.paho:org.eclipse.paho.mqttv5.client:$pahoMqttClientVersion"
843+
optional "org.eclipse.paho:org.eclipse.paho.mqttv5.client:$pahoMqttClientVersion"
821844

822845
testImplementation project(':spring-integration-jmx')
823846
testImplementation 'com.fasterxml.jackson.core:jackson-databind'
@@ -847,9 +870,9 @@ project('spring-integration-rsocket') {
847870
project('spring-integration-scripting') {
848871
description = 'Spring Integration Scripting Support'
849872
dependencies {
850-
optionalApi 'org.jetbrains.kotlin:kotlin-scripting-jsr223'
851-
providedImplementation "org.graalvm.sdk:graal-sdk:$graalvmVersion"
852-
providedImplementation "org.graalvm.polyglot:js:$graalvmVersion"
873+
optional 'org.jetbrains.kotlin:kotlin-scripting-jsr223'
874+
provided "org.graalvm.sdk:graal-sdk:$graalvmVersion"
875+
provided "org.graalvm.polyglot:js:$graalvmVersion"
853876

854877
testImplementation "org.jruby:jruby-complete:$jrubyVersion"
855878
testImplementation 'org.apache.groovy:groovy-jsr223'
@@ -893,7 +916,7 @@ project('spring-integration-smb') {
893916
project('spring-integration-stomp') {
894917
description = 'Spring Integration STOMP Support'
895918
dependencies {
896-
optionalApi 'org.springframework:spring-websocket'
919+
optional 'org.springframework:spring-websocket'
897920

898921
testImplementation project(':spring-integration-websocket')
899922
testImplementation project(':spring-integration-websocket').sourceSets.test.output
@@ -945,7 +968,7 @@ project('spring-integration-webflux') {
945968
exclude group: 'org.springframework', module: 'spring-webmvc'
946969
}
947970
api 'org.springframework:spring-webflux'
948-
optionalApi 'io.projectreactor.netty:reactor-netty-http'
971+
optional 'io.projectreactor.netty:reactor-netty-http'
949972

950973
testImplementation "jakarta.servlet:jakarta.servlet-api:$servletApiVersion"
951974
testImplementation "org.hamcrest:hamcrest-core:$hamcrestVersion"
@@ -968,8 +991,8 @@ project('spring-integration-websocket') {
968991
description = 'Spring Integration WebSockets Support'
969992
dependencies {
970993
api 'org.springframework:spring-websocket'
971-
optionalApi 'org.springframework:spring-webmvc'
972-
providedImplementation "jakarta.servlet:jakarta.servlet-api:$servletApiVersion"
994+
optional 'org.springframework:spring-webmvc'
995+
provided "jakarta.servlet:jakarta.servlet-api:$servletApiVersion"
973996

974997
testImplementation project(':spring-integration-event')
975998
testImplementation "org.apache.tomcat.embed:tomcat-embed-websocket:$tomcatVersion"
@@ -994,7 +1017,7 @@ project('spring-integration-ws') {
9941017
exclude group: 'org.glassfish.jaxb'
9951018
}
9961019

997-
providedImplementation "com.sun.xml.bind:jaxb-impl:$jaxbVersion"
1020+
provided "com.sun.xml.bind:jaxb-impl:$jaxbVersion"
9981021

9991022
testImplementation "com.thoughtworks.xstream:xstream:$xstreamVersion"
10001023
testImplementation('org.springframework.ws:spring-ws-support') {
@@ -1015,7 +1038,7 @@ project('spring-integration-xml') {
10151038
api('org.springframework.ws:spring-xml') {
10161039
exclude group: 'org.springframework'
10171040
}
1018-
optionalApi('org.springframework.ws:spring-ws-core') {
1041+
optional('org.springframework.ws:spring-ws-core') {
10191042
exclude group: 'org.springframework'
10201043
}
10211044

@@ -1045,7 +1068,7 @@ project('spring-integration-zeromq') {
10451068
dependencies {
10461069
api "org.zeromq:jeromq:$jeroMqVersion"
10471070

1048-
optionalApi 'com.fasterxml.jackson.core:jackson-databind'
1071+
optional 'com.fasterxml.jackson.core:jackson-databind'
10491072
}
10501073
}
10511074

@@ -1109,10 +1132,9 @@ tasks.register('api', Javadoc) {
11091132
source javaProjects.collect { project ->
11101133
project.sourceSets.main.allJava
11111134
}
1112-
destinationDir = new File(buildDir, 'api')
1113-
classpath = files(javaProjects.collect { project ->
1114-
project.sourceSets.main.compileClasspath
1115-
})
1135+
destinationDir = new File('build', 'api')
1136+
classpath = files().from { files(javaProjects.collect { it.sourceSets.main.compileClasspath }) }
1137+
11161138
}
11171139

11181140
dokkaHtmlMultiModule {

gradle/publish-maven.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ publishing {
4141
developer {
4242
id = 'markfisher'
4343
name = 'Mark Fisher'
44-
email = 'mark.fisher@broadcom.com'
44+
email = 'mark.ryan.fisher@gmail.com'
4545
roles = ['project founder and lead emeritus']
4646
}
4747
}

0 commit comments

Comments
 (0)