Skip to content

Commit 8a38a5e

Browse files
committed
Merge spring-integration-kotlin-dsl project
* Migrate all the Kotlin tests to use new Kotlin DSL * Upgrade to the latest Kotlin * Generate KDocs
1 parent f332a94 commit 8a38a5e

File tree

7 files changed

+1628
-48
lines changed

7 files changed

+1628
-48
lines changed

build.gradle

+47-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
buildscript {
2-
ext.kotlinVersion = '1.3.61'
2+
ext.kotlinVersion = '1.3.70'
33
repositories {
44
maven { url 'https://repo.spring.io/plugins-release' }
55
}
@@ -17,6 +17,7 @@ plugins {
1717
id 'org.ajoberstar.grgit' version '4.0.1'
1818
id "io.spring.dependency-management" version '1.0.9.RELEASE'
1919
id 'com.jfrog.artifactory' version '4.13.0' apply false
20+
id 'org.jetbrains.dokka' version '0.10.1'
2021
}
2122

2223
if (System.getenv('TRAVIS') || System.getenv('bamboo_buildKey')) {
@@ -188,9 +189,14 @@ configure(javaProjects) { subproject ->
188189
targetCompatibility = 1.8
189190
}
190191

192+
compileKotlin {
193+
kotlinOptions {
194+
jvmTarget = '1.8'
195+
allWarningsAsErrors = true
196+
}
197+
}
191198
compileTestKotlin {
192199
kotlinOptions {
193-
freeCompilerArgs = ['-Xjsr305=strict']
194200
jvmTarget = '1.8'
195201
}
196202
}
@@ -414,10 +420,13 @@ project('spring-integration-core') {
414420
optionalApi "com.esotericsoftware:kryo-shaded:$kryoShadedVersion"
415421
optionalApi "io.micrometer:micrometer-core:$micrometerVersion"
416422
optionalApi "io.github.resilience4j:resilience4j-ratelimiter:$resilience4jVersion"
417-
optionalApi"org.apache.avro:avro:$avroVersion"
423+
optionalApi "org.apache.avro:avro:$avroVersion"
424+
optionalApi 'org.jetbrains.kotlin:kotlin-reflect'
425+
optionalApi 'org.jetbrains.kotlin:kotlin-stdlib-jdk8'
418426

419427
testImplementation ("org.aspectj:aspectjweaver:$aspectjVersion")
420428
testImplementation ('com.fasterxml.jackson.datatype:jackson-datatype-jsr310')
429+
testRuntime 'com.fasterxml.jackson.module:jackson-module-kotlin'
421430
}
422431
}
423432

@@ -980,6 +989,38 @@ task api(type: Javadoc) {
980989
})
981990
}
982991

992+
dokka {
993+
dependsOn api
994+
995+
outputFormat = 'html'
996+
outputDirectory = "$buildDir/docs/kdoc"
997+
998+
configuration {
999+
classpath = javaProjects.collect { project -> project.jar.outputs.files.getFiles() }.flatten()
1000+
classpath += files(javaProjects.collect { it.sourceSets.main.compileClasspath })
1001+
javaProjects.forEach { project ->
1002+
if(project.sourceSets.main.kotlin) {
1003+
sourceRoot {
1004+
path = project.sourceSets.main.kotlin.srcDirs.first()
1005+
}
1006+
}
1007+
}
1008+
moduleName = 'spring-integration'
1009+
externalDocumentationLink {
1010+
url = new URL("https://docs.spring.io/spring-integration/docs/$version/api/")
1011+
}
1012+
externalDocumentationLink {
1013+
url = new URL('https://docs.spring.io/spring-framework/docs/current/javadoc-api/')
1014+
}
1015+
externalDocumentationLink {
1016+
url = new URL('https://projectreactor.io/docs/core/release/api/')
1017+
}
1018+
externalDocumentationLink {
1019+
url = new URL('https://www.reactive-streams.org/reactive-streams-1.0.1-javadoc/')
1020+
}
1021+
}
1022+
}
1023+
9831024
task schemaZip(type: Zip) {
9841025
group = 'Distribution'
9851026
archiveClassifier = 'schema'
@@ -1038,6 +1079,9 @@ task docsZip(type: Zip, dependsOn: reference) {
10381079
rename 'index-single.pdf', 'spring-integration-reference.pdf'
10391080
into 'reference/pdf'
10401081
}
1082+
from (dokka) {
1083+
into "kdoc-api"
1084+
}
10411085
}
10421086

