Commit fd07bfd8 authored by Stephane Nicoll's avatar Stephane Nicoll

Polish "Add runApplication() Kotlin top level function"

Closes gh-10511
parent 605ede88
...@@ -2245,26 +2245,6 @@ ...@@ -2245,26 +2245,6 @@
<artifactId>jdom2</artifactId> <artifactId>jdom2</artifactId>
<version>${jdom2.version}</version> <version>${jdom2.version}</version>
</dependency> </dependency>
<dependency>
<groupId>org.jolokia</groupId>
<artifactId>jolokia-core</artifactId>
<version>${jolokia.version}</version>
</dependency>
<dependency>
<groupId>org.jooq</groupId>
<artifactId>jooq</artifactId>
<version>${jooq.version}</version>
</dependency>
<dependency>
<groupId>org.jooq</groupId>
<artifactId>jooq-meta</artifactId>
<version>${jooq.version}</version>
</dependency>
<dependency>
<groupId>org.jooq</groupId>
<artifactId>jooq-codegen</artifactId>
<version>${jooq.version}</version>
</dependency>
<dependency> <dependency>
<groupId>org.jetbrains.kotlin</groupId> <groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-reflect</artifactId> <artifactId>kotlin-reflect</artifactId>
...@@ -2285,6 +2265,26 @@ ...@@ -2285,6 +2265,26 @@
<artifactId>kotlin-stdlib-jre8</artifactId> <artifactId>kotlin-stdlib-jre8</artifactId>
<version>${kotlin.version}</version> <version>${kotlin.version}</version>
</dependency> </dependency>
<dependency>
<groupId>org.jolokia</groupId>
<artifactId>jolokia-core</artifactId>
<version>${jolokia.version}</version>
</dependency>
<dependency>
<groupId>org.jooq</groupId>
<artifactId>jooq</artifactId>
<version>${jooq.version}</version>
</dependency>
<dependency>
<groupId>org.jooq</groupId>
<artifactId>jooq-meta</artifactId>
<version>${jooq.version}</version>
</dependency>
<dependency>
<groupId>org.jooq</groupId>
<artifactId>jooq-codegen</artifactId>
<version>${jooq.version}</version>
</dependency>
<dependency> <dependency>
<groupId>org.liquibase</groupId> <groupId>org.liquibase</groupId>
<artifactId>liquibase-core</artifactId> <artifactId>liquibase-core</artifactId>
...@@ -2881,6 +2881,11 @@ ...@@ -2881,6 +2881,11 @@
<build> <build>
<pluginManagement> <pluginManagement>
<plugins> <plugins>
<plugin>
<groupId>kotlin-maven-plugin</groupId>
<artifactId>org.jetbrains.kotlin</artifactId>
<version>${kotlin.version}</version>
</plugin>
<plugin> <plugin>
<groupId>org.jooq</groupId> <groupId>org.jooq</groupId>
<artifactId>jooq-codegen-maven</artifactId> <artifactId>jooq-codegen-maven</artifactId>
...@@ -3024,11 +3029,6 @@ ...@@ -3024,11 +3029,6 @@
<artifactId>flyway-maven-plugin</artifactId> <artifactId>flyway-maven-plugin</artifactId>
<version>${flyway.version}</version> <version>${flyway.version}</version>
</plugin> </plugin>
<plugin>
<groupId>kotlin-maven-plugin</groupId>
<artifactId>org.jetbrains.kotlin</artifactId>
<version>${kotlin.version}</version>
</plugin>
<plugin> <plugin>
<groupId>pl.project13.maven</groupId> <groupId>pl.project13.maven</groupId>
<artifactId>git-commit-id-plugin</artifactId> <artifactId>git-commit-id-plugin</artifactId>
......
...@@ -268,6 +268,14 @@ ...@@ -268,6 +268,14 @@
<build> <build>
<pluginManagement> <pluginManagement>
<plugins> <plugins>
<plugin>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-maven-plugin</artifactId>
<version>${kotlin.version}</version>
<configuration>
<jvmTarget>${java.version}</jvmTarget>
</configuration>
</plugin>
<plugin> <plugin>
<groupId>org.asciidoctor</groupId> <groupId>org.asciidoctor</groupId>
<artifactId>asciidoctor-maven-plugin</artifactId> <artifactId>asciidoctor-maven-plugin</artifactId>
......
...@@ -60,6 +60,30 @@ ...@@ -60,6 +60,30 @@
<pluginManagement> <pluginManagement>
<plugins> <plugins>
<!-- Apply more sensible defaults for user projects --> <!-- Apply more sensible defaults for user projects -->
<plugin>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-maven-plugin</artifactId>
<version>${kotlin.version}</version>
<configuration>
<jvmTarget>${java.version}</jvmTarget>
</configuration>
<executions>
<execution>
<id>compile</id>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
<execution>
<id>test-compile</id>
<phase>test-compile</phase>
<goals>
<goal>test-compile</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId> <artifactId>maven-compiler-plugin</artifactId>
......
...@@ -13,79 +13,6 @@ ...@@ -13,79 +13,6 @@
<properties> <properties>
<main.basedir>${basedir}/../..</main.basedir> <main.basedir>${basedir}/../..</main.basedir>
</properties> </properties>
<build>
<plugins>
<plugin>
<artifactId>kotlin-maven-plugin</artifactId>
<groupId>org.jetbrains.kotlin</groupId>
<version>${kotlin.version}</version>
<configuration>
<jvmTarget>${java.version}</jvmTarget>
</configuration>
<executions>
<execution>
<id>compile</id>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
<configuration>
<sourceDirs>
<sourceDir>${project.basedir}/src/main/kotlin</sourceDir>
<sourceDir>${project.basedir}/src/main/java</sourceDir>
</sourceDirs>
</configuration>
</execution>
<execution>
<id>test-compile</id>
<phase>test-compile</phase>
<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>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
<parameters>true</parameters>
</configuration>
<executions>
<execution>
<id>default-compile</id>
<phase>none</phase>
</execution>
<execution>
<id>default-testCompile</id>
<phase>none</phase>
</execution>
<execution>
<id>java-compile</id>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
<execution>
<id>java-test-compile</id>
<phase>test-compile</phase>
<goals>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies> <dependencies>
<!-- Compile --> <!-- Compile -->
<dependency> <dependency>
...@@ -460,4 +387,68 @@ ...@@ -460,4 +387,68 @@
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
</dependencies> </dependencies>
<build>
<plugins>
<plugin>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-maven-plugin</artifactId>
<executions>
<execution>
<id>compile</id>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
<configuration>
<sourceDirs>
<sourceDir>${project.basedir}/src/main/kotlin</sourceDir>
<sourceDir>${project.basedir}/src/main/java</sourceDir>
</sourceDirs>
</configuration>
</execution>
<execution>
<id>test-compile</id>
<phase>test-compile</phase>
<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>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<executions>
<execution>
<id>default-compile</id>
<phase>none</phase>
</execution>
<execution>
<id>default-testCompile</id>
<phase>none</phase>
</execution>
<execution>
<id>java-compile</id>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
<execution>
<id>java-test-compile</id>
<phase>test-compile</phase>
<goals>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project> </project>
...@@ -17,12 +17,14 @@ ...@@ -17,12 +17,14 @@
package org.springframework.boot package org.springframework.boot
import org.springframework.context.ConfigurableApplicationContext import org.springframework.context.ConfigurableApplicationContext
import kotlin.reflect.KClass import kotlin.reflect.KClass
/** /**
* Top level function acting as a Kotlin shortcut allowing to write `runApplication<FooApplication>(arg1, arg2)` * Top level function acting as a Kotlin shortcut allowing to write
* instead of `SpringApplication.run(FooApplication::class.java, arg1, arg2)`. * `runApplication<FooApplication>(arg1, arg2)` instead of
* `SpringApplication.run(FooApplication::class.java, arg1, arg2)`.
* *
* @author Sebastien Deleuze * @author Sebastien Deleuze
* @since 2.0.0 * @since 2.0.0
...@@ -31,8 +33,10 @@ inline fun <reified T : Any> runApplication(vararg args: String): ConfigurableAp ...@@ -31,8 +33,10 @@ inline fun <reified T : Any> runApplication(vararg args: String): ConfigurableAp
SpringApplication.run(T::class.java, *args) SpringApplication.run(T::class.java, *args)
/** /**
* Top level function acting as a Kotlin shortcut allowing to write `runApplication<FooApplication>(arg1, arg2) { // SpringApplication customization ... }` * Top level function acting as a Kotlin shortcut allowing to write
* instead of instantiating `SpringApplication` class, customize it and then invoking `run(arg1, arg2)`. * `runApplication<FooApplication>(arg1, arg2) { // SpringApplication customization ... }`
* instead of instantiating `SpringApplication` class, customize it and then invoking
* `run(arg1, arg2)`.
* *
* @author Sebastien Deleuze * @author Sebastien Deleuze
* @since 2.0.0 * @since 2.0.0
...@@ -44,7 +48,8 @@ inline fun <reified T : Any> runApplication(vararg args: String, init: SpringApp ...@@ -44,7 +48,8 @@ inline fun <reified T : Any> runApplication(vararg args: String, init: SpringApp
/** /**
* Top level function acting as a Kotlin shortcut allowing to write * Top level function acting as a Kotlin shortcut allowing to write
* `runApplication(arrayOf(FooApplication::class, FooConfiguration::class), arg1, arg2) { // Optional SpringApplication customization ... }` * `runApplication(arrayOf(FooApplication::class, FooConfiguration::class), arg1, arg2) { // Optional SpringApplication customization ... }`
* instead of instantiating `SpringApplication` class, customize it and then invoking `run(arrayOf(arg1, arg2))`.` * instead of instantiating `SpringApplication` class, customize it and then invoking
* `run(arrayOf(arg1, arg2))`.`
* *
* @author Sebastien Deleuze * @author Sebastien Deleuze
* @since 2.0.0 * @since 2.0.0
......
...@@ -15,10 +15,14 @@ ...@@ -15,10 +15,14 @@
*/ */
package org.springframework.boot package org.springframework.boot
import org.junit.Assert.* import org.junit.Assert.assertArrayEquals
import org.junit.Assert.assertEquals
import org.junit.Assert.assertNotNull
import org.junit.Assert.assertTrue
import org.junit.Test import org.junit.Test
import org.springframework.beans.factory.getBean import org.springframework.beans.factory.getBean
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory import org.springframework.boot.web.servlet.server.MockServletWebServerFactory
import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration import org.springframework.context.annotation.Configuration
import org.springframework.core.env.StandardEnvironment import org.springframework.core.env.StandardEnvironment
...@@ -110,8 +114,8 @@ class SpringApplicationExtensionsTests { ...@@ -110,8 +114,8 @@ class SpringApplicationExtensionsTests {
internal open class ExampleWebConfig { internal open class ExampleWebConfig {
@Bean @Bean
open fun webServer(): TomcatServletWebServerFactory { open fun webServer(): MockServletWebServerFactory {
return TomcatServletWebServerFactory(0) return MockServletWebServerFactory()
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment