mirror of
https://gitee.com/dcren/initializr.git
synced 2025-11-09 02:45:00 +08:00
Fix war kotlin project
This commit fixes the generation of a web-based project using Kotlin by propertly detecting the `ServletInitializer` template. Closes gh-217
This commit is contained in:
@@ -132,7 +132,7 @@ class ProjectGenerator {
|
|||||||
write(new File(src, "${applicationName}.${extension}"), "Application.$extension", model)
|
write(new File(src, "${applicationName}.${extension}"), "Application.$extension", model)
|
||||||
|
|
||||||
if (request.packaging == 'war') {
|
if (request.packaging == 'war') {
|
||||||
def fileName = "ServletInitializer.$language"
|
def fileName = "ServletInitializer.$extension"
|
||||||
write(new File(src, fileName), fileName, model)
|
write(new File(src, fileName), fileName, model)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -554,6 +554,14 @@ class ProjectGeneratorTests {
|
|||||||
.hasDependenciesCount(3)
|
.hasDependenciesCount(3)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void kotlinWar() {
|
||||||
|
def request = createProjectRequest('web')
|
||||||
|
request.language = 'kotlin'
|
||||||
|
request.packaging = 'war'
|
||||||
|
generateProject(request).isKotlinWarProject()
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void invalidType() {
|
void invalidType() {
|
||||||
def request = createProjectRequest('web')
|
def request = createProjectRequest('web')
|
||||||
|
|||||||
@@ -130,15 +130,29 @@ class ProjectAssert {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ProjectAssert isJavaWarProject(String expectedApplicationName) {
|
ProjectAssert isJavaWarProject(String expectedApplicationName) {
|
||||||
isJavaProject(DEFAULT_PACKAGE_NAME, expectedApplicationName)
|
isGenericWarProject(DEFAULT_PACKAGE_NAME, expectedApplicationName, 'java', 'java')
|
||||||
.hasStaticAndTemplatesResources(true)
|
|
||||||
.hasFile('src/main/java/com/example/ServletInitializer.java')
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ProjectAssert isJavaWarProject() {
|
ProjectAssert isJavaWarProject() {
|
||||||
isJavaWarProject(DEFAULT_APPLICATION_NAME)
|
isJavaWarProject(DEFAULT_APPLICATION_NAME)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ProjectAssert isGroovyWarProject() {
|
||||||
|
isGenericWarProject(DEFAULT_PACKAGE_NAME, DEFAULT_APPLICATION_NAME, 'groovy', 'groovy')
|
||||||
|
}
|
||||||
|
|
||||||
|
ProjectAssert isKotlinWarProject() {
|
||||||
|
isGenericWarProject(DEFAULT_PACKAGE_NAME, DEFAULT_APPLICATION_NAME, 'kotlin', 'kt')
|
||||||
|
}
|
||||||
|
|
||||||
|
ProjectAssert isGenericWarProject(String expectedPackageName, String expectedApplicationName,
|
||||||
|
String codeLocation, String extension) {
|
||||||
|
String packageName = expectedPackageName.replace('.', '/')
|
||||||
|
isGenericProject(expectedPackageName, expectedApplicationName, codeLocation, extension)
|
||||||
|
.hasStaticAndTemplatesResources(true)
|
||||||
|
.hasFile("src/main/$codeLocation/$packageName/ServletInitializer.$extension")
|
||||||
|
}
|
||||||
|
|
||||||
ProjectAssert hasStaticAndTemplatesResources(boolean web) {
|
ProjectAssert hasStaticAndTemplatesResources(boolean web) {
|
||||||
assertFile('src/main/resources/templates', web)
|
assertFile('src/main/resources/templates', web)
|
||||||
assertFile('src/main/resources/static', web)
|
assertFile('src/main/resources/static', web)
|
||||||
|
|||||||
Reference in New Issue
Block a user