10431087
task distZip(type: Zip, dependsOn: [docsZip, schemaZip]) {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,159 @@
1+
/*
2+
* Copyright 2020 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.springframework.integration.dsl
18+
19+
import org.reactivestreams.Publisher
20+
import org.springframework.integration.core.MessageSource
21+
import org.springframework.integration.endpoint.MessageProducerSupport
22+
import org.springframework.integration.gateway.MessagingGatewaySupport
23+
import org.springframework.messaging.Message
24+
import org.springframework.messaging.MessageChannel
25+
import java.util.function.Consumer
26+
27+
private fun buildIntegrationFlow(flowBuilder: IntegrationFlowBuilder,
28+
flow: (KotlinIntegrationFlowDefinition) -> Unit): IntegrationFlow {
29+
30+
flow(KotlinIntegrationFlowDefinition(flowBuilder))
31+
return flowBuilder.get()
32+
}
33+
34+
/**
35+
* Functional [IntegrationFlow] definition in Kotlin DSL for [IntegrationFlow] lambdas.
36+
*
37+
* @author Artem Bilan
38+
*/
39+
fun integrationFlow(flow: KotlinIntegrationFlowDefinition.() -> Unit) =
40+
IntegrationFlow {
41+
flow(KotlinIntegrationFlowDefinition(it))
42+
}
43+
44+
/**
45+
* Functional [IntegrationFlow] definition in Kotlin DSL for [IntegrationFlows.from] -
46+
* `IntegrationFlows.from(Class<?>, Consumer<GatewayProxySpec>)` factory method.
47+
*
48+
* @author Artem Bilan
49+
*/
50+
inline fun <reified T> integrationFlow(
51+
crossinline gateway: GatewayProxySpec.() -> Unit = {},
52+
flow: KotlinIntegrationFlowDefinition.() -> Unit): IntegrationFlow {
53+
54+
val flowBuilder = IntegrationFlows.from(T::class.java) { gateway(it) }
55+
flow(KotlinIntegrationFlowDefinition(flowBuilder))
56+
return flowBuilder.get()
57+
}
58+
59+
/**
60+
* Functional [IntegrationFlow] definition in Kotlin DSL for [IntegrationFlows.from] -
61+
* `IntegrationFlows.from(String, Boolean)` factory method.
62+
*
63+
* @author Artem Bilan
64+
*/
65+
fun integrationFlow(channelName: String, fixedSubscriber: Boolean = false,
66+
flow: KotlinIntegrationFlowDefinition.() -> Unit) =
67+
buildIntegrationFlow(IntegrationFlows.from(channelName, fixedSubscriber), flow)
68+
69+
/**
70+
* Functional [IntegrationFlow] definition in Kotlin DSL for [IntegrationFlows.from] -
71+
* `IntegrationFlows.from(MessageChannel)` factory method.
72+
*
73+
* @author Artem Bilan
74+
*/
75+
fun integrationFlow(channel: MessageChannel, flow: KotlinIntegrationFlowDefinition.() -> Unit) =
76+
buildIntegrationFlow(IntegrationFlows.from(channel), flow)
77+
78+
/**
79+
* Functional [IntegrationFlow] definition in Kotlin DSL for [IntegrationFlows.from] -
80+
* `IntegrationFlows.from(MessageSource<*>, Consumer<SourcePollingChannelAdapterSpec>)` factory method.
81+
*
82+
* @author Artem Bilan
83+
*/
84+
fun integrationFlow(messageSource: MessageSource<*>,
85+
options: SourcePollingChannelAdapterSpec.() -> Unit = {},
86+
flow: KotlinIntegrationFlowDefinition.() -> Unit) =
87+
buildIntegrationFlow(IntegrationFlows.from(messageSource, Consumer { options(it) }), flow)
88+
89+
/**
90+
* Functional [IntegrationFlow] definition in Kotlin DSL for [IntegrationFlows.from] -
91+
* `IntegrationFlows.from(MessageSourceSpec<*>, Consumer<SourcePollingChannelAdapterSpec>)` factory method.
92+
*
93+
* @author Artem Bilan
94+
*/
95+
fun integrationFlow(messageSource: MessageSourceSpec<*, out MessageSource<*>>,
96+
options: SourcePollingChannelAdapterSpec.() -> Unit = {},
97+
flow: KotlinIntegrationFlowDefinition.() -> Unit) =
98+
buildIntegrationFlow(IntegrationFlows.from(messageSource, options), flow)
99+
100+
/**
101+
* Functional [IntegrationFlow] definition in Kotlin DSL for [IntegrationFlows.from] -
102+
* `IntegrationFlows.from(Supplier<*>, Consumer<SourcePollingChannelAdapterSpec>)` factory method.
103+
*
104+
* @author Artem Bilan
105+
*/
106+
fun integrationFlow(source: () -> Any,
107+
options: SourcePollingChannelAdapterSpec.() -> Unit = {},
108+
flow: KotlinIntegrationFlowDefinition.() -> Unit) =
109+
buildIntegrationFlow(IntegrationFlows.from(source, options), flow)
110+
111+
/**
112+
* Functional [IntegrationFlow] definition in Kotlin DSL for [IntegrationFlows.from] -
113+
* `IntegrationFlows.from(Publisher<out Message<*>>)` factory method.
114+
*
115+
* @author Artem Bilan
116+
*/
117+
fun integrationFlow(publisher: Publisher<out Message<*>>,
118+
flow: KotlinIntegrationFlowDefinition.() -> Unit) =
119+
buildIntegrationFlow(IntegrationFlows.from(publisher), flow)
120+
121+
/**
122+
* Functional [IntegrationFlow] definition in Kotlin DSL for [IntegrationFlows.from] -
123+
* `IntegrationFlows.from(MessagingGatewaySupport)` factory method.
124+
*
125+
* @author Artem Bilan
126+
*/
127+
fun integrationFlow(gateway: MessagingGatewaySupport,
128+
flow: KotlinIntegrationFlowDefinition.() -> Unit) =
129+
buildIntegrationFlow(IntegrationFlows.from(gateway), flow)
130+
131+
/**
132+
* Functional [IntegrationFlow] definition in Kotlin DSL for [IntegrationFlows.from] -
133+
* `IntegrationFlows.from(MessagingGatewaySpec<*, *>)` factory method.
134+
*
135+
* @author Artem Bilan
136+
*/
137+
fun integrationFlow(gatewaySpec: MessagingGatewaySpec<*, *>,
138+
flow: KotlinIntegrationFlowDefinition.() -> Unit) =
139+
buildIntegrationFlow(IntegrationFlows.from(gatewaySpec), flow)
140+
141+
/**
142+
* Functional [IntegrationFlow] definition in Kotlin DSL for [IntegrationFlows.from] -
143+
* `IntegrationFlows.from(MessageProducerSupport)` factory method.
144+
*
145+
* @author Artem Bilan
146+
*/
147+
fun integrationFlow(producer: MessageProducerSupport,
148+
flow: KotlinIntegrationFlowDefinition.() -> Unit) =
149+
buildIntegrationFlow(IntegrationFlows.from(producer), flow)
150+
151+
/**
152+
* Functional [IntegrationFlow] definition in Kotlin DSL for [IntegrationFlows.from] -
153+
* `IntegrationFlows.from(MessageProducerSpec<*, *>)` factory method.
154+
*
155+
* @author Artem Bilan
156+
*/
157+
fun integrationFlow(producerSpec: MessageProducerSpec<*, *>,
158+
flow: KotlinIntegrationFlowDefinition.() -> Unit) =
159+
buildIntegrationFlow(IntegrationFlows.from(producerSpec), flow)

0 commit comments

Comments
 (0)