Merge pull request #388 from sdeleuze:kotlin-1.1.1

* pr/388:
  Polish contribution
  Upgrade to Kotlin 1.1.1
This commit is contained in:
Stephane Nicoll 2017-03-15 16:51:42 +01:00
commit 36f7fd15a2
16 changed files with 345 additions and 13 deletions

View File

@ -429,6 +429,11 @@ public class ProjectGenerator {
// New Servlet Initializer location
model.put("newServletInitializer", isNewServletInitializerAvailable(request));
// Java versions
model.put("isJava6", isJavaVersion(request, "1.6"));
model.put("isJava7", isJavaVersion(request, "1.7"));
model.put("isJava8", isJavaVersion(request, "1.8"));
// Append the project request to the model
BeanWrapperImpl bean = new BeanWrapperImpl(request);
for (PropertyDescriptor descriptor : bean.getPropertyDescriptors()) {
@ -505,6 +510,10 @@ public class ProjectGenerator {
return VERSION_1_5_0_M1.compareTo(bootVersion) <= 0;
}
private static boolean isJavaVersion(ProjectRequest request, String version) {
return request.getJavaVersion().equals(version);
}
private byte[] doGenerateMavenPom(Map<String, Object> model) {
return templateRenderer.process("starter-pom.xml", model).getBytes();
}

View File

@ -42,7 +42,13 @@ apply plugin: 'war'
{{/war}}
version = '{{version}}'
sourceCompatibility = {{javaVersion}}
sourceCompatibility = {{javaVersion}}{{#kotlin}}{{#isJava8}}
compileKotlin {
kotlinOptions.jvmTarget = "1.8"
}
compileTestKotlin {
kotlinOptions.jvmTarget = "1.8"
}{{/isJava8}}{{/kotlin}}
repositories {
mavenCentral()
@ -71,7 +77,15 @@ dependencies {
compile('org.codehaus.groovy:groovy')
{{/groovy}}
{{#kotlin}}
{{#isJava6}}
compile("org.jetbrains.kotlin:kotlin-stdlib:${kotlinVersion}")
{{/isJava6}}
{{#isJava7}}
compile("org.jetbrains.kotlin:kotlin-stdlib-jre7:${kotlinVersion}")
{{/isJava7}}
{{#isJava8}}
compile("org.jetbrains.kotlin:kotlin-stdlib-jre8:${kotlinVersion}")
{{/isJava8}}
compile("org.jetbrains.kotlin:kotlin-reflect:${kotlinVersion}")
{{/kotlin}}
{{#runtimeDependencies}}

View File

@ -49,7 +49,15 @@
{{#kotlin}}
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
{{#isJava6}}
<artifactId>kotlin-stdlib</artifactId>
{{/isJava6}}
{{#isJava7}}
<artifactId>kotlin-stdlib-jre7</artifactId>
{{/isJava7}}
{{#isJava8}}
<artifactId>kotlin-stdlib-jre8</artifactId>
{{/isJava8}}
<version>${kotlin.version}</version>
</dependency>
<dependency>
@ -174,6 +182,9 @@
<compilerPlugins>
<plugin>spring</plugin>
</compilerPlugins>
{{#isJava8}}
<jvmTarget>1.8</jvmTarget>
{{/isJava8}}
</configuration>
<executions>
<execution>

View File

@ -170,6 +170,26 @@ public class ProjectGeneratorBuildTests extends AbstractProjectGeneratorTests {
"project/" + build + "/bom-ordering-" + assertFileName));
}
@Test
public void kotlinJava6() {
ProjectRequest request = createProjectRequest();
request.setLanguage("kotlin");
request.setJavaVersion("1.6");
ProjectAssert project = generateProject(request);
project.sourceCodeAssert(fileName).equalsTo(new ClassPathResource(
"project/" + build + "/kotlin-java6-" + assertFileName));
}
@Test
public void kotlinJava7() {
ProjectRequest request = createProjectRequest();
request.setLanguage("kotlin");
request.setJavaVersion("1.7");
ProjectAssert project = generateProject(request);
project.sourceCodeAssert(fileName).equalsTo(new ClassPathResource(
"project/" + build + "/kotlin-java7-" + assertFileName));
}
@Override
public ProjectRequest createProjectRequest(String... styles) {
ProjectRequest request = super.createProjectRequest(styles);

View File

@ -77,7 +77,7 @@ public class InitializrMetadataTestBuilder {
public InitializrMetadataTestBuilder addDefaults() {
return addDefaultTypes().addDefaultPackagings().addDefaultJavaVersions()
.addDefaultLanguages().addDefaultBootVersions()
.setGradleEnv("0.5.1.RELEASE").setKotlinEnv("1.0.1");
.setGradleEnv("0.5.1.RELEASE").setKotlinEnv("1.1.1");
}
public InitializrMetadataTestBuilder addDefaultTypes() {

View File

@ -0,0 +1,36 @@
buildscript {
ext {
kotlinVersion = '1.1.1'
springBootVersion = '1.2.3.RELEASE'
}
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
classpath('io.spring.gradle:dependency-management-plugin:0.5.1.RELEASE')
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:${kotlinVersion}")
classpath("org.jetbrains.kotlin:kotlin-allopen:${kotlinVersion}")
}
}
apply plugin: 'kotlin'
apply plugin: 'kotlin-spring'
apply plugin: 'eclipse'
apply plugin: 'spring-boot'
apply plugin: 'io.spring.dependency-management'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = 1.6
repositories {
mavenCentral()
}
dependencies {
compile('org.springframework.boot:spring-boot-starter')
compile("org.jetbrains.kotlin:kotlin-stdlib:${kotlinVersion}")
compile("org.jetbrains.kotlin:kotlin-reflect:${kotlinVersion}")
testCompile('org.springframework.boot:spring-boot-starter-test')
}

View File

@ -0,0 +1,36 @@
buildscript {
ext {
kotlinVersion = '1.1.1'
springBootVersion = '1.2.3.RELEASE'
}
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
classpath('io.spring.gradle:dependency-management-plugin:0.5.1.RELEASE')
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:${kotlinVersion}")
classpath("org.jetbrains.kotlin:kotlin-allopen:${kotlinVersion}")
}
}
apply plugin: 'kotlin'
apply plugin: 'kotlin-spring'
apply plugin: 'eclipse'
apply plugin: 'spring-boot'
apply plugin: 'io.spring.dependency-management'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = 1.7
repositories {
mavenCentral()
}
dependencies {
compile('org.springframework.boot:spring-boot-starter')
compile("org.jetbrains.kotlin:kotlin-stdlib-jre7:${kotlinVersion}")
compile("org.jetbrains.kotlin:kotlin-reflect:${kotlinVersion}")
testCompile('org.springframework.boot:spring-boot-starter-test')
}

View File

@ -1,6 +1,6 @@
buildscript {
ext {
kotlinVersion = '1.0.1'
kotlinVersion = '1.1.1'
springBootVersion = '1.2.3.RELEASE'
}
repositories {
@ -22,6 +22,12 @@ apply plugin: 'io.spring.dependency-management'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = 1.8
compileKotlin {
kotlinOptions.jvmTarget = "1.8"
}
compileTestKotlin {
kotlinOptions.jvmTarget = "1.8"
}
repositories {
mavenCentral()
@ -30,7 +36,7 @@ repositories {
dependencies {
compile('org.springframework.boot:spring-boot-starter')
compile("org.jetbrains.kotlin:kotlin-stdlib:${kotlinVersion}")
compile("org.jetbrains.kotlin:kotlin-stdlib-jre8:${kotlinVersion}")
compile("org.jetbrains.kotlin:kotlin-reflect:${kotlinVersion}")
testCompile('org.springframework.boot:spring-boot-starter-test')
}

View File

@ -22,7 +22,7 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<kotlin.version>1.0.1</kotlin.version>
<kotlin.version>1.1.1</kotlin.version>
</properties>
<dependencies>
@ -32,7 +32,7 @@
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib</artifactId>
<artifactId>kotlin-stdlib-jre8</artifactId>
<version>${kotlin.version}</version>
</dependency>
<dependency>
@ -64,6 +64,7 @@
<compilerPlugins>
<plugin>spring</plugin>
</compilerPlugins>
<jvmTarget>1.8</jvmTarget>
</configuration>
<executions>
<execution>

View File

@ -1,6 +1,6 @@
buildscript {
ext {
kotlinVersion = '1.0.1'
kotlinVersion = '1.1.1'
springBootVersion = '1.2.3.RELEASE'
}
repositories {
@ -23,6 +23,12 @@ apply plugin: 'war'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = 1.8
compileKotlin {
kotlinOptions.jvmTarget = "1.8"
}
compileTestKotlin {
kotlinOptions.jvmTarget = "1.8"
}
repositories {
mavenCentral()
@ -34,7 +40,7 @@ configurations {
dependencies {
compile('org.springframework.boot:spring-boot-starter-web')
compile("org.jetbrains.kotlin:kotlin-stdlib:${kotlinVersion}")
compile("org.jetbrains.kotlin:kotlin-stdlib-jre8:${kotlinVersion}")
compile("org.jetbrains.kotlin:kotlin-reflect:${kotlinVersion}")
providedRuntime('org.springframework.boot:spring-boot-starter-tomcat')
testCompile('org.springframework.boot:spring-boot-starter-test')

View File

@ -22,7 +22,7 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<kotlin.version>1.0.1</kotlin.version>
<kotlin.version>1.1.1</kotlin.version>
</properties>
<dependencies>
@ -32,7 +32,7 @@
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib</artifactId>
<artifactId>kotlin-stdlib-jre8</artifactId>
<version>${kotlin.version}</version>
</dependency>
<dependency>
@ -69,6 +69,7 @@
<compilerPlugins>
<plugin>spring</plugin>
</compilerPlugins>
<jvmTarget>1.8</jvmTarget>
</configuration>
<executions>
<execution>

View File

@ -0,0 +1,96 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>demo</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>demo</name>
<description>Demo project for Spring Boot</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.2.3.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.6</java.version>
<kotlin.version>1.1.1</kotlin.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib</artifactId>
<version>${kotlin.version}</version>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-reflect</artifactId>
<version>${kotlin.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<sourceDirectory>${project.basedir}/src/main/kotlin</sourceDirectory>
<testSourceDirectory>${project.basedir}/src/test/kotlin</testSourceDirectory>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<artifactId>kotlin-maven-plugin</artifactId>
<groupId>org.jetbrains.kotlin</groupId>
<version>${kotlin.version}</version>
<configuration>
<compilerPlugins>
<plugin>spring</plugin>
</compilerPlugins>
</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>
<dependencies>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-maven-allopen</artifactId>
<version>${kotlin.version}</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
</project>

View File

@ -0,0 +1,96 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>demo</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>demo</name>
<description>Demo project for Spring Boot</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.2.3.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.7</java.version>
<kotlin.version>1.1.1</kotlin.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib-jre7</artifactId>
<version>${kotlin.version}</version>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-reflect</artifactId>
<version>${kotlin.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<sourceDirectory>${project.basedir}/src/main/kotlin</sourceDirectory>
<testSourceDirectory>${project.basedir}/src/test/kotlin</testSourceDirectory>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<artifactId>kotlin-maven-plugin</artifactId>
<groupId>org.jetbrains.kotlin</groupId>
<version>${kotlin.version}</version>
<configuration>
<compilerPlugins>
<plugin>spring</plugin>
</compilerPlugins>
</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>
<dependencies>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-maven-allopen</artifactId>
<version>${kotlin.version}</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
</project>

View File

@ -91,7 +91,7 @@ initializr:
gradle:
dependency-management-plugin-version: 0.6.0.RELEASE
kotlin:
version: 1.0.6
version: 1.1.1
dependencies:
- name: Core
content:

View File

@ -185,7 +185,7 @@ public class ProjectGenerationSmokeTests
projectAssert.hasBaseDir("demo").isMavenProject().isKotlinProject()
.hasStaticAndTemplatesResources(false).pomAssert().hasDependenciesCount(4)
.hasSpringBootStarterRootDependency().hasSpringBootStarterTest()
.hasDependency("org.jetbrains.kotlin", "kotlin-stdlib")
.hasDependency("org.jetbrains.kotlin", "kotlin-stdlib-jre8")
.hasDependency("org.jetbrains.kotlin", "kotlin-reflect");
}