diff --git a/initializr-generator/src/main/resources/templates/starter-pom.xml b/initializr-generator/src/main/resources/templates/starter-pom.xml index 29829c71..2a866174 100644 --- a/initializr-generator/src/main/resources/templates/starter-pom.xml +++ b/initializr-generator/src/main/resources/templates/starter-pom.xml @@ -41,7 +41,7 @@ kotlin-stdlib \${kotlin.version} <% } %> - <% runtimeDependencies.each { %> +<% runtimeDependencies.each { %> ${it.groupId} ${it.artifactId}<% if (it.version != null) { %> @@ -69,7 +69,7 @@ ${it.type}<% } %> <% } %> - <% if (boms) { %> +<% if (boms) { %> <% boms.values().each { %> @@ -132,7 +132,7 @@ <% } %> - <% if (repositories) { %> +<% if (repositories) { %> <% repositories.each { key, repo -> %> ${key} diff --git a/initializr-generator/src/test/groovy/io/spring/initializr/generator/ProjectGeneratorBuildTests.groovy b/initializr-generator/src/test/groovy/io/spring/initializr/generator/ProjectGeneratorBuildTests.groovy new file mode 100644 index 00000000..03fa2e13 --- /dev/null +++ b/initializr-generator/src/test/groovy/io/spring/initializr/generator/ProjectGeneratorBuildTests.groovy @@ -0,0 +1,81 @@ +/* + * Copyright 2012-2016 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.spring.initializr.generator + +import org.junit.Test +import org.junit.runner.RunWith +import org.junit.runners.Parameterized + +import org.springframework.core.io.ClassPathResource + +import static io.spring.initializr.test.generator.ProjectAssert.DEFAULT_APPLICATION_NAME +import static io.spring.initializr.test.generator.ProjectAssert.DEFAULT_PACKAGE_NAME + +/** + * Project generator tests for supported build systems. + * + * @author Stephane Nicoll + */ +@RunWith(Parameterized.class) +class ProjectGeneratorBuildTests extends AbstractProjectGeneratorTests { + + @Parameterized.Parameters(name = "{0} with {1}") + public static Object[] parameters() { + Object[] javaMaven = ["java", "maven", "pom.xml"] + Object[] javaGradle = ["java", "gradle", "build.gradle"] + Object[] groovyMaven = ["groovy", "maven", "pom.xml"] + Object[] groovyGradle = ["groovy", "gradle", "build.gradle"] + Object[] kotlinMaven = ["kotlin", "maven", "pom.xml"] + Object[] kotlinGradle = ["kotlin", "gradle", "build.gradle"] + Object[] parameters = [javaMaven, javaGradle, groovyMaven, groovyGradle, kotlinMaven, kotlinGradle] + parameters + } + + private final String language + private final String build + private final String fileName + private final String assertFileName + + ProjectGeneratorBuildTests(String language, String build, String fileName) { + this.language = language + this.build = build + this.fileName = fileName + this.assertFileName = fileName + ".gen" + } + + @Test + public void standardJar() { + def request = createProjectRequest() + request.language = language + request.type = "$build-project" + def project = generateProject(request) + project.sourceCodeAssert("$fileName") + .equalsTo(new ClassPathResource("project/$language/standard/$assertFileName")) + } + + @Test + public void standardWar() { + def request = createProjectRequest('web') + request.packaging = 'war' + request.language = language + request.type = "$build-project" + def project = generateProject(request) + project.sourceCodeAssert("$fileName") + .equalsTo(new ClassPathResource("project/$language/war/$assertFileName")) + } + +} diff --git a/initializr-generator/src/test/resources/project/groovy/standard/build.gradle.gen b/initializr-generator/src/test/resources/project/groovy/standard/build.gradle.gen new file mode 100644 index 00000000..1d9c392c --- /dev/null +++ b/initializr-generator/src/test/resources/project/groovy/standard/build.gradle.gen @@ -0,0 +1,43 @@ +buildscript { + ext { + 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') + } +} + +apply plugin: 'groovy' +apply plugin: 'eclipse' +apply plugin: 'spring-boot' +apply plugin: 'io.spring.dependency-management' + +jar { + baseName = 'demo' + version = '0.0.1-SNAPSHOT' +} +sourceCompatibility = 1.8 +targetCompatibility = 1.8 + +repositories { + mavenCentral() +} + + +dependencies { + compile('org.springframework.boot:spring-boot-starter') + compile('org.codehaus.groovy:groovy') + testCompile('org.springframework.boot:spring-boot-starter-test') +} + + +eclipse { + classpath { + containers.remove('org.eclipse.jdt.launching.JRE_CONTAINER') + containers 'org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8' + } +} diff --git a/initializr-generator/src/test/resources/project/groovy/standard/pom.xml.gen b/initializr-generator/src/test/resources/project/groovy/standard/pom.xml.gen new file mode 100644 index 00000000..fa0f090d --- /dev/null +++ b/initializr-generator/src/test/resources/project/groovy/standard/pom.xml.gen @@ -0,0 +1,72 @@ + + + 4.0.0 + + com.example + demo + 0.0.1-SNAPSHOT + jar + + demo + Demo project for Spring Boot + + + org.springframework.boot + spring-boot-starter-parent + 1.2.3.RELEASE + + + + + UTF-8 + 1.8 + + + + + org.springframework.boot + spring-boot-starter + + + org.codehaus.groovy + groovy + + + + org.springframework.boot + spring-boot-starter-test + test + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + org.codehaus.gmavenplus + gmavenplus-plugin + 1.5 + + + + addSources + addTestSources + generateStubs + compile + testGenerateStubs + testCompile + removeStubs + removeTestStubs + + + + + + + + + diff --git a/initializr-generator/src/test/resources/project/groovy/war/build.gradle.gen b/initializr-generator/src/test/resources/project/groovy/war/build.gradle.gen new file mode 100644 index 00000000..a03b8cdd --- /dev/null +++ b/initializr-generator/src/test/resources/project/groovy/war/build.gradle.gen @@ -0,0 +1,49 @@ +buildscript { + ext { + 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') + } +} + +apply plugin: 'groovy' +apply plugin: 'eclipse-wtp' +apply plugin: 'spring-boot' +apply plugin: 'io.spring.dependency-management' +apply plugin: 'war' + + +war { + baseName = 'demo' + version = '0.0.1-SNAPSHOT' +} +sourceCompatibility = 1.8 +targetCompatibility = 1.8 + +repositories { + mavenCentral() +} + +configurations { + providedRuntime +} + +dependencies { + compile('org.springframework.boot:spring-boot-starter-web') + compile('org.codehaus.groovy:groovy') + providedRuntime('org.springframework.boot:spring-boot-starter-tomcat') + testCompile('org.springframework.boot:spring-boot-starter-test') +} + + +eclipse { + classpath { + containers.remove('org.eclipse.jdt.launching.JRE_CONTAINER') + containers 'org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8' + } +} diff --git a/initializr-generator/src/test/resources/project/groovy/war/pom.xml.gen b/initializr-generator/src/test/resources/project/groovy/war/pom.xml.gen new file mode 100644 index 00000000..42bfd5f6 --- /dev/null +++ b/initializr-generator/src/test/resources/project/groovy/war/pom.xml.gen @@ -0,0 +1,77 @@ + + + 4.0.0 + + com.example + demo + 0.0.1-SNAPSHOT + war + + demo + Demo project for Spring Boot + + + org.springframework.boot + spring-boot-starter-parent + 1.2.3.RELEASE + + + + + UTF-8 + 1.8 + + + + + org.springframework.boot + spring-boot-starter-web + + + org.codehaus.groovy + groovy + + + + org.springframework.boot + spring-boot-starter-tomcat + provided + + + org.springframework.boot + spring-boot-starter-test + test + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + org.codehaus.gmavenplus + gmavenplus-plugin + 1.5 + + + + addSources + addTestSources + generateStubs + compile + testGenerateStubs + testCompile + removeStubs + removeTestStubs + + + + + + + + + diff --git a/initializr-generator/src/test/resources/project/java/standard/build.gradle.gen b/initializr-generator/src/test/resources/project/java/standard/build.gradle.gen new file mode 100644 index 00000000..98bbc838 --- /dev/null +++ b/initializr-generator/src/test/resources/project/java/standard/build.gradle.gen @@ -0,0 +1,42 @@ +buildscript { + ext { + 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') + } +} + +apply plugin: 'java' +apply plugin: 'eclipse' +apply plugin: 'spring-boot' +apply plugin: 'io.spring.dependency-management' + +jar { + baseName = 'demo' + version = '0.0.1-SNAPSHOT' +} +sourceCompatibility = 1.8 +targetCompatibility = 1.8 + +repositories { + mavenCentral() +} + + +dependencies { + compile('org.springframework.boot:spring-boot-starter') + testCompile('org.springframework.boot:spring-boot-starter-test') +} + + +eclipse { + classpath { + containers.remove('org.eclipse.jdt.launching.JRE_CONTAINER') + containers 'org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8' + } +} diff --git a/initializr-generator/src/test/resources/project/java/standard/pom.xml.gen b/initializr-generator/src/test/resources/project/java/standard/pom.xml.gen new file mode 100644 index 00000000..ba82e80d --- /dev/null +++ b/initializr-generator/src/test/resources/project/java/standard/pom.xml.gen @@ -0,0 +1,49 @@ + + + 4.0.0 + + com.example + demo + 0.0.1-SNAPSHOT + jar + + demo + Demo project for Spring Boot + + + org.springframework.boot + spring-boot-starter-parent + 1.2.3.RELEASE + + + + + UTF-8 + 1.8 + + + + + org.springframework.boot + spring-boot-starter + + + + org.springframework.boot + spring-boot-starter-test + test + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + + + diff --git a/initializr-generator/src/test/resources/project/java/war/build.gradle.gen b/initializr-generator/src/test/resources/project/java/war/build.gradle.gen new file mode 100644 index 00000000..6d368ef6 --- /dev/null +++ b/initializr-generator/src/test/resources/project/java/war/build.gradle.gen @@ -0,0 +1,48 @@ +buildscript { + ext { + 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') + } +} + +apply plugin: 'java' +apply plugin: 'eclipse-wtp' +apply plugin: 'spring-boot' +apply plugin: 'io.spring.dependency-management' +apply plugin: 'war' + + +war { + baseName = 'demo' + version = '0.0.1-SNAPSHOT' +} +sourceCompatibility = 1.8 +targetCompatibility = 1.8 + +repositories { + mavenCentral() +} + +configurations { + providedRuntime +} + +dependencies { + compile('org.springframework.boot:spring-boot-starter-web') + providedRuntime('org.springframework.boot:spring-boot-starter-tomcat') + testCompile('org.springframework.boot:spring-boot-starter-test') +} + + +eclipse { + classpath { + containers.remove('org.eclipse.jdt.launching.JRE_CONTAINER') + containers 'org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8' + } +} diff --git a/initializr-generator/src/test/resources/project/java/war/pom.xml.gen b/initializr-generator/src/test/resources/project/java/war/pom.xml.gen new file mode 100644 index 00000000..0fd8f3cf --- /dev/null +++ b/initializr-generator/src/test/resources/project/java/war/pom.xml.gen @@ -0,0 +1,54 @@ + + + 4.0.0 + + com.example + demo + 0.0.1-SNAPSHOT + war + + demo + Demo project for Spring Boot + + + org.springframework.boot + spring-boot-starter-parent + 1.2.3.RELEASE + + + + + UTF-8 + 1.8 + + + + + org.springframework.boot + spring-boot-starter-web + + + + org.springframework.boot + spring-boot-starter-tomcat + provided + + + org.springframework.boot + spring-boot-starter-test + test + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + + + diff --git a/initializr-generator/src/test/resources/project/kotlin/standard/build.gradle.gen b/initializr-generator/src/test/resources/project/kotlin/standard/build.gradle.gen new file mode 100644 index 00000000..1fa83eda --- /dev/null +++ b/initializr-generator/src/test/resources/project/kotlin/standard/build.gradle.gen @@ -0,0 +1,45 @@ +buildscript { + ext { + springBootVersion = '1.2.3.RELEASE' + kotlinVersion = '1.0.1' + } + 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}") + } +} + +apply plugin: 'kotlin' +apply plugin: 'eclipse' +apply plugin: 'spring-boot' +apply plugin: 'io.spring.dependency-management' + +jar { + baseName = 'demo' + version = '0.0.1-SNAPSHOT' +} +sourceCompatibility = 1.8 +targetCompatibility = 1.8 + +repositories { + mavenCentral() +} + + +dependencies { + compile('org.springframework.boot:spring-boot-starter') + compile("org.jetbrains.kotlin:kotlin-stdlib:${kotlinVersion}") + testCompile('org.springframework.boot:spring-boot-starter-test') +} + + +eclipse { + classpath { + containers.remove('org.eclipse.jdt.launching.JRE_CONTAINER') + containers 'org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8' + } +} diff --git a/initializr-generator/src/test/resources/project/kotlin/standard/pom.xml.gen b/initializr-generator/src/test/resources/project/kotlin/standard/pom.xml.gen new file mode 100644 index 00000000..5f830354 --- /dev/null +++ b/initializr-generator/src/test/resources/project/kotlin/standard/pom.xml.gen @@ -0,0 +1,78 @@ + + + 4.0.0 + + com.example + demo + 0.0.1-SNAPSHOT + jar + + demo + Demo project for Spring Boot + + + org.springframework.boot + spring-boot-starter-parent + 1.2.3.RELEASE + + + + + UTF-8 + 1.8 + 1.0.1 + + + + + org.springframework.boot + spring-boot-starter + + + org.jetbrains.kotlin + kotlin-stdlib + ${kotlin.version} + + + + org.springframework.boot + spring-boot-starter-test + test + + + + + ${project.basedir}/src/main/kotlin + ${project.basedir}/src/test/kotlin + + + org.springframework.boot + spring-boot-maven-plugin + + + kotlin-maven-plugin + org.jetbrains.kotlin + ${kotlin.version} + + + compile + compile + + compile + + + + test-compile + test-compile + + test-compile + + + + + + + + + diff --git a/initializr-generator/src/test/resources/project/kotlin/war/build.gradle.gen b/initializr-generator/src/test/resources/project/kotlin/war/build.gradle.gen new file mode 100644 index 00000000..f09ff9bb --- /dev/null +++ b/initializr-generator/src/test/resources/project/kotlin/war/build.gradle.gen @@ -0,0 +1,51 @@ +buildscript { + ext { + springBootVersion = '1.2.3.RELEASE' + kotlinVersion = '1.0.1' + } + 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}") + } +} + +apply plugin: 'kotlin' +apply plugin: 'eclipse-wtp' +apply plugin: 'spring-boot' +apply plugin: 'io.spring.dependency-management' +apply plugin: 'war' + + +war { + baseName = 'demo' + version = '0.0.1-SNAPSHOT' +} +sourceCompatibility = 1.8 +targetCompatibility = 1.8 + +repositories { + mavenCentral() +} + +configurations { + providedRuntime +} + +dependencies { + compile('org.springframework.boot:spring-boot-starter-web') + compile("org.jetbrains.kotlin:kotlin-stdlib:${kotlinVersion}") + providedRuntime('org.springframework.boot:spring-boot-starter-tomcat') + testCompile('org.springframework.boot:spring-boot-starter-test') +} + + +eclipse { + classpath { + containers.remove('org.eclipse.jdt.launching.JRE_CONTAINER') + containers 'org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8' + } +} diff --git a/initializr-generator/src/test/resources/project/kotlin/war/pom.xml.gen b/initializr-generator/src/test/resources/project/kotlin/war/pom.xml.gen new file mode 100644 index 00000000..e3962f7b --- /dev/null +++ b/initializr-generator/src/test/resources/project/kotlin/war/pom.xml.gen @@ -0,0 +1,83 @@ + + + 4.0.0 + + com.example + demo + 0.0.1-SNAPSHOT + war + + demo + Demo project for Spring Boot + + + org.springframework.boot + spring-boot-starter-parent + 1.2.3.RELEASE + + + + + UTF-8 + 1.8 + 1.0.1 + + + + + org.springframework.boot + spring-boot-starter-web + + + org.jetbrains.kotlin + kotlin-stdlib + ${kotlin.version} + + + + org.springframework.boot + spring-boot-starter-tomcat + provided + + + org.springframework.boot + spring-boot-starter-test + test + + + + + ${project.basedir}/src/main/kotlin + ${project.basedir}/src/test/kotlin + + + org.springframework.boot + spring-boot-maven-plugin + + + kotlin-maven-plugin + org.jetbrains.kotlin + ${kotlin.version} + + + compile + compile + + compile + + + + test-compile + test-compile + + test-compile + + + + + + + + + diff --git a/initializr-web/src/test/resources/metadata/config/test-default.json b/initializr-web/src/test/resources/metadata/config/test-default.json index a7f7d936..e59ada71 100644 --- a/initializr-web/src/test/resources/metadata/config/test-default.json +++ b/initializr-web/src/test/resources/metadata/config/test-default.json @@ -33,6 +33,9 @@ "artifactRepository": "https://repo.spring.io/release/", "fallbackApplicationName": "Application", "forceSsl": true, + "gradle": { + "dependencyManagementPluginVersion": null + }, "kotlin": { "version": null },