mirror of
https://gitee.com/dcren/initializr.git
synced 2025-09-19 01:58:16 +08:00
Polish contribution
Closes gh-388
This commit is contained in:
@@ -430,9 +430,9 @@ public class ProjectGenerator {
|
||||
model.put("newServletInitializer", isNewServletInitializerAvailable(request));
|
||||
|
||||
// Java versions
|
||||
model.put("isJava6", isJava6(request));
|
||||
model.put("isJava7", isJava7(request));
|
||||
model.put("isJava8", isJava8(request));
|
||||
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);
|
||||
@@ -510,16 +510,8 @@ public class ProjectGenerator {
|
||||
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 static boolean isJavaVersion(ProjectRequest request, String version) {
|
||||
return request.getJavaVersion().equals(version);
|
||||
}
|
||||
|
||||
private byte[] doGenerateMavenPom(Map<String, Object> model) {
|
||||
|
@@ -183,7 +183,7 @@
|
||||
<plugin>spring</plugin>
|
||||
</compilerPlugins>
|
||||
{{#isJava8}}
|
||||
<jvmTarget>${java.version}</jvmTarget>
|
||||
<jvmTarget>1.8</jvmTarget>
|
||||
{{/isJava8}}
|
||||
</configuration>
|
||||
<executions>
|
||||
|
@@ -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);
|
||||
|
@@ -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')
|
||||
}
|
@@ -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')
|
||||
}
|
@@ -64,7 +64,7 @@
|
||||
<compilerPlugins>
|
||||
<plugin>spring</plugin>
|
||||
</compilerPlugins>
|
||||
<jvmTarget>${java.version}</jvmTarget>
|
||||
<jvmTarget>1.8</jvmTarget>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
|
@@ -69,7 +69,7 @@
|
||||
<compilerPlugins>
|
||||
<plugin>spring</plugin>
|
||||
</compilerPlugins>
|
||||
<jvmTarget>${java.version}</jvmTarget>
|
||||
<jvmTarget>1.8</jvmTarget>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
|
@@ -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>
|
@@ -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>
|
Reference in New Issue
Block a user