Skip to content

Commit af1c276

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`** # Conflicts: # build.gradle
1 parent 9b63911 commit af1c276

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
@@ -194,6 +194,30 @@ configure(javaProjects) { subproject ->
194194

195195
apply from: "${rootDir}/gradle/publish-maven.gradle"
196196

197+
def scopeAttribute = Attribute.of('dependency.scope', String)
198+
199+
configurations {
200+
optional {
201+
attributes {
202+
attribute(scopeAttribute, 'optional')
203+
}
204+
}
205+
provided {
206+
attributes {
207+
attribute(scopeAttribute, 'provided')
208+
}
209+
}
210+
}
211+
212+
components.java.with {
213+
it.addVariantsFromConfiguration(configurations.optional) {
214+
mapToOptional()
215+
}
216+
it.addVariantsFromConfiguration(configurations.provided) {
217+
mapToMavenScope('compile') // This is temporary. Gradle doesn't natively support the provided scope
218+
}
219+
}
220+
197221
sourceSets {
198222
test {
199223
resources {
@@ -202,15 +226,16 @@ configure(javaProjects) { subproject ->
202226
}
203227
}
204228

229+
[configurations.optional, configurations.provided].each { scoped ->
230+
sourceSets.all {
231+
compileClasspath += scoped
232+
runtimeClasspath += scoped
233+
}
234+
}
235+
205236
java {
206237
withJavadocJar()
207238
withSourcesJar()
208-
registerFeature('optional') {
209-
usingSourceSet(sourceSets.main)
210-
}
211-
registerFeature('provided') {
212-
usingSourceSet(sourceSets.main)
213-
}
214239
}
215240

216241
compileJava {
@@ -246,6 +271,10 @@ configure(javaProjects) { subproject ->
246271

247272
// dependencies that are common across all java projects
248273
dependencies {
274+
attributesSchema {
275+
attribute(scopeAttribute)
276+
}
277+
249278
if (!(subproject.name ==~ /.*-test.*/)) {
250279
testImplementation(project(':spring-integration-test-support')) {
251280
exclude group: 'org.hamcrest'
@@ -416,14 +445,8 @@ configure(javaProjects) { subproject ->
416445
from components.java
417446
pom.withXml {
418447
def pomDeps = asNode().dependencies.first()
419-
subproject.configurations.providedImplementation.allDependencies.each { dep ->
420-
pomDeps.remove(pomDeps.'*'.find { it.artifactId.text() == dep.name })
421-
pomDeps.appendNode('dependency').with {
422-
it.appendNode('groupId', dep.group)
423-
it.appendNode('artifactId', dep.name)
424-
it.appendNode('version', dep.version)
425-
it.appendNode('scope', 'provided')
426-
}
448+
subproject.configurations.provided.allDependencies.each { dep ->
449+
pomDeps.'*'.find { it.artifactId.text() == dep.name }.scope.first().value = 'provided'
427450
}
428451
}
429452
}
@@ -441,19 +464,19 @@ project('spring-integration-test-support') {
441464
api 'org.springframework:spring-context'
442465
api 'org.springframework:spring-messaging'
443466
api 'org.springframework:spring-test'
444-
optionalApi("junit:junit:$junit4Version") {
467+
optional("junit:junit:$junit4Version") {
445468
exclude group: 'org.hamcrest'
446469
}
447-
optionalApi 'org.junit.jupiter:junit-jupiter-api'
448-
optionalApi 'org.apache.logging.log4j:log4j-core'
470+
optional 'org.junit.jupiter:junit-jupiter-api'
471+
optional 'org.apache.logging.log4j:log4j-core'
449472
}
450473
}
451474

452475
project('spring-integration-amqp') {
453476
description = 'Spring Integration AMQP Support'
454477
dependencies {
455478
api 'org.springframework.amqp:spring-rabbit'
456-
optionalApi 'org.springframework.amqp:spring-rabbit-stream'
479+
optional 'org.springframework.amqp:spring-rabbit-stream'
457480

458481
testImplementation 'org.springframework.amqp:spring-rabbit-junit'
459482
testImplementation project(':spring-integration-stream')
@@ -503,23 +526,23 @@ project('spring-integration-core') {
503526
api 'io.projectreactor:reactor-core'
504527
api 'io.micrometer:micrometer-observation'
505528

506-
optionalApi 'com.fasterxml.jackson.core:jackson-databind'
507-
optionalApi 'com.fasterxml.jackson.datatype:jackson-datatype-jdk8'
508-
optionalApi 'com.fasterxml.jackson.datatype:jackson-datatype-jsr310'
509-
optionalApi 'com.fasterxml.jackson.datatype:jackson-datatype-joda'
510-
optionalApi('com.fasterxml.jackson.module:jackson-module-kotlin') {
529+
optional 'com.fasterxml.jackson.core:jackson-databind'
530+
optional 'com.fasterxml.jackson.datatype:jackson-datatype-jdk8'
531+
optional 'com.fasterxml.jackson.datatype:jackson-datatype-jsr310'
532+
optional 'com.fasterxml.jackson.datatype:jackson-datatype-joda'
533+
optional('com.fasterxml.jackson.module:jackson-module-kotlin') {
511534
exclude group: 'org.jetbrains.kotlin'
512535
}
513-
optionalApi "com.google.protobuf:protobuf-java:$protobufVersion"
514-
optionalApi "com.jayway.jsonpath:json-path:$jsonpathVersion"
515-
optionalApi "com.esotericsoftware:kryo:$kryoVersion"
516-
optionalApi 'io.micrometer:micrometer-core'
517-
optionalApi('io.micrometer:micrometer-tracing') {
536+
optional "com.google.protobuf:protobuf-java:$protobufVersion"
537+
optional "com.jayway.jsonpath:json-path:$jsonpathVersion"
538+
optional "com.esotericsoftware:kryo:$kryoVersion"
539+
optional 'io.micrometer:micrometer-core'
540+
optional('io.micrometer:micrometer-tracing') {
518541
exclude group: 'aopalliance'
519542
}
520-
optionalApi "io.github.resilience4j:resilience4j-ratelimiter:$resilience4jVersion"
521-
optionalApi "org.apache.avro:avro:$avroVersion"
522-
optionalApi 'org.jetbrains.kotlinx:kotlinx-coroutines-reactor'
543+
optional "io.github.resilience4j:resilience4j-ratelimiter:$resilience4jVersion"
544+
optional "org.apache.avro:avro:$avroVersion"
545+
optional 'org.jetbrains.kotlinx:kotlinx-coroutines-reactor'
523546

524547
testImplementation "com.google.protobuf:protobuf-java-util:$protobufVersion"
525548
testImplementation "org.aspectj:aspectjweaver:$aspectjVersion"
@@ -532,7 +555,7 @@ project('spring-integration-core') {
532555
}
533556

534557
dokkaHtmlPartial {
535-
outputDirectory.set(new File(buildDir, 'kdoc'))
558+
outputDirectory.set(new File('build', 'kdoc'))
536559
dokkaSourceSets {
537560
main {
538561
sourceRoots.setFrom(file('src/main/kotlin'))
@@ -600,7 +623,7 @@ project('spring-integration-ftp') {
600623
api project(':spring-integration-file')
601624
api "commons-net:commons-net:$commonsNetVersion"
602625
api 'org.springframework:spring-context-support'
603-
optionalApi "org.apache.ftpserver:ftpserver-core:$ftpServerVersion"
626+
optional "org.apache.ftpserver:ftpserver-core:$ftpServerVersion"
604627

605628
testImplementation project(':spring-integration-file').sourceSets.test.output
606629
}
@@ -659,9 +682,9 @@ project('spring-integration-http') {
659682
description = 'Spring Integration HTTP Support'
660683
dependencies {
661684
api 'org.springframework:spring-webmvc'
662-
providedImplementation "jakarta.servlet:jakarta.servlet-api:$servletApiVersion"
663-
optionalApi "com.rometools:rome:$romeToolsVersion"
664-
optionalApi 'org.springframework:spring-webflux'
685+
provided "jakarta.servlet:jakarta.servlet-api:$servletApiVersion"
686+
optional "com.rometools:rome:$romeToolsVersion"
687+
optional 'org.springframework:spring-webflux'
665688

666689
testImplementation "org.hamcrest:hamcrest-core:$hamcrestVersion"
667690
testImplementation 'org.springframework.security:spring-security-messaging'
@@ -693,7 +716,7 @@ project('spring-integration-jdbc') {
693716
description = 'Spring Integration JDBC Support'
694717
dependencies {
695718
api 'org.springframework:spring-jdbc'
696-
optionalApi "org.postgresql:postgresql:$postgresVersion"
719+
optional "org.postgresql:postgresql:$postgresVersion"
697720

698721
testImplementation "com.h2database:h2:$h2Version"
699722
testImplementation "org.hsqldb:hsqldb:$hsqldbVersion"
@@ -718,7 +741,7 @@ project('spring-integration-jms') {
718741
description = 'Spring Integration JMS Support'
719742
dependencies {
720743
api 'org.springframework:spring-jms'
721-
providedImplementation "jakarta.jms:jakarta.jms-api:$jmsApiVersion"
744+
provided "jakarta.jms:jakarta.jms-api:$jmsApiVersion"
722745

723746
testImplementation("org.apache.activemq:artemis-server:$artemisVersion") {
724747
exclude group: 'org.jboss.logmanager'
@@ -741,7 +764,7 @@ project('spring-integration-jpa') {
741764
description = 'Spring Integration JPA Support'
742765
dependencies {
743766
api 'org.springframework:spring-orm'
744-
optionalApi "jakarta.persistence:jakarta.persistence-api:$jpaApiVersion"
767+
optional "jakarta.persistence:jakarta.persistence-api:$jpaApiVersion"
745768

746769
testImplementation 'org.springframework.data:spring-data-jpa'
747770
testImplementation "com.h2database:h2:$h2Version"
@@ -764,7 +787,7 @@ project('spring-integration-mail') {
764787
dependencies {
765788
api 'org.springframework:spring-context-support'
766789

767-
providedImplementation "org.eclipse.angus:jakarta.mail:$mailVersion"
790+
provided "org.eclipse.angus:jakarta.mail:$mailVersion"
768791

769792
testImplementation "com.icegreen:greenmail:$greenmailVersion"
770793

@@ -777,8 +800,8 @@ project('spring-integration-mongodb') {
777800
dependencies {
778801
api 'org.springframework.data:spring-data-mongodb'
779802

780-
optionalApi "org.mongodb:mongodb-driver-sync:$mongoDriverVersion"
781-
optionalApi "org.mongodb:mongodb-driver-reactivestreams:$mongoDriverVersion"
803+
optional "org.mongodb:mongodb-driver-sync:$mongoDriverVersion"
804+
optional "org.mongodb:mongodb-driver-reactivestreams:$mongoDriverVersion"
782805

783806
testImplementation 'org.testcontainers:mongodb'
784807
}
@@ -799,7 +822,7 @@ project('spring-integration-mqtt') {
799822
dependencies {
800823
api "org.eclipse.paho:org.eclipse.paho.client.mqttv3:$pahoMqttClientVersion"
801824

802-
optionalApi "org.eclipse.paho:org.eclipse.paho.mqttv5.client:$pahoMqttClientVersion"
825+
optional "org.eclipse.paho:org.eclipse.paho.mqttv5.client:$pahoMqttClientVersion"
803826

804827
testImplementation project(':spring-integration-jmx')
805828
testImplementation 'com.fasterxml.jackson.core:jackson-databind'
@@ -829,9 +852,9 @@ project('spring-integration-rsocket') {
829852
project('spring-integration-scripting') {
830853
description = 'Spring Integration Scripting Support'
831854
dependencies {
832-
optionalApi 'org.jetbrains.kotlin:kotlin-scripting-jsr223'
833-
providedImplementation "org.graalvm.sdk:graal-sdk:$graalvmVersion"
834-
providedImplementation "org.graalvm.js:js:$graalvmVersion"
855+
optional 'org.jetbrains.kotlin:kotlin-scripting-jsr223'
856+
provided "org.graalvm.sdk:graal-sdk:$graalvmVersion"
857+
provided "org.graalvm.js:js:$graalvmVersion"
835858

836859
testImplementation "org.jruby:jruby-complete:$jrubyVersion"
837860
testImplementation 'org.apache.groovy:groovy-jsr223'
@@ -882,7 +905,7 @@ project('spring-integration-smb') {
882905
project('spring-integration-stomp') {
883906
description = 'Spring Integration STOMP Support'
884907
dependencies {
885-
optionalApi 'org.springframework:spring-websocket'
908+
optional 'org.springframework:spring-websocket'
886909

887910
testImplementation project(':spring-integration-websocket')
888911
testImplementation project(':spring-integration-websocket').sourceSets.test.output
@@ -934,7 +957,7 @@ project('spring-integration-webflux') {
934957
exclude group: 'org.springframework', module: 'spring-webmvc'
935958
}
936959
api 'org.springframework:spring-webflux'
937-
optionalApi 'io.projectreactor.netty:reactor-netty-http'
960+
optional 'io.projectreactor.netty:reactor-netty-http'
938961

939962
testImplementation "jakarta.servlet:jakarta.servlet-api:$servletApiVersion"
940963
testImplementation "org.hamcrest:hamcrest-core:$hamcrestVersion"
@@ -957,8 +980,8 @@ project('spring-integration-websocket') {
957980
description = 'Spring Integration WebSockets Support'
958981
dependencies {
959982
api 'org.springframework:spring-websocket'
960-
optionalApi 'org.springframework:spring-webmvc'
961-
providedImplementation "jakarta.servlet:jakarta.servlet-api:$servletApiVersion"
983+
optional 'org.springframework:spring-webmvc'
984+
provided "jakarta.servlet:jakarta.servlet-api:$servletApiVersion"
962985

963986
testImplementation project(':spring-integration-event')
964987
testImplementation "org.apache.tomcat.embed:tomcat-embed-websocket:$tomcatVersion"
@@ -983,7 +1006,7 @@ project('spring-integration-ws') {
9831006
exclude group: 'org.glassfish.jaxb'
9841007
}
9851008

986-
providedImplementation "com.sun.xml.bind:jaxb-impl:$jaxbVersion"
1009+
provided "com.sun.xml.bind:jaxb-impl:$jaxbVersion"
9871010

9881011
testImplementation "com.thoughtworks.xstream:xstream:$xstreamVersion"
9891012
testImplementation('org.springframework.ws:spring-ws-support') {
@@ -1004,7 +1027,7 @@ project('spring-integration-xml') {
10041027
api('org.springframework.ws:spring-xml') {
10051028
exclude group: 'org.springframework'
10061029
}
1007-
optionalApi('org.springframework.ws:spring-ws-core') {
1030+
optional('org.springframework.ws:spring-ws-core') {
10081031
exclude group: 'org.springframework'
10091032
}
10101033

@@ -1034,7 +1057,7 @@ project('spring-integration-zeromq') {
10341057
dependencies {
10351058
api "org.zeromq:jeromq:$jeroMqVersion"
10361059

1037-
optionalApi 'com.fasterxml.jackson.core:jackson-databind'
1060+
optional 'com.fasterxml.jackson.core:jackson-databind'
10381061
}
10391062
}
10401063

@@ -1098,10 +1121,9 @@ tasks.register('api', Javadoc) {
10981121
source javaProjects.collect { project ->
10991122
project.sourceSets.main.allJava
11001123
}
1101-
destinationDir = new File(buildDir, 'api')
1102-
classpath = files(javaProjects.collect { project ->
1103-
project.sourceSets.main.compileClasspath
1104-
})
1124+
destinationDir = new File('build', 'api')
1125+
classpath = files().from { files(javaProjects.collect { it.sourceSets.main.compileClasspath }) }
1126+
11051127
}
11061128

11071129
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)