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.
  • Constructor Details

    • GroovyApplication

      public GroovyApplication()
  • Method Details

    • mainClassName

      @Nullable public @Nullable String mainClassName(GeneratorContext generatorContext)
      Specified by:
      mainClassName in interface ApplicationFeature
    • getName

      public String getName()
      Description copied from interface: Feature
      The name of the feature. It must be unique.
      Specified by:
      getName in interface Feature
      Specified by:
      getName in interface io.micronaut.core.naming.Named
      Returns:
      the name of the feature
    • supports

      public boolean supports(Options options)
      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.
      Specified by:
      supports in interface Feature
      Parameters:
      options - Options
      Returns:
      True if the feature can be selected by the user
    • apply

      public void apply(GeneratorContext generatorContext)
      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 of DefaultFeature.shouldApply(io.micronaut.starter.options.Options, java.util.Set), or added explicitly by another feature through FeatureContext.addFeature(Feature). At this point the feature list is set and cannot change.
      Specified by:
      apply in interface ApplicationFeature
      Specified by:
      apply in interface Feature
      Parameters:
      generatorContext - THe generator context
    • shouldGenerateApplicationFile

      protected boolean shouldGenerateApplicationFile(GeneratorContext generatorContext)
      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 project
      module - the module context containing information about the module being generated
      Returns:
      a RockerModel representing the application template
    • addApplication

      protected void addApplication(GeneratorContext generatorContext, ModuleContext module)
      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 project
      module - the module context containing information about the module being generated
    • addApplicationTest

      protected void addApplicationTest(GeneratorContext generatorContext, ModuleContext module)
      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 project
      module - the module context containing information about the module being generated
    • applicationTest

      protected com.fizzed.rocker.RockerModel applicationTest(GeneratorContext generatorContext)
      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

      protected String 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