From f340439202e4be42dd82899524a0a80f29c3b374 Mon Sep 17 00:00:00 2001 From: Sebastien Deleuze Date: Tue, 14 May 2019 11:09:05 +0200 Subject: [PATCH 1/9] Fix R2DBC transitive dependencies --- gradle.properties | 4 ++-- samples/kofu-coroutines-r2dbc/build.gradle.kts | 8 +++----- samples/kofu-reactive-r2dbc/build.gradle.kts | 8 +++----- 3 files changed, 8 insertions(+), 12 deletions(-) diff --git a/gradle.properties b/gradle.properties index 5b7bb4cd6..14225df51 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,5 +1,5 @@ bootVersion=2.2.0.BUILD-SNAPSHOT coroutinesVersion=1.2.1 kotlin.version=1.3.31 -springDataR2dbcVersion=1.0.0.BUILD-SNAPSHOT -r2dbcVersion=Arabba-BUILD-SNAPSHOT \ No newline at end of file +springDataR2dbcVersion=1.0.0.M2 +r2dbcVersion=Arabba-M8 \ No newline at end of file diff --git a/samples/kofu-coroutines-r2dbc/build.gradle.kts b/samples/kofu-coroutines-r2dbc/build.gradle.kts index 9e5bda99b..24b24e2fe 100644 --- a/samples/kofu-coroutines-r2dbc/build.gradle.kts +++ b/samples/kofu-coroutines-r2dbc/build.gradle.kts @@ -11,19 +11,17 @@ dependencies { implementation("org.springframework.boot:spring-boot-starter-webflux") implementation("org.springframework.boot:spring-boot-starter-mustache") implementation("com.fasterxml.jackson.module:jackson-module-kotlin") - implementation("org.springframework.data:spring-data-r2dbc:1.0.0.BUILD-SNAPSHOT") + implementation("org.springframework.data:spring-data-r2dbc:1.0.0.M2") implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.2.1") implementation("org.jetbrains.kotlinx:kotlinx-coroutines-reactor:1.2.1") - implementation("io.r2dbc:r2dbc-h2") { - exclude(module = "reactor-netty") - } + implementation("io.r2dbc:r2dbc-h2") testImplementation("org.springframework.boot:spring-boot-starter-test") } dependencyManagement { imports { - mavenBom("io.r2dbc:r2dbc-bom:Arabba-BUILD-SNAPSHOT") + mavenBom("io.r2dbc:r2dbc-bom:Arabba-M8") } } diff --git a/samples/kofu-reactive-r2dbc/build.gradle.kts b/samples/kofu-reactive-r2dbc/build.gradle.kts index 4d78da902..354f0942a 100644 --- a/samples/kofu-reactive-r2dbc/build.gradle.kts +++ b/samples/kofu-reactive-r2dbc/build.gradle.kts @@ -12,17 +12,15 @@ dependencies { implementation("org.springframework.boot:spring-boot-starter-webflux") implementation("org.springframework.boot:spring-boot-starter-mustache") implementation("com.fasterxml.jackson.module:jackson-module-kotlin") - implementation("org.springframework.data:spring-data-r2dbc:1.0.0.BUILD-SNAPSHOT") - implementation("io.r2dbc:r2dbc-h2") { - exclude(module = "reactor-netty") - } + implementation("org.springframework.data:spring-data-r2dbc:1.0.0.M2") + implementation("io.r2dbc:r2dbc-h2") testImplementation("org.springframework.boot:spring-boot-starter-test") } dependencyManagement { imports { - mavenBom("io.r2dbc:r2dbc-bom:Arabba-BUILD-SNAPSHOT") + mavenBom("io.r2dbc:r2dbc-bom:Arabba-M8") } } From b610649285f6a729f5f7cb3e458f58b810b64cc6 Mon Sep 17 00:00:00 2001 From: Sebastien Deleuze Date: Tue, 14 May 2019 11:14:46 +0200 Subject: [PATCH 2/9] Avoid specifying reactor-kotlin-extensions version --- kofu/build.gradle.kts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kofu/build.gradle.kts b/kofu/build.gradle.kts index 09bb57fa5..5bc9c9930 100644 --- a/kofu/build.gradle.kts +++ b/kofu/build.gradle.kts @@ -22,7 +22,7 @@ dependencies { compileOnly("org.mongodb:mongodb-driver-reactivestreams") compileOnly("com.fasterxml.jackson.core:jackson-databind") compileOnly("com.samskivert:jmustache") - compileOnly("io.projectreactor.kotlin:reactor-kotlin-extensions:1.0.0.BUILD-SNAPSHOT") + compileOnly("io.projectreactor.kotlin:reactor-kotlin-extensions") compileOnly("javax.servlet:javax.servlet-api") testImplementation("org.junit.jupiter:junit-jupiter-api") @@ -40,7 +40,7 @@ dependencies { testImplementation("com.fasterxml.jackson.module:jackson-module-kotlin") testRuntimeOnly("de.flapdoodle.embed:de.flapdoodle.embed.mongo") testImplementation("io.mockk:mockk:1.9") - testImplementation("io.projectreactor.kotlin:reactor-kotlin-extensions:1.0.0.BUILD-SNAPSHOT") + testImplementation("io.projectreactor.kotlin:reactor-kotlin-extensions") testImplementation("javax.servlet:javax.servlet-api") } From b646ed7545c8e00d474df6e5ecfc39a6712e9521 Mon Sep 17 00:00:00 2001 From: Sebastien Deleuze Date: Tue, 14 May 2019 11:38:20 +0200 Subject: [PATCH 3/9] Fix documentation --- kofu/build.gradle.kts | 25 +++++++++++++++++-- .../springframework/fu/kofu/ApplicationDsl.kt | 3 +-- .../fu/kofu/KofuApplication.kt | 1 - .../fu/kofu/webflux/WebFluxServerDsl.kt | 3 ++- .../fu/kofu/webmvc/WebMvcServerDsl.kt | 13 +++++----- .../fu/kofu/samples/application.kt | 2 +- 6 files changed, 34 insertions(+), 13 deletions(-) diff --git a/kofu/build.gradle.kts b/kofu/build.gradle.kts index 5bc9c9930..53230064d 100644 --- a/kofu/build.gradle.kts +++ b/kofu/build.gradle.kts @@ -49,10 +49,31 @@ tasks.withType { outputFormat = "html" samples = listOf("src/test/kotlin/org/springframework/fu/kofu/samples") externalDocumentationLink { - url = URL("https://docs.spring.io/spring-framework/docs/5.2.0.BUILD-SNAPSHOT/javadoc-api/") + url = URL("https://docs.spring.io/spring-framework/docs/5.2.0.M2/javadoc-api/") } externalDocumentationLink { - url = URL("https://docs.spring.io/spring-framework/docs/5.2.0.BUILD-SNAPSHOT/kdoc-api/spring-framework/") + url = URL("https://docs.spring.io/spring-framework/docs/5.2.0.M2/kdoc-api/spring-framework/") + } + externalDocumentationLink { + url = URL("https://fasterxml.github.io/jackson-core/javadoc/2.9/") + } + externalDocumentationLink { + url = URL("https://fasterxml.github.io/jackson-annotations/javadoc/2.9/") + } + externalDocumentationLink { + url = URL("https://fasterxml.github.io/jackson-databind/javadoc/2.9/") + } + externalDocumentationLink { + url = URL("https://docs.spring.io/spring-data/mongodb/docs/2.2.x/api/") + } + externalDocumentationLink { + url = URL("https://docs.oracle.com/javase/8/docs/api/") + } + externalDocumentationLink { + url = URL("https://docs.spring.io/spring-boot/docs/2.2.x/api/") + } + externalDocumentationLink { + url = URL("https://docs.spring.io/spring-data/r2dbc/docs/1.0.x/api/") } } diff --git a/kofu/src/main/kotlin/org/springframework/fu/kofu/ApplicationDsl.kt b/kofu/src/main/kotlin/org/springframework/fu/kofu/ApplicationDsl.kt index 680b0393a..137858b28 100644 --- a/kofu/src/main/kotlin/org/springframework/fu/kofu/ApplicationDsl.kt +++ b/kofu/src/main/kotlin/org/springframework/fu/kofu/ApplicationDsl.kt @@ -23,10 +23,9 @@ import org.springframework.context.support.GenericApplicationContext * Kofu top level DSL for application which allows to configure a Spring Boot * application using Kofu and functional bean registration. * - * @sample org.springframework.fu.kofu.samples.webApplicationDsl + * @sample org.springframework.fu.kofu.samples.webFluxApplicationDsl * @param dsl The `application { }` DSL * @see application - * @see reactiveWebApplication * @author Sebastien Deleuze */ open class ApplicationDsl internal constructor(private val dsl: ApplicationDsl.() -> Unit) : ConfigurationDsl({}) { diff --git a/kofu/src/main/kotlin/org/springframework/fu/kofu/KofuApplication.kt b/kofu/src/main/kotlin/org/springframework/fu/kofu/KofuApplication.kt index 9c8fefc63..b14dc32de 100644 --- a/kofu/src/main/kotlin/org/springframework/fu/kofu/KofuApplication.kt +++ b/kofu/src/main/kotlin/org/springframework/fu/kofu/KofuApplication.kt @@ -9,7 +9,6 @@ import org.springframework.context.support.GenericApplicationContext /** * Kofu application that can be run parameterized with Spring profiles and/or command line arguments. * @see application - * @see reactiveWebApplication * @author Sebastien Deleuze */ abstract class KofuApplication(private val initializer: ApplicationContextInitializer) { diff --git a/kofu/src/main/kotlin/org/springframework/fu/kofu/webflux/WebFluxServerDsl.kt b/kofu/src/main/kotlin/org/springframework/fu/kofu/webflux/WebFluxServerDsl.kt index d808d0d4f..0de7636df 100644 --- a/kofu/src/main/kotlin/org/springframework/fu/kofu/webflux/WebFluxServerDsl.kt +++ b/kofu/src/main/kotlin/org/springframework/fu/kofu/webflux/WebFluxServerDsl.kt @@ -24,7 +24,8 @@ import org.springframework.web.server.WebFilter /** * Kofu DSL for WebFlux server. * - * This DSL to be used in [org.springframework.fu.kofu.reactiveWebApplication] configures a + * This DSL to be used in [org.springframework.fu.kofu.application] and a + * [org.springframework.boot.WebApplicationType.REACTIVE] parameter configures a * [WebFlux server](https://docs.spring.io/spring/docs/current/spring-framework-reference/webflux-reactive.html#spring-webflux). * * When no codec is configured, `String` and `Resource` ones are configured by default. diff --git a/kofu/src/main/kotlin/org/springframework/fu/kofu/webmvc/WebMvcServerDsl.kt b/kofu/src/main/kotlin/org/springframework/fu/kofu/webmvc/WebMvcServerDsl.kt index 22f44c375..191ed3609 100644 --- a/kofu/src/main/kotlin/org/springframework/fu/kofu/webmvc/WebMvcServerDsl.kt +++ b/kofu/src/main/kotlin/org/springframework/fu/kofu/webmvc/WebMvcServerDsl.kt @@ -22,8 +22,9 @@ import org.springframework.web.servlet.function.RouterFunctionDsl /** * Kofu DSL for Spring MVC server. * - * This DSL to be used in [org.springframework.fu.kofu.application] configures a Spring MVC server - * with functional routing. + * This DSL to be used in [org.springframework.fu.kofu.application] and a + * [org.springframework.boot.WebApplicationType.SERVLET] parameter configures + * a Spring MVC server with functional routing. * * Required dependencies can be retrieve using `org.springframework.boot:spring-boot-starter-web`. * @@ -104,7 +105,7 @@ open class WebMvcServerDsl(private val init: WebMvcServerDsl.() -> Unit): Abstra } /** - * Enable [org.springframework.core.codec.CharSequenceEncoder] and [org.springframework.core.codec.StringDecoder] + * Enable [org.springframework.http.converter.StringHttpMessageConverter] */ fun string() { StringConverterInitializer().initialize(context) @@ -136,14 +137,14 @@ open class WebMvcServerDsl(private val init: WebMvcServerDsl.() -> Unit): Abstra } /** - * Enable [org.springframework.boot.autoconfigure.web.servlet.AtomFeedHttpMessageConverter] + * Enable [org.springframework.http.converter.feed.AtomFeedHttpMessageConverter] */ fun atom() { AtomConverterInitializer().initialize(context) } /** - * Enable [org.springframework.boot.autoconfigure.web.servlet.RssConverterInitializer] + * Enable [org.springframework.http.converter.feed.RssChannelHttpMessageConverter] */ fun rss() { RssConverterInitializer().initialize(context) @@ -153,7 +154,7 @@ open class WebMvcServerDsl(private val init: WebMvcServerDsl.() -> Unit): Abstra /** * Declare a Spring MVC server. - * @see WebFluxServerDsl + * @see WebMvcServerDsl */ fun ConfigurationDsl.webMvc(dsl: WebMvcServerDsl.() -> Unit = {}) { WebMvcServerDsl(dsl).initialize(context) diff --git a/kofu/src/test/kotlin/org/springframework/fu/kofu/samples/application.kt b/kofu/src/test/kotlin/org/springframework/fu/kofu/samples/application.kt index cd32218cc..83a49eacb 100644 --- a/kofu/src/test/kotlin/org/springframework/fu/kofu/samples/application.kt +++ b/kofu/src/test/kotlin/org/springframework/fu/kofu/samples/application.kt @@ -60,7 +60,7 @@ private fun applicationDslWithConfiguration() { fun main(args: Array) = app.run() } -private fun webApplicationDsl() { +private fun webFluxApplicationDsl() { fun routes(htmlHandler: HtmlHandler, apiHandler: ApiHandler) = router { GET("/", htmlHandler::blog) GET("/article/{id}", htmlHandler::article) From ff978218a66c19702a597fc248a38fe4de29a16e Mon Sep 17 00:00:00 2001 From: Sebastien Deleuze Date: Tue, 14 May 2019 11:47:50 +0200 Subject: [PATCH 4/9] Add tests for the R2DBC mapping to simple types Closes #160 --- .../kotlin/com/sample/UserRepositoryTests.kt | 38 +++++++++++++++++++ .../kotlin/com/sample/UserRepositoryTests.kt | 35 +++++++++++++++++ 2 files changed, 73 insertions(+) create mode 100644 samples/kofu-coroutines-r2dbc/src/test/kotlin/com/sample/UserRepositoryTests.kt create mode 100644 samples/kofu-reactive-r2dbc/src/test/kotlin/com/sample/UserRepositoryTests.kt diff --git a/samples/kofu-coroutines-r2dbc/src/test/kotlin/com/sample/UserRepositoryTests.kt b/samples/kofu-coroutines-r2dbc/src/test/kotlin/com/sample/UserRepositoryTests.kt new file mode 100644 index 000000000..4b3cff0d8 --- /dev/null +++ b/samples/kofu-coroutines-r2dbc/src/test/kotlin/com/sample/UserRepositoryTests.kt @@ -0,0 +1,38 @@ +package com.sample + +import kotlinx.coroutines.runBlocking +import org.junit.jupiter.api.AfterAll +import org.junit.jupiter.api.Assertions.assertEquals +import org.junit.jupiter.api.BeforeAll +import org.junit.jupiter.api.Test +import org.springframework.beans.factory.getBean +import org.springframework.boot.WebApplicationType +import org.springframework.context.ConfigurableApplicationContext +import org.springframework.fu.kofu.application + +class UserRepositoryTests { + + private val dataApp = application(WebApplicationType.NONE) { + enable(dataConfig) + } + + private lateinit var context: ConfigurableApplicationContext + + @BeforeAll + fun beforeAll() { + context = app.run(profiles = "test") + } + + @Test + fun count() { + val repository = context.getBean() + runBlocking { + assertEquals(3, repository.count()) + } + } + + @AfterAll + fun afterAll() { + context.close() + } +} diff --git a/samples/kofu-reactive-r2dbc/src/test/kotlin/com/sample/UserRepositoryTests.kt b/samples/kofu-reactive-r2dbc/src/test/kotlin/com/sample/UserRepositoryTests.kt new file mode 100644 index 000000000..1361ff860 --- /dev/null +++ b/samples/kofu-reactive-r2dbc/src/test/kotlin/com/sample/UserRepositoryTests.kt @@ -0,0 +1,35 @@ +package com.sample + +import org.junit.jupiter.api.AfterAll +import org.junit.jupiter.api.Assertions.assertEquals +import org.junit.jupiter.api.BeforeAll +import org.junit.jupiter.api.Test +import org.springframework.beans.factory.getBean +import org.springframework.boot.WebApplicationType +import org.springframework.context.ConfigurableApplicationContext +import org.springframework.fu.kofu.application + +class UserRepositoryTests { + + private val dataApp = application(WebApplicationType.NONE) { + enable(dataConfig) + } + + private lateinit var context: ConfigurableApplicationContext + + @BeforeAll + fun beforeAll() { + context = app.run(profiles = "test") + } + + @Test + fun count() { + val repository = context.getBean() + assertEquals(3, repository.count().block()) + } + + @AfterAll + fun afterAll() { + context.close() + } +} From a85ca7124a240787717473e2536e4775901ad630 Mon Sep 17 00:00:00 2001 From: Sebastien Deleuze Date: Tue, 14 May 2019 12:24:38 +0200 Subject: [PATCH 5/9] Avoid exposing AbstractDsl#initialize in public API Closes #218 --- .../main/kotlin/org/springframework/fu/kofu/AbstractDsl.kt | 7 ++++--- .../kotlin/org/springframework/fu/kofu/ConfigurationDsl.kt | 2 +- .../kotlin/org/springframework/fu/kofu/KofuApplication.kt | 6 +++--- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/kofu/src/main/kotlin/org/springframework/fu/kofu/AbstractDsl.kt b/kofu/src/main/kotlin/org/springframework/fu/kofu/AbstractDsl.kt index b94cf1758..ba548e689 100644 --- a/kofu/src/main/kotlin/org/springframework/fu/kofu/AbstractDsl.kt +++ b/kofu/src/main/kotlin/org/springframework/fu/kofu/AbstractDsl.kt @@ -26,12 +26,12 @@ internal annotation class KofuMarker /** * Kofu DSL base class. * - * Make sure to invoke `super.initialize(context)` from [initialize] in inherited classes to get the context initialized. + * Make sure to invoke `super.initialize(context)` in inherited classes to get the context initialized. * * @author Sebastien Deleuze */ @KofuMarker -abstract class AbstractDsl : ApplicationContextInitializer { +abstract class AbstractDsl { @PublishedApi internal lateinit var context: GenericApplicationContext @@ -58,8 +58,9 @@ abstract class AbstractDsl : ApplicationContextInitializer { initialize(it) } } \ No newline at end of file diff --git a/kofu/src/main/kotlin/org/springframework/fu/kofu/ConfigurationDsl.kt b/kofu/src/main/kotlin/org/springframework/fu/kofu/ConfigurationDsl.kt index 936370e1a..47a5e86cf 100644 --- a/kofu/src/main/kotlin/org/springframework/fu/kofu/ConfigurationDsl.kt +++ b/kofu/src/main/kotlin/org/springframework/fu/kofu/ConfigurationDsl.kt @@ -36,7 +36,7 @@ open class ConfigurationDsl(private val dsl: ConfigurationDsl.() -> Unit): Abstr * @see configuration * @sample org.springframework.fu.kofu.samples.applicationDslWithConfiguration */ - fun enable(configuration: ApplicationContextInitializer) { + fun enable(configuration: AbstractDsl) { configuration.initialize(context) } diff --git a/kofu/src/main/kotlin/org/springframework/fu/kofu/KofuApplication.kt b/kofu/src/main/kotlin/org/springframework/fu/kofu/KofuApplication.kt index b14dc32de..703aa6080 100644 --- a/kofu/src/main/kotlin/org/springframework/fu/kofu/KofuApplication.kt +++ b/kofu/src/main/kotlin/org/springframework/fu/kofu/KofuApplication.kt @@ -11,7 +11,7 @@ import org.springframework.context.support.GenericApplicationContext * @see application * @author Sebastien Deleuze */ -abstract class KofuApplication(private val initializer: ApplicationContextInitializer) { +abstract class KofuApplication(private val initializer: AbstractDsl) { private var customizer: (ApplicationDsl.() -> Unit)? = null @@ -31,8 +31,8 @@ abstract class KofuApplication(private val initializer: ApplicationContextInitia if (!profiles.isEmpty()) { app.setAdditionalProfiles(*profiles.split(",").map { it.trim() }.toTypedArray()) } - app.addInitializers(initializer) - if (customizer != null) app.addInitializers(ApplicationDsl(customizer!!)) + app.addInitializers(initializer.toInitializer()) + if (customizer != null) app.addInitializers(ApplicationDsl(customizer!!).toInitializer()) System.setProperty("spring.backgroundpreinitializer.ignore", "true") System.setProperty("spring.main.lazy-initialization", "true") return app.run(*args) From b0e670a241a8be980d0d424f72b9b6208fe574e6 Mon Sep 17 00:00:00 2001 From: Sebastien Deleuze Date: Tue, 14 May 2019 13:23:16 +0200 Subject: [PATCH 6/9] Focus GraalVM native image support on spring-projects/spring-framework#22968 Closes #218 --- README.adoc | 8 ++------ samples/kofu-reactive-minimal/build.sh | 6 ------ 2 files changed, 2 insertions(+), 12 deletions(-) delete mode 100755 samples/kofu-reactive-minimal/build.sh diff --git a/README.adoc b/README.adoc index 28d7198d9..aaebeddda 100755 --- a/README.adoc +++ b/README.adoc @@ -4,8 +4,6 @@ image::https://ci.spring.io/api/v1/teams/spring-fu/pipelines/spring-fu/badge["Build Status", link="https://ci.spring.io/teams/spring-fu/pipelines/spring-fu"] -= Kofu configuration for Spring Boot - Spring Fu is an incubator for *Kofu* (*Ko* for Kotlin, *fu* for functional), which provides any API to configure Spring Boot applications programmatically with following characteristics: * Explicit configuration via a Kotlin DSL instead of auto-configuration @@ -22,12 +20,13 @@ Spring Fu is an incubator for *Kofu* (*Ko* for Kotlin, *fu* for functional), whi ** Spring Data JDBC https://github.com/spring-projects/spring-data-jdbc/blob/master/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/JdbcAggregateOperations.java[`JdbcAggregateOperations`] ** Spring Data NoSQL similar APIs for MongoDB, Redis and Cassandra * Configuration via Spring Security `security { }` DSL (WIP) - * https://github.com/oracle/graal/tree/master/substratevm[GraalVM native image] friendly * Fast startup and low memory consumption It is not intended to be used in production yet, but rather to incubate and get feedback and contributions from the community in order to hopefully reach a point where it can be integrated as part of Spring Boot. +If you are interested in running Spring application as GraalVM native images see https://github.com/spring-projects/spring-framework/issues/22968[this related issue]. + == Minimal application Here is a minimal sample application that is leveraging WebMvc.fn: @@ -197,9 +196,6 @@ This is a sample project for a Spring Boot Reactive web application with Kofu co `http://localhost:8080/` endpoint that displays "Hello world!" and an `http://localhost:8080/api` with a JSON endpoint. -You can run compile and run it as a https://github.com/oracle/graal/tree/master/substratevm[Graal native image] -(GraalVM 1.0 RC10+) by running `./build.sh` then `./com.sample.applicationkt`. - === kofu-reactive-mongodb https://github.com/spring-projects/spring-fu/tree/master/samples/kofu-reactive-mongodb[Browse source] | diff --git a/samples/kofu-reactive-minimal/build.sh b/samples/kofu-reactive-minimal/build.sh deleted file mode 100755 index 7b0070a37..000000000 --- a/samples/kofu-reactive-minimal/build.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/env sh - -./gradlew clean build -Pgraal=true -unzip build/libs/kofu-reactive-minimal.jar -d build/libs/kofu-reactive-minimal - -native-image --allow-incomplete-classpath -H:IncludeResources='META-INF/.*.json|META-INF/spring.factories|org/springframework/boot/logging/.*|kotlin/.*.kotlin_builtins' --delay-class-initialization-to-runtime=io.netty.handler.codec.http.HttpObjectEncoder,org.springframework.core.io.VfsUtils,org.springframework.format.support.DefaultFormattingConversionService --delay-class-initialization-to-runtime=io.netty.handler.codec.http.HttpObjectEncoder,org.springframework.core.io.VfsUtils,org.springframework.format.support.DefaultFormattingConversionService -H:ReflectionConfigurationFiles=graal/app.json,graal/boot.json,graal/framework.json,graal/netty.json,graal/log4j.json -Dio.netty.noUnsafe=true -H:+ReportUnsupportedElementsAtRuntime -Dfile.encoding=UTF-8 -cp ".:$(echo build/libs/kofu-reactive-minimal/BOOT-INF/lib/*.jar | tr ' ' ':')":build/libs/kofu-reactive-minimal/BOOT-INF/classes com.sample.ApplicationKt From 445d9d1da3de2b150a5b9b88aaf04626a0a654dc Mon Sep 17 00:00:00 2001 From: Sebastien Deleuze Date: Tue, 14 May 2019 13:30:30 +0200 Subject: [PATCH 7/9] Remove manual GraalVM native image configuration The focus is now on supporting GraalVM native image out of the box, see #146 and spring-projects/spring-framework#22968 for more details. Closes #198 --- samples/kofu-reactive-minimal/graal/app.json | 24 -- samples/kofu-reactive-minimal/graal/boot.json | 228 ------------------ .../graal/framework.json | 20 -- .../kofu-reactive-minimal/graal/log4j.json | 20 -- .../kofu-reactive-minimal/graal/netty.json | 14 -- 5 files changed, 306 deletions(-) delete mode 100644 samples/kofu-reactive-minimal/graal/app.json delete mode 100644 samples/kofu-reactive-minimal/graal/boot.json delete mode 100644 samples/kofu-reactive-minimal/graal/framework.json delete mode 100644 samples/kofu-reactive-minimal/graal/log4j.json delete mode 100644 samples/kofu-reactive-minimal/graal/netty.json diff --git a/samples/kofu-reactive-minimal/graal/app.json b/samples/kofu-reactive-minimal/graal/app.json deleted file mode 100644 index 9a1e43816..000000000 --- a/samples/kofu-reactive-minimal/graal/app.json +++ /dev/null @@ -1,24 +0,0 @@ -[ - { - "name": "com.sample.SampleService", - "allPublicConstructors" : true, - "allDeclaredConstructors" : true, - "allDeclaredMethods": true - }, - { - "name": "[Lcom.sample.SampleService;", - "allPublicConstructors" : true, - "allDeclaredConstructors" : true, - "allDeclaredMethods": true - }, - { - "name": "com.sample.SampleHandler", - "allDeclaredConstructors" : true, - "allDeclaredMethods": true - }, - { - "name": "com.sample.Sample", - "allDeclaredConstructors" : true, - "allDeclaredMethods": true - } -] \ No newline at end of file diff --git a/samples/kofu-reactive-minimal/graal/boot.json b/samples/kofu-reactive-minimal/graal/boot.json deleted file mode 100644 index 65076c0cd..000000000 --- a/samples/kofu-reactive-minimal/graal/boot.json +++ /dev/null @@ -1,228 +0,0 @@ -[ - { - "name": "org.springframework.boot.env.PropertiesPropertySourceLoader", - "allDeclaredConstructors": true - }, - { - "name": "org.springframework.boot.env.YamlPropertySourceLoader", - "allDeclaredConstructors": true - }, - { - "name": "org.springframework.boot.context.event.EventPublishingRunListener", - "allDeclaredConstructors": true - }, - { - "name": "org.springframework.boot.diagnostics.FailureAnalyzers", - "allDeclaredConstructors": true - }, - { - "name": "org.springframework.boot.context.ConfigurationWarningsApplicationContextInitializer", - "allDeclaredConstructors": true - }, - { - "name": "org.springframework.boot.context.ContextIdApplicationContextInitializer", - "allDeclaredConstructors": true - }, - { - "name": "org.springframework.boot.context.config.DelegatingApplicationContextInitializer", - "allDeclaredConstructors": true - }, - { - "name": "org.springframework.boot.ClearCachesApplicationListener", - "allDeclaredConstructors": true - }, - { - "name": "org.springframework.boot.builder.ParentContextCloserApplicationListener", - "allDeclaredConstructors": true - }, - { - "name": "org.springframework.boot.context.FileEncodingApplicationListener", - "allDeclaredConstructors": true - }, - { - "name": "org.springframework.boot.context.config.AnsiOutputApplicationListener", - "allDeclaredConstructors": true - }, - { - "name": "org.springframework.boot.context.config.ConfigFileApplicationListener", - "allDeclaredConstructors": true - }, - { - "name": "org.springframework.boot.context.config.DelegatingApplicationListener", - "allDeclaredConstructors": true - }, - { - "name": "org.springframework.boot.context.logging.ClasspathLoggingApplicationListener", - "allDeclaredConstructors": true - }, - { - "name": "org.springframework.boot.context.logging.LoggingApplicationListener", - "allDeclaredConstructors": true - }, - { - "name": "org.springframework.boot.cloud.CloudFoundryVcapEnvironmentPostProcessor", - "allDeclaredConstructors": true - }, - { - "name": "org.springframework.boot.env.SpringApplicationJsonEnvironmentPostProcessor", - "allDeclaredConstructors": true - }, - { - "name": "org.springframework.boot.env.SystemEnvironmentPropertySourceEnvironmentPostProcessor", - "allDeclaredConstructors": true - }, - { - "name": "org.springframework.boot.diagnostics.analyzer.BeanCurrentlyInCreationFailureAnalyzer", - "allDeclaredConstructors": true - }, - { - "name": "org.springframework.boot.diagnostics.analyzer.BeanDefinitionOverrideFailureAnalyzer", - "allDeclaredConstructors": true - }, - { - "name": "org.springframework.boot.diagnostics.analyzer.BeanNotOfRequiredTypeFailureAnalyzer", - "allDeclaredConstructors": true - }, - { - "name": "org.springframework.boot.diagnostics.analyzer.BindFailureAnalyzer", - "allDeclaredConstructors": true - }, - { - "name": "org.springframework.boot.diagnostics.analyzer.BindValidationFailureAnalyzer", - "allDeclaredConstructors": true - }, - { - "name": "org.springframework.boot.diagnostics.analyzer.UnboundConfigurationPropertyFailureAnalyzer", - "allDeclaredConstructors": true - }, - { - "name": "org.springframework.boot.diagnostics.analyzer.ConnectorStartFailureAnalyzer", - "allDeclaredConstructors": true - }, - { - "name": "org.springframework.boot.diagnostics.analyzer.NoSuchMethodFailureAnalyzer", - "allDeclaredConstructors": true - }, - { - "name": "org.springframework.boot.diagnostics.analyzer.NoUniqueBeanDefinitionFailureAnalyzer", - "allDeclaredConstructors": true - }, - { - "name": "org.springframework.boot.diagnostics.analyzer.PortInUseFailureAnalyzer", - "allDeclaredConstructors": true - }, - { - "name": "org.springframework.boot.diagnostics.analyzer.ValidationExceptionFailureAnalyzer", - "methods": [ - { - "name": "", - "parameterTypes": [] - } - ] - }, - { - "name": "org.springframework.boot.diagnostics.analyzer.InvalidConfigurationPropertyNameFailureAnalyzer", - "allDeclaredConstructors": true - }, - { - "name": "org.springframework.boot.diagnostics.analyzer.InvalidConfigurationPropertyValueFailureAnalyzer", - "allDeclaredConstructors": true - }, - { - "name": "org.springframework.boot.diagnostics.LoggingFailureAnalysisReporter", - "allDeclaredConstructors": true - }, - { - "name": "org.springframework.boot.autoconfigure.SharedMetadataReaderFactoryContextInitializer", - "allDeclaredConstructors": true - }, - { - "name": "org.springframework.boot.autoconfigure.SharedMetadataReaderFactoryContextInitializer$SharedMetadataReaderFactoryBean", - "allDeclaredConstructors": true - }, - { - "name": "org.springframework.boot.autoconfigure.logging.ConditionEvaluationReportLoggingListener", - "allDeclaredConstructors": true - }, - { - "name": "org.springframework.boot.autoconfigure.BackgroundPreinitializer", - "allDeclaredConstructors": true - }, - { - "name": "org.springframework.boot.autoconfigure.condition.ConditionEvaluationReportAutoConfigurationImportListener", - "allDeclaredConstructors": true - }, - { - "name": "org.springframework.boot.autoconfigure.condition.OnClassCondition", - "allDeclaredConstructors": true - }, - { - "name": "org.springframework.boot.autoconfigure.context.MessageSourceAutoConfiguration", - "allDeclaredConstructors": true - }, - { - "name": "org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration", - "allDeclaredConstructors": true - }, - { - "name": "org.springframework.boot.web.context.ServerPortInfoApplicationContextInitializer", - "allDeclaredConstructors": true - }, - { - "name": "org.springframework.boot.liquibase.LiquibaseServiceLocatorApplicationListener", - "allDeclaredConstructors": true - }, - { - "name": "org.springframework.boot.autoconfigure.freemarker.FreeMarkerTemplateAvailabilityProvider", - "allDeclaredConstructors": true - }, - { - "name": "org.springframework.boot.autoconfigure.mustache.MustacheTemplateAvailabilityProvider", - "allDeclaredConstructors": true - }, - { - "name": "org.springframework.boot.autoconfigure.groovy.template.GroovyTemplateAvailabilityProvider", - "allDeclaredConstructors": true - }, - { - "name": "org.springframework.boot.autoconfigure.thymeleaf.ThymeleafTemplateAvailabilityProvider", - "allDeclaredConstructors": true - }, - { - "name": "org.springframework.boot.autoconfigure.web.servlet.JspTemplateAvailabilityProvider", - "allDeclaredConstructors": true - }, - { - "name": "org.springframework.boot.web.reactive.context.ReactiveWebServerApplicationContext", - "methods": [ - { "name": "", "parameterTypes": [] } - ] - }, - { - "name": "org.springframework.boot.logging.java.JavaLoggingSystem", - "allDeclaredConstructors" : true, - "allPublicConstructors" : true, - "allPublicFields": true, - "allPublicMethods": true, - "allDeclaredMethods": true, - "allDeclaredFields": true - }, - { - "name": "java.util.logging.ConsoleHandler", - "allDeclaredConstructors" : true, - "allPublicConstructors" : true, - "allPublicFields": true, - "allPublicMethods": true, - "allDeclaredMethods": true, - "allDeclaredFields": true - }, - { - "name": "java.util.logging.LogManager", - "allDeclaredConstructors" : true, - "allPublicConstructors" : true, - "allPublicFields": true, - "allPublicMethods": true, - "allDeclaredMethods": true, - "allDeclaredFields": true - } -] diff --git a/samples/kofu-reactive-minimal/graal/framework.json b/samples/kofu-reactive-minimal/graal/framework.json deleted file mode 100644 index 4d1bcbbde..000000000 --- a/samples/kofu-reactive-minimal/graal/framework.json +++ /dev/null @@ -1,20 +0,0 @@ -[ - { - "name": "org.springframework.context.support.GenericApplicationContext", - "methods": [ - { "name": "", "parameterTypes": [] } - ] - }, - { - "name": "org.springframework.context.annotation.ConfigurationClassPostProcessor", - "methods": [ - { "name": "", "parameterTypes": [] } - ] - }, - { - "name": "org.springframework.http.codec.support.DefaultServerCodecConfigurer", - "methods": [ - { "name": "", "parameterTypes": [] } - ] - } -] \ No newline at end of file diff --git a/samples/kofu-reactive-minimal/graal/log4j.json b/samples/kofu-reactive-minimal/graal/log4j.json deleted file mode 100644 index bfd076984..000000000 --- a/samples/kofu-reactive-minimal/graal/log4j.json +++ /dev/null @@ -1,20 +0,0 @@ -[ - { - "name": "org.apache.logging.log4j.message.ReusableMessageFactory", - "methods": [ - { "name": "", "parameterTypes": [] } - ] - }, - { - "name": "org.apache.logging.log4j.message.DefaultFlowMessageFactory", - "methods": [ - { "name": "", "parameterTypes": [] } - ] - }, - { - "name": "org.apache.logging.log4j.message.ParameterizedMessageFactory", - "methods": [ - { "name": "", "parameterTypes": [] } - ] - } -] \ No newline at end of file diff --git a/samples/kofu-reactive-minimal/graal/netty.json b/samples/kofu-reactive-minimal/graal/netty.json deleted file mode 100644 index b53be8f75..000000000 --- a/samples/kofu-reactive-minimal/graal/netty.json +++ /dev/null @@ -1,14 +0,0 @@ -[ - { - "name": "io.netty.channel.socket.nio.NioServerSocketChannel", - "methods": [ - { "name": "", "parameterTypes": [] } - ] - }, - { - "name": "io.netty.channel.socket.nio.NioSocketChannel", - "methods": [ - { "name": "", "parameterTypes": [] } - ] - } -] \ No newline at end of file From cbd79c02de828a853e1d28e242d42fe6680f64e0 Mon Sep 17 00:00:00 2001 From: Sebastien Deleuze Date: Tue, 14 May 2019 13:32:26 +0200 Subject: [PATCH 8/9] Polishing --- README.adoc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.adoc b/README.adoc index aaebeddda..3e97c346a 100755 --- a/README.adoc +++ b/README.adoc @@ -4,7 +4,7 @@ image::https://ci.spring.io/api/v1/teams/spring-fu/pipelines/spring-fu/badge["Build Status", link="https://ci.spring.io/teams/spring-fu/pipelines/spring-fu"] -Spring Fu is an incubator for *Kofu* (*Ko* for Kotlin, *fu* for functional), which provides any API to configure Spring Boot applications programmatically with following characteristics: +Spring Fu is an incubator for *Kofu* (*Ko* for Kotlin, *fu* for functional), which provides a Kotlin API to configure Spring Boot applications programmatically with following characteristics: * Explicit configuration via a Kotlin DSL instead of auto-configuration * Leverages Spring Framework 5.x https://docs.spring.io/spring/docs/5.2.0.BUILD-SNAPSHOT/spring-framework-reference/languages.html#kotlin-bean-definition-dsl[Functional bean configuration] instead of annotations @@ -25,7 +25,7 @@ Spring Fu is an incubator for *Kofu* (*Ko* for Kotlin, *fu* for functional), whi It is not intended to be used in production yet, but rather to incubate and get feedback and contributions from the community in order to hopefully reach a point where it can be integrated as part of Spring Boot. -If you are interested in running Spring application as GraalVM native images see https://github.com/spring-projects/spring-framework/issues/22968[this related issue]. +If you are interested in running Spring application as GraalVM native images see https://github.com/spring-projects/spring-framework/issues/22968[this dedicated Spring Framework issue]. == Minimal application From 056b2351a066b1741f7ce50e173c3d667dbf9357 Mon Sep 17 00:00:00 2001 From: Sebastien Deleuze Date: Tue, 14 May 2019 13:35:23 +0200 Subject: [PATCH 9/9] Polishing --- README.adoc | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/README.adoc b/README.adoc index 3e97c346a..e29a6ef2c 100755 --- a/README.adoc +++ b/README.adoc @@ -7,18 +7,17 @@ image::https://ci.spring.io/api/v1/teams/spring-fu/pipelines/spring-fu/badge["Bu Spring Fu is an incubator for *Kofu* (*Ko* for Kotlin, *fu* for functional), which provides a Kotlin API to configure Spring Boot applications programmatically with following characteristics: * Explicit configuration via a Kotlin DSL instead of auto-configuration - * Leverages Spring Framework 5.x https://docs.spring.io/spring/docs/5.2.0.BUILD-SNAPSHOT/spring-framework-reference/languages.html#kotlin-bean-definition-dsl[Functional bean configuration] instead of annotations + * Leverages Spring Framework 5 https://docs.spring.io/spring/docs/5.2.0.BUILD-SNAPSHOT/spring-framework-reference/languages.html#kotlin-bean-definition-dsl[functional bean configuration] instead of annotations * Allows to define custom configuration slices (useful for more focused and efficient testing) * Great discoverability via code auto-complete * https://docs.spring.io/spring/docs/5.2.0.BUILD-SNAPSHOT/spring-framework-reference/languages.html#router-dsl[Web functional routing] instead of `@Controller` available in 3 flavors: - Expose the same Web functional routing programming model in 3 flavors: ** WebMvc.fn (functional variant Spring MVC) ** WebFlux.fn with Reactor declarative-style API (`Mono` and `Flux`) ** WebFlux.fn with Coroutines imperative-style API (https://spring.io/blog/2019/04/12/going-reactive-with-spring-coroutines-and-kotlin-flow[using suspending functions and Kotlin `Flow`]) * Persistence via Spring Data functional APIs like: ** https://spring.io/projects/spring-data-r2dbc[Spring Data R2DBC `DatabaseClient`] ** Spring Data JDBC https://github.com/spring-projects/spring-data-jdbc/blob/master/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/JdbcAggregateOperations.java[`JdbcAggregateOperations`] - ** Spring Data NoSQL similar APIs for MongoDB, Redis and Cassandra + ** Spring Data NoSQL `*Template` APIs for MongoDB, Redis and Cassandra * Configuration via Spring Security `security { }` DSL (WIP) * Fast startup and low memory consumption