Class MicronautBuildPlugin

java.lang.Object
io.micronaut.starter.feature.buildtools.MicronautBuildPlugin
All Implemented Interfaces:
io.micronaut.core.naming.Described, io.micronaut.core.naming.Named, io.micronaut.core.order.Ordered, BuildPluginFeature, DefaultFeature, Feature

@Requires(property="micronaut.starter.feature.micronaut.build.enabled", value="true", defaultValue="true") @Singleton public class MicronautBuildPlugin extends Object implements BuildPluginFeature, DefaultFeature
Feature that adds the Micronaut Gradle Build Plugin to the project, providing integration with Micronaut and optional GraalVM Gradle plugins.
  • Field Details

  • Constructor Details

    • MicronautBuildPlugin

      public MicronautBuildPlugin(CoordinateResolver coordinateResolver)
  • Method Details

    • getName

      @NonNull public @NonNull 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
    • 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 Feature
      Parameters:
      generatorContext - THe generator context
    • gradlePlugin

      @NonNull protected @NonNull GradlePlugin gradlePlugin(@NonNull @NonNull GeneratorContext generatorContext)
      Creates a GradlePlugin instance based on the provided GeneratorContext. The method determines whether to apply the Micronaut Application Gradle Plugin or the Micronaut Library Gradle Plugin based on the GeneratorContext. It also adds snapshot repositories if necessary.
      Parameters:
      generatorContext - the GeneratorContext instance to base the GradlePlugin on
      Returns:
      a GradlePlugin instance
    • shouldAddRepositoriesForSnapshots

      public boolean shouldAddRepositoriesForSnapshots(GradlePlugin.Builder builder)
      Determines if snapshot repositories should be added based on the plugin's artifact version.
      Parameters:
      builder - the GradlePlugin.Builder instance to inspect
      Returns:
      true if the plugin version ends with "-SNAPSHOT", false otherwise or if artifact id or version is unavailable
    • micronautGradleApplicationPluginBuilder

      protected MicronautApplicationGradlePlugin.Builder micronautGradleApplicationPluginBuilder(GeneratorContext generatorContext, String id)
      Creates a MicronautApplicationGradlePlugin.Builder instance based on the provided GeneratorContext and plugin ID. The method configures the builder with settings derived from the GeneratorContext, including build tool, Java version, package name, and runtime settings. It also configures additional settings based on the presence of certain features.
      Parameters:
      generatorContext - the GeneratorContext instance to base the MicronautApplicationGradlePlugin.Builder on
      id - the ID of the plugin to use (e.g., "io.micronaut.application" or "io.micronaut.library")
      Returns:
      a MicronautApplicationGradlePlugin.Builder instance configured based on the GeneratorContext
    • micronautGradleApplicationPluginBuilder

      protected MicronautApplicationGradlePlugin.Builder micronautGradleApplicationPluginBuilder(GeneratorContext generatorContext)
      Creates a MicronautApplicationGradlePlugin.Builder instance based on the provided GeneratorContext. The method configures the builder with settings derived from the GeneratorContext, including build tool, Java version, package name, and runtime settings. It also configures Docker native settings based on the presence of certain features and the JDK version.
      Parameters:
      generatorContext - the GeneratorContext instance to base the MicronautApplicationGradlePlugin.Builder on
      Returns:
      a MicronautApplicationGradlePlugin.Builder instance configured based on the GeneratorContext
    • micronautLibraryGradlePluginBuilder

      protected GradlePlugin.Builder micronautLibraryGradlePluginBuilder(GeneratorContext generatorContext)
      Creates a GradlePlugin.Builder instance for the Micronaut Library Gradle Plugin based on the provided GeneratorContext. The method reuses the configuration from the Micronaut Application Gradle Plugin builder, but with the ID set to "LIBRARY".
      Parameters:
      generatorContext - the GeneratorContext instance to base the GradlePlugin on
      Returns:
      a GradlePlugin.Builder instance for the Micronaut Library Gradle Plugin
    • isVisible

      public boolean isVisible()
      Description copied from interface: Feature
      Some features should not be visible to the user because they are a common parent of other selectable features, or they should always be applied, or any other reason.
      Specified by:
      isVisible in interface Feature
      Returns:
      True if the feature should be able to be selected by the user
    • shouldApply

      public boolean shouldApply(Options options, Set<Feature> selectedFeatures)
      Description copied from interface: DefaultFeature
      Determines if the feature should be applied to the project. Default features do not need to be concerned if the feature was already selected and therefore is already in the list of selected features. The addition to the set is based on the identity of the feature instance and all features are singletons.
      Specified by:
      shouldApply in interface DefaultFeature
      Parameters:
      options - The options
      selectedFeatures - The features manually selected by the user
      Returns:
      True if the feature should apply