Skip to content

Commit

Permalink
GH-1015 Fix Kotlin dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
olegz committed Mar 20, 2023
1 parent c6c7dbf commit 8f5d832
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 77 deletions.
40 changes: 12 additions & 28 deletions spring-cloud-function-context/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -159,15 +159,6 @@
<plugin>
<artifactId>kotlin-maven-plugin</artifactId>
<groupId>org.jetbrains.kotlin</groupId>
<version>1.6.0</version>
<configuration>
<args>
<arg>-Xjsr305=strict</arg>
</args>
<compilerPlugins>
<plugin>spring</plugin>
</compilerPlugins>
</configuration>
<executions>
<execution>
<id>compile</id>
Expand All @@ -181,26 +172,19 @@
</sourceDirs>
</configuration>
</execution>
<execution>
<id>test-compile</id>
<goals>
<goal>test-compile</goal>
</goals>
<configuration>
<sourceDirs>
<sourceDir>${project.basedir}/src/test/kotlin</sourceDir>
<sourceDir>${project.basedir}/src/test/java</sourceDir>
</sourceDirs>
</configuration>
</execution>
<!-- <execution>-->
<!-- <id>test-compile</id>-->
<!-- <goals>-->
<!-- <goal>test-compile</goal>-->
<!-- </goals>-->
<!-- <configuration>-->
<!-- <sourceDirs>-->
<!-- <sourceDir>${project.basedir}/src/test/kotlin</sourceDir>-->
<!-- <sourceDir>${project.basedir}/src/test/java</sourceDir>-->
<!-- </sourceDirs>-->
<!-- </configuration>-->
<!-- </execution>-->
</executions>
<dependencies>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-maven-allopen</artifactId>
<version>1.6.0</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
Expand Down
18 changes: 0 additions & 18 deletions spring-cloud-function-kotlin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -64,16 +64,6 @@
<plugin>
<artifactId>kotlin-maven-plugin</artifactId>
<groupId>org.jetbrains.kotlin</groupId>
<version>1.8.10</version>
<configuration>
<args>
<arg>-Xjsr305=strict</arg>
</args>
<compilerPlugins>
<plugin>spring</plugin>
</compilerPlugins>
<jvmTarget>17</jvmTarget>
</configuration>
<executions>
<execution>
<id>test-compile</id>
Expand All @@ -85,17 +75,9 @@
<sourceDir>${project.basedir}/src/test/kotlin</sourceDir>
<sourceDir>${project.basedir}/src/test/java</sourceDir>
</sourceDirs>
<jvmTarget>17</jvmTarget>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-maven-allopen</artifactId>
<version>1.8.10</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,39 +28,39 @@ import java.util.List
*/
@EnableAutoConfiguration
@Configuration
class KotlinLambdasConfiguration {
open class KotlinLambdasConfiguration {

@Bean
fun uppercase(): Function<String, String> = KotlinComponentFunction()
open fun uppercase(): Function<String, String> = KotlinComponentFunction()
@Bean
fun kotlinFunction(): (String) -> String {
open fun kotlinFunction(): (String) -> String {
return { it.toUpperCase() }
}

@Bean
fun kotlinPojoFunction(): (Person) -> String {
open fun kotlinPojoFunction(): (Person) -> String {
return { it.name.toString()}
}

@Bean
fun kotlinListPojoFunction(): (List<Person>) -> String {
open fun kotlinListPojoFunction(): (List<Person>) -> String {
return {
"List of: " + it.get(0).name
}
}

@Bean
fun kotlinConsumer(): (String) -> Unit {
open fun kotlinConsumer(): (String) -> Unit {
return { println(it) }
}

@Bean
fun kotlinSupplier(): () -> String {
open fun kotlinSupplier(): () -> String {
return { "Hello" }
}

@Bean
fun javaFunction(): Function<String, String> {
open fun javaFunction(): Function<String, String> {
return Function { x -> x }
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,32 +32,32 @@ import java.util.function.Function
*/
@EnableAutoConfiguration
@Configuration
class KotlinSuspendFlowLambdasConfiguration {
open class KotlinSuspendFlowLambdasConfiguration {

@Bean
fun kotlinFunction(): suspend (Flow<String>) -> Flow<String> = { flow ->
open fun kotlinFunction(): suspend (Flow<String>) -> Flow<String> = { flow ->
flow.map { value -> value.toUpperCase() }
}

@Bean
fun kotlinPojoFunction(): suspend (Flow<Person>) -> Flow<String> = { flow ->
open fun kotlinPojoFunction(): suspend (Flow<Person>) -> Flow<String> = { flow ->
flow.map(Person::toString)
}

@Bean
fun kotlinConsumer(): suspend (Flow<String>) -> Unit = { flow ->
open fun kotlinConsumer(): suspend (Flow<String>) -> Unit = { flow ->
flow.collect(::println)
}

@Bean
fun kotlinSupplier(): suspend () -> Flow<String> = {
open fun kotlinSupplier(): suspend () -> Flow<String> = {
flow {
emit("Hello")
}
}

@Bean
fun javaFunction(): Function<Flux<String>, Flux<String>> {
open fun javaFunction(): Function<Flux<String>, Flux<String>> {
return Function { x -> x }
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,20 @@ import org.springframework.context.annotation.Configuration
*/
@EnableAutoConfiguration
@Configuration
class KotlinSuspendLambdasConfiguration {
open class KotlinSuspendLambdasConfiguration {

@Bean
fun kotlinFunction(): suspend (Person) -> String {
open fun kotlinFunction(): suspend (Person) -> String {
return { it.name.toString()}
}

@Bean
fun kotlinConsumer(): suspend (String) -> Unit {
open fun kotlinConsumer(): suspend (String) -> Unit {
return { println(it) }
}

@Bean
fun kotlinSupplier(): suspend () -> String {
open fun kotlinSupplier(): suspend () -> String {
return { "Hello" }
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@ import java.net.URI
properties = ["spring.cloud.function.web.path=/functions", "spring.main.web-application-type=reactive"]
)
@ContextConfiguration(classes = [RestApplication::class, HeadersToMessageSuspendTests.TestConfiguration::class])
class HeadersToMessageSuspendTests {
open class HeadersToMessageSuspendTests {
@Autowired
private val rest: TestRestTemplate? = null
@Test
@Throws(Exception::class)
fun testBodyAndCustomHeaderFromMessagePropagation() {
open fun testBodyAndCustomHeaderFromMessagePropagation() {
// test POJO paylod
var postForEntity = rest!!
.exchange(
Expand Down Expand Up @@ -75,9 +75,9 @@ class HeadersToMessageSuspendTests {

@EnableAutoConfiguration
@org.springframework.boot.test.context.TestConfiguration
class TestConfiguration {
open class TestConfiguration {
@Bean("stringSuspend")
fun functiono():suspend (employee: Flow<Message<String>>) -> Flow<Message<String>> = { flow: Flow<Message<String>> ->
open fun functiono():suspend (employee: Flow<Message<String>>) -> Flow<Message<String>> = { flow: Flow<Message<String>> ->
flow.map { request ->
val message =
MessageBuilder.withPayload(request.payload)
Expand All @@ -88,7 +88,7 @@ class HeadersToMessageSuspendTests {
}

@Bean("employeeSuspend")
fun function1(): suspend (employee: Flow<Message<Employee>>) -> Flow<Message<Employee>> = { flow ->
open fun function1(): suspend (employee: Flow<Message<Employee>>) -> Flow<Message<Employee>> = { flow ->
flow.map { request ->
val message =
MessageBuilder
Expand All @@ -101,7 +101,7 @@ class HeadersToMessageSuspendTests {
}
}

class Employee {
open class Employee {
var name: String? = null
var age = 0
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@ import java.net.URI
properties = ["spring.cloud.function.web.path=/functions", "spring.main.web-application-type=reactive"]
)
@ContextConfiguration(classes = [RestApplication::class, HeadersToMessageTests.TestConfiguration::class])
class HeadersToMessageTests {
open class HeadersToMessageTests {
@Autowired
private val rest: TestRestTemplate? = null
@Test
@Throws(Exception::class)
fun testBodyAndCustomHeaderFromMessagePropagation() {
open fun testBodyAndCustomHeaderFromMessagePropagation() {
// test POJO paylod
var postForEntity = rest!!
.exchange(
Expand Down Expand Up @@ -74,9 +74,9 @@ class HeadersToMessageTests {

@EnableAutoConfiguration
@org.springframework.boot.test.context.TestConfiguration
class TestConfiguration {
open class TestConfiguration {
@Bean("string")
fun functiono(): (message: Message<String?>) -> Message<String> = { request: Message<String?> ->
open fun functiono(): (message: Message<String?>) -> Message<String?> = { request: Message<String?> ->
val message =
MessageBuilder.withPayload(request.payload)
.setHeader("X-Content-Type", "application/xml")
Expand All @@ -85,7 +85,7 @@ class HeadersToMessageTests {
}

@Bean("employee")
fun function1(): (employee: Message<Employee>) -> Message<Employee> = { request ->
open fun function1(): (employee: Message<Employee>) -> Message<Employee> = { request ->
val message =
MessageBuilder
.withPayload(request.payload)
Expand All @@ -96,7 +96,7 @@ class HeadersToMessageTests {
}

// used by json converter
class Employee {
open class Employee {
var name: String? = null
var age = 0
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-maven-allopen</artifactId>
<version>1.8.10</version>
<version>${kotlin.version}</version>
</dependency>
</dependencies>
</plugin>
Expand Down

0 comments on commit 8f5d832

Please sign in to comment.