From 1ebc4b957b48f52e23f91d1c5e04e13cc31b32fb Mon Sep 17 00:00:00 2001 From: Puneet Behl Date: Tue, 26 Sep 2023 22:34:25 +0530 Subject: [PATCH 1/3] Add BootStrap.groovy file --- .../forge/cli/command/CreateAppCommandSpec.groovy | 3 +++ .../feature/lang/groovy/GrailsApplication.java | 1 + .../forge/feature/lang/groovy/bootStrap.rocker.raw | 13 +++++++++++++ .../forge/feature/lang/GrailsApplicationSpec.groovy | 13 +++++++++++++ 4 files changed, 30 insertions(+) create mode 100644 grails-forge-core/src/main/java/org/grails/forge/feature/lang/groovy/bootStrap.rocker.raw diff --git a/grails-cli/src/test/groovy/org/grails/forge/cli/command/CreateAppCommandSpec.groovy b/grails-cli/src/test/groovy/org/grails/forge/cli/command/CreateAppCommandSpec.groovy index 9dbde36f..2eb3343a 100644 --- a/grails-cli/src/test/groovy/org/grails/forge/cli/command/CreateAppCommandSpec.groovy +++ b/grails-cli/src/test/groovy/org/grails/forge/cli/command/CreateAppCommandSpec.groovy @@ -3,9 +3,12 @@ package org.grails.forge.cli.command import io.micronaut.configuration.picocli.PicocliRunner import io.micronaut.context.ApplicationContext import io.micronaut.context.env.Environment +import org.grails.forge.application.ApplicationType import org.grails.forge.application.WebAvailableFeatures +import org.grails.forge.cli.CodeGenConfig import org.grails.forge.cli.CommandFixture import org.grails.forge.cli.CommandSpec +import org.grails.forge.io.ConsoleOutput import spock.lang.AutoCleanup import spock.lang.Shared diff --git a/grails-forge-core/src/main/java/org/grails/forge/feature/lang/groovy/GrailsApplication.java b/grails-forge-core/src/main/java/org/grails/forge/feature/lang/groovy/GrailsApplication.java index af11b2a9..420b8c9f 100644 --- a/grails-forge-core/src/main/java/org/grails/forge/feature/lang/groovy/GrailsApplication.java +++ b/grails-forge-core/src/main/java/org/grails/forge/feature/lang/groovy/GrailsApplication.java @@ -66,6 +66,7 @@ public void apply(GeneratorContext generatorContext) { generatorContext.addTemplate("plugin", new RockerTemplate(generatorContext.getSourcePath("/{packagePath}/{className}GrailsPlugin"), plugin.template(generatorContext.getProject(), applicationType))); } + generatorContext.addTemplate("bootStrap", new RockerTemplate("grails-app/init/{packagePath}/BootStrap.groovy", bootStrap.template(generatorContext.getProject()))); } protected boolean shouldGenerateApplicationFile(ApplicationType applicationType, GeneratorContext generatorContext) { diff --git a/grails-forge-core/src/main/java/org/grails/forge/feature/lang/groovy/bootStrap.rocker.raw b/grails-forge-core/src/main/java/org/grails/forge/feature/lang/groovy/bootStrap.rocker.raw new file mode 100644 index 00000000..1a214b29 --- /dev/null +++ b/grails-forge-core/src/main/java/org/grails/forge/feature/lang/groovy/bootStrap.rocker.raw @@ -0,0 +1,13 @@ +@import org.grails.forge.application.Project + +@args(Project project) + +package @project.getPackageName() + +class BootStrap { + + def init = { servletContext -> + } + def destroy = { + } +} \ No newline at end of file diff --git a/grails-forge-core/src/test/groovy/org/grails/forge/feature/lang/GrailsApplicationSpec.groovy b/grails-forge-core/src/test/groovy/org/grails/forge/feature/lang/GrailsApplicationSpec.groovy index a7e1b071..cb09b57c 100644 --- a/grails-forge-core/src/test/groovy/org/grails/forge/feature/lang/GrailsApplicationSpec.groovy +++ b/grails-forge-core/src/test/groovy/org/grails/forge/feature/lang/GrailsApplicationSpec.groovy @@ -99,4 +99,17 @@ class GrailsApplicationSpec extends BeanContextSpec implements CommandOutputFixt expect: buildGradle.contains("war") } + + void "test BootStrap.groovy is present for application type #applicationType"() { + + when: + def output = generate(applicationType) + + then + output.containsKey("grails-app/init/example/grails/BootStrap.groovy") + + where: + applicationType << ApplicationType.values() + + } } From 9723f1ac2e840cf05a7e0eb3919845709a992a11 Mon Sep 17 00:00:00 2001 From: Puneet Behl Date: Tue, 26 Sep 2023 23:24:27 +0530 Subject: [PATCH 2/3] Update GrailsApplicationSpec.groovy --- .../org/grails/forge/feature/lang/GrailsApplicationSpec.groovy | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/grails-forge-core/src/test/groovy/org/grails/forge/feature/lang/GrailsApplicationSpec.groovy b/grails-forge-core/src/test/groovy/org/grails/forge/feature/lang/GrailsApplicationSpec.groovy index cb09b57c..c5db69c6 100644 --- a/grails-forge-core/src/test/groovy/org/grails/forge/feature/lang/GrailsApplicationSpec.groovy +++ b/grails-forge-core/src/test/groovy/org/grails/forge/feature/lang/GrailsApplicationSpec.groovy @@ -100,12 +100,13 @@ class GrailsApplicationSpec extends BeanContextSpec implements CommandOutputFixt buildGradle.contains("war") } + @Unroll void "test BootStrap.groovy is present for application type #applicationType"() { when: def output = generate(applicationType) - then + then: output.containsKey("grails-app/init/example/grails/BootStrap.groovy") where: From 5f28054d7f1aa7124b5ed3c789f4d076f9a42900 Mon Sep 17 00:00:00 2001 From: Puneet Behl Date: Tue, 26 Sep 2023 23:25:19 +0530 Subject: [PATCH 3/3] Update GrailsApplicationSpec.groovy --- .../org/grails/forge/feature/lang/GrailsApplicationSpec.groovy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grails-forge-core/src/test/groovy/org/grails/forge/feature/lang/GrailsApplicationSpec.groovy b/grails-forge-core/src/test/groovy/org/grails/forge/feature/lang/GrailsApplicationSpec.groovy index c5db69c6..41766499 100644 --- a/grails-forge-core/src/test/groovy/org/grails/forge/feature/lang/GrailsApplicationSpec.groovy +++ b/grails-forge-core/src/test/groovy/org/grails/forge/feature/lang/GrailsApplicationSpec.groovy @@ -110,7 +110,7 @@ class GrailsApplicationSpec extends BeanContextSpec implements CommandOutputFixt output.containsKey("grails-app/init/example/grails/BootStrap.groovy") where: - applicationType << ApplicationType.values() + applicationType << ApplicationType.values().toList() } }