Class GroovyApplication
java.lang.Object
io.micronaut.starter.feature.lang.groovy.GroovyApplication
- All Implemented Interfaces:
io.micronaut.core.naming.Described
,io.micronaut.core.naming.Named
,io.micronaut.core.order.Ordered
,ApplicationFeature
,Feature
,GroovyApplicationFeature
@Requires(property="micronaut.starter.feature.groovy.application.enabled",
value="true",
defaultValue="true")
@Singleton
public class GroovyApplication
extends Object
implements GroovyApplicationFeature
Feature that generates a Groovy-based application entry point for supported Micronaut application types.
Provides Groovy-specific application and test templates, and configures the main class accordingly.
-
Field Summary
Fields inherited from interface io.micronaut.core.order.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected void
addApplication
(GeneratorContext generatorContext, ModuleContext module) Adds the application template to the module context.protected void
addApplicationTest
(GeneratorContext generatorContext, ModuleContext module) Adds an application test template to the module context.protected com.fizzed.rocker.RockerModel
application
(GeneratorContext generatorContext, ModuleContext module) Generates a RockerModel for the application based on the provided GeneratorContext and ModuleContext.protected com.fizzed.rocker.RockerModel
applicationTest
(GeneratorContext generatorContext) Generates a RockerModel for the application test based on the provided GeneratorContext.void
apply
(GeneratorContext generatorContext) If this method is called for a given feature that means the feature was explicitly selected, included by default as a result ofDefaultFeature.shouldApply(io.micronaut.starter.options.Options, java.util.Set)
, or added explicitly by another feature throughFeatureContext.addFeature(Feature)
.getName()
The name of the feature.protected String
getPath()
Returns the file path for the Groovy application class.@Nullable String
mainClassName
(GeneratorContext generatorContext) protected boolean
shouldGenerateApplicationFile
(GeneratorContext generatorContext) Determines whether an application file should be generated based on the provided GeneratorContext.boolean
This method must be implemented to ensure it is only selectable for the desired application types.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface io.micronaut.projectgen.core.feature.ApplicationFeature
isVisible
Methods inherited from interface io.micronaut.core.naming.Described
getDescription
Methods inherited from interface io.micronaut.projectgen.core.feature.Feature
getCategory, getDescription, getFrameworkDocumentation, getThirdPartyDocumentation, getTitle, isCommunity, isPreview, processSelectedFeatures
Methods inherited from interface io.micronaut.projectgen.core.feature.GroovyApplicationFeature
getOrder
-
Constructor Details
-
GroovyApplication
public GroovyApplication()
-
-
Method Details
-
mainClassName
- Specified by:
mainClassName
in interfaceApplicationFeature
-
getName
Description copied from interface:Feature
The name of the feature. It must be unique. -
supports
Description copied from interface:Feature
This method must be implemented to ensure it is only selectable for the desired application types. This method is not used for determining if a default feature should be applied. -
apply
Description copied from interface:Feature
If this method is called for a given feature that means the feature was explicitly selected, included by default as a result ofDefaultFeature.shouldApply(io.micronaut.starter.options.Options, java.util.Set)
, or added explicitly by another feature throughFeatureContext.addFeature(Feature)
. At this point the feature list is set and cannot change.- Specified by:
apply
in interfaceApplicationFeature
- Specified by:
apply
in interfaceFeature
- Parameters:
generatorContext
- THe generator context
-
shouldGenerateApplicationFile
Determines whether an application file should be generated based on the provided GeneratorContext. The decision is made based on the application type and the presence of the FunctionFeature.- Parameters:
generatorContext
- the context used to generate the project- Returns:
- true if an application file should be generated, false otherwise
-
application
protected com.fizzed.rocker.RockerModel application(GeneratorContext generatorContext, ModuleContext module) Generates a RockerModel for the application based on the provided GeneratorContext and ModuleContext. The generated RockerModel is used to render the application template.- Parameters:
generatorContext
- the context used to generate the projectmodule
- the module context containing information about the module being generated- Returns:
- a RockerModel representing the application template
-
addApplication
Adds the application template to the module context. This method generates a RockerModel for the application based on the provided GeneratorContext and ModuleContext, and adds it to the module context as a template named "application".- Parameters:
generatorContext
- the context used to generate the projectmodule
- the module context containing information about the module being generated
-
addApplicationTest
Adds an application test template to the module context. This method generates a test source path based on the provided GeneratorContext, creates a RockerModel for the application test using the applicationTest method, and adds it to the module context as a template named "applicationTest".- Parameters:
generatorContext
- the context used to generate the projectmodule
- the module context containing information about the module being generated
-
applicationTest
Generates a RockerModel for the application test based on the provided GeneratorContext. The generated RockerModel is used to render the application test template. The test framework and project information are retrieved from the GeneratorContext, and used to determine the appropriate test template to use.- Parameters:
generatorContext
- the context used to generate the project- Returns:
- a RockerModel representing the application test template
-
getPath
Returns the file path for the Groovy application class. The path is in the format "src/main/groovy/{packagePath}/Application.groovy", where "{packagePath}" is a placeholder for the actual package path.- Returns:
- the file path for the Groovy application class
-