mirror of
https://gitee.com/dcren/initializr.git
synced 2025-11-08 02:14:55 +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)
|
||||
|
||||
if (request.packaging == 'war') {
|
||||
def fileName = "ServletInitializer.$language"
|
||||
def fileName = "ServletInitializer.$extension"
|
||||
write(new File(src, fileName), fileName, model)
|
||||
}
|
||||
|
||||
|
||||
@@ -554,6 +554,14 @@ class ProjectGeneratorTests {
|
||||
.hasDependenciesCount(3)
|
||||
}
|
||||
|
||||
@Test
|
||||
void kotlinWar() {
|
||||
def request = createProjectRequest('web')
|
||||
request.language = 'kotlin'
|
||||
request.packaging = 'war'
|
||||
generateProject(request).isKotlinWarProject()
|
||||
}
|
||||
|
||||
@Test
|
||||
void invalidType() {
|
||||
def request = createProjectRequest('web')
|
||||
|
||||
@@ -130,15 +130,29 @@ class ProjectAssert {
|
||||
}
|
||||
|
||||
ProjectAssert isJavaWarProject(String expectedApplicationName) {
|
||||
isJavaProject(DEFAULT_PACKAGE_NAME, expectedApplicationName)
|
||||
.hasStaticAndTemplatesResources(true)
|
||||
.hasFile('src/main/java/com/example/ServletInitializer.java')
|
||||
isGenericWarProject(DEFAULT_PACKAGE_NAME, expectedApplicationName, 'java', 'java')
|
||||
}
|
||||
|
||||
ProjectAssert isJavaWarProject() {
|
||||
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) {
|
||||
assertFile('src/main/resources/templates', web)
|
||||
assertFile('src/main/resources/static', web)
|
||||
|
||||
Reference in New Issue
Block a user