You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There is a lot of maven and gradle-specific code for micronaut plugins that seems to be generateable. An example is micronaut openapi generators. We will also need plugins for JSON schema generations and possibly others in the future.
For openapi all the parameters are repeated 3 times currently:
Generating would have the advanatage that both versions would have consistent parameters and possibly similar API.
Generation description
Add a new module to generate plugins.
Given a configuration for an plugin executable, like
/** * Test configuration. * * @param packageName The package name to generate to */@PluginConfig(mavenPropertyPrefix = "test")
publicrecordTestConfig(
@PluginParameter(mavenProperty = "packageName", required = true)
StringpackageName,
@PluginParameter(defaultValue = false)
booleanserverGeneration,
Map<String, String> additionalProperties,
@PluginParameter(internal = true)
StringoutputDirectory
) implementsPluginExecutable {
publicvoidexecute() {
doWork(packageName, serverGeneration, additionalProperties, outputDirectory);
}
}
we would want to generate plugin code stubs for reading these properties and calling the execute method.
Maven
we could generate maven Mojo:
publicabstractclassAbstractTestMojoextendsAbstractMicronautMojo {
/** * The package name to generate to. */@Parameter(property = "test.packageName", required = true)
protectedStringpackageName;
@Parameter(defaultValue = "false")
protectedbooleanserverGeneration;
@ParameterprotectedMap<String, Object> additionalProperties;
@Parameter(property = "test.enabled")
protectedbooleanenabled;
protectedabstractStringgetOutputDirectory();
@Overridepublicvoidexecute() throwsMojoExecutionException, MojoFailureException {
if (!isEnabled()) {
getLog().debug(this.getClass().getSimpleName() + " is disabled");
return;
}
newTestConfig(packageName, serverGeneration, additionalProperties, getOutputDirectory()).execute();
}
}
The mojo is abstract, so that it can be extended with custom code like (the project logic is different for gradle and maven, so we have to keep it write it separate):
The task is abstract, so that it can be extended with custom code like (the project logic is different for gradle and maven, so we have to keep it write it separate):
@melix Could you take a look and give feedback if you think this could be possible? I see for OpenAPI there is more logic and it might be impossible to change now. But perhaps we can add it for new plugins.
Sounds like a good idea. As always the devil is in the details, but we can probably try something with the new json schema plugins. We should make sure not to end in a chicken and egg situation though, that is the Maven/Gradle plugin depends on Micronaut Sourcegen to generate sources of its plugins, but also at runtime. I think whatever we generate shouldn't depend on Micronaut runtime at all (basically we should use the generator infrastructure, but not the runtime).
Description
There is a lot of maven and gradle-specific code for micronaut plugins that seems to be generateable. An example is micronaut openapi generators. We will also need plugins for JSON schema generations and possibly others in the future.
For openapi all the parameters are repeated 3 times currently:
Generating would have the advanatage that both versions would have consistent parameters and possibly similar API.
Generation description
Add a new module to generate plugins.
Given a configuration for an plugin executable, like
we would want to generate plugin code stubs for reading these properties and calling the execute method.
Maven
we could generate maven Mojo:
The mojo is abstract, so that it can be extended with custom code like (the project logic is different for gradle and maven, so we have to keep it write it separate):
Gradle
Generate a Gradle Task:
The task is abstract, so that it can be extended with custom code like (the project logic is different for gradle and maven, so we have to keep it write it separate):
Additionally, gradle plugin will be written by user to extend the logic. For it an extension can be generated, as well:
@melix Could you take a look and give feedback if you think this could be possible? I see for OpenAPI there is more logic and it might be impossible to change now. But perhaps we can add it for new plugins.
cc @elifKurtay @graemerocher
The text was updated successfully, but these errors were encountered: