Upgrade to Kotlin 1.1.1

This commit also enables Java 8 bytecode and uses kotlin-stdlib-jre7 or
kotlin-stdlib-jre8 dependencies when possible.

Closes gh-377
This commit is contained in:
Sebastien Deleuze 2017-03-15 15:28:33 +01:00 committed by Stephane Nicoll
parent c6194d2357
commit 6e7ff7fb58
9 changed files with 67 additions and 11 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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