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 Summary
FieldsModifier and TypeFieldDescriptionstatic final String
static final String
protected final CoordinateResolver
static final String
static final String
Fields inherited from interface io.micronaut.core.order.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
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)
.@NonNull String
getName()
The name of the feature.protected @NonNull GradlePlugin
gradlePlugin
(@NonNull GeneratorContext generatorContext) Creates a GradlePlugin instance based on the provided GeneratorContext.boolean
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.protected MicronautApplicationGradlePlugin.Builder
micronautGradleApplicationPluginBuilder
(GeneratorContext generatorContext) Creates a MicronautApplicationGradlePlugin.Builder instance based on the provided GeneratorContext.protected MicronautApplicationGradlePlugin.Builder
micronautGradleApplicationPluginBuilder
(GeneratorContext generatorContext, String id) Creates a MicronautApplicationGradlePlugin.Builder instance based on the provided GeneratorContext and plugin ID.protected GradlePlugin.Builder
micronautLibraryGradlePluginBuilder
(GeneratorContext generatorContext) Creates a GradlePlugin.Builder instance for the Micronaut Library Gradle Plugin based on the provided GeneratorContext.boolean
Determines if snapshot repositories should be added based on the plugin's artifact version.boolean
shouldApply
(Options options, Set<Feature> selectedFeatures) Determines if the feature should be applied to the project.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.BuildPluginFeature
getOrder
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, supports
-
Field Details
-
MICRONAUT_GRADLE_DOCS_URL
- See Also:
-
GRAALVM_GRADLE_DOCS_URL
- See Also:
-
AOT_KEY_SECURITY_JWKS
- See Also:
-
AOT_KEY_SECURITY_OPENID
- See Also:
-
coordinateResolver
-
-
Constructor Details
-
MicronautBuildPlugin
-
-
Method Details
-
getName
Description copied from interface:Feature
The name of the feature. It must be unique. -
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. -
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
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 onid
- 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. -
shouldApply
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 interfaceDefaultFeature
- Parameters:
options
- The optionsselectedFeatures
- The features manually selected by the user- Returns:
- True if the feature should apply
-