Skip to content

Commit

Permalink
Merge pull request #204 from grails/bootstrap
Browse files Browse the repository at this point in the history
Add BootStrap.groovy file
  • Loading branch information
puneetbehl authored Sep 26, 2023
2 parents fc1c9ad + 5f28054 commit eeeb4a4
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
@import org.grails.forge.application.Project

@args(Project project)

package @project.getPackageName()

class BootStrap {

def init = { servletContext ->
}
def destroy = {
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,18 @@ class GrailsApplicationSpec extends BeanContextSpec implements CommandOutputFixt
expect:
buildGradle.contains("war")
}

@Unroll
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().toList()

}
}

0 comments on commit eeeb4a4

Please sign in to comment.