hey, I'm vaguely following the declarative Gradle ...
# declarative-gradle
m
hey, I'm vaguely following the declarative Gradle project, mostly by lack of time. However, as a designer of the Micronaut Gradle plugins, I'm extremely interested in making sure that we can profit from this at some point in time. Some thoughts in thread.
👀 3
❤️ 4
First of all, thanks for the first docs here: https://declarative.gradle.org/
my first thought was "the dependency declarations should probably use version catalogs and not strings". We've used catalogs for 3 years now in the Micronaut team and built a lot of standardized plugins on top of it, no one would come back. Such things involve conventions on aliases defined in the catalogs, such as
managed-foo
, so that we can derive things in BOMs we generate. This is not possible with stringly-typed dependencies, I think a project designed "for the future" should probably use this instead.
💯 3
the second aspect I'm thinking about is the "shadowing" of extensions. The Micronaut plugins are already fairly declarative. We have a
micronaut { ... }
block where users can configure things, and plugins for various kinds of components we produce. For example we have an
application
plugin, but also a
library
one. In addition, we have companion plugins which can be combined to enable/disable features. For example, the
application
plugin actually composes the "minimal" application plugin with the "docker" and "graalvm" plugins, so that users can build an app, compile it as a native binary then deploy as a docker container. But a user may choose to use the minimal plugins if they don't need such features.
One of the nice things I would like to have is a way to "hide" some extensions or properties from configuration. For example, since we combine many plugins (shadow plugin, graalvm plugin, etc...) there are things that we would probably want to configure via the
micronaut
extension, but not the
graalvm
one, so ideally, despite the fact that the
graalvm
plugin is applied, the extension created by this plugin should be hidden.
in other words, today it's fairly simple for plugin authors to compose on top of other plugins, but it's more complicated to restrict the set of features they expose to these we want to support.
👍 2
Should you want to try declarative Gradle on real world projects, I think Micronaut would be a good fit. We have actually 2 sets of plugins: • our internal convention plugins for building Micronaut itself. Our builds are extremely simple thanks to these, there's almost no custom code in builds, everything is designed via a
micronautBuild
extension • our "user facing" plugins, for developers who build apps with Micronaut. These are the ones I described above. In both cases, I think these are good fit if you want to face some real world use cases, like conventions to collect project dependencies so that the BOM module doesn't have to declare explicitly dependencies on all projects, etc.
All this to say that while I cannot commit time to look regularly at the declarative Gradle project, I'm happy to help you understand our use cases, describe what we do, etc.
❤️ 2
s
Hey Cedric, hope you're doing well.
my first thought was "the dependency declarations should probably use version catalogs and not strings".
This is still an open area to investigate. We're intentionally avoiding any existing project extension right now. There's some overlap with version catalogs and how the declarative files work that may change how version catalogs are incorporated. A simple way to update/add dependencies is a must still.
in other words, today it's fairly simple for plugin authors to compose on top of other plugins, but it's more complicated to restrict the set of features they expose to these we want to support.
The way we're thinking this would work is you'd naturally get what you want. We have "software types" (this the thing you're building) and then some kind of mix-in to extend those software types. Let's say there's a
micronautLibrary
and
micronautApplication
and you can mix-in
graalvm
as an optional thing. In a build file, you can only access the software types, so a project building a micronautLibrary with graalvm could look like:
Copy code
micronautLibrary {
    graalvm {
        // graal specific configuration
    }
}
This would imply the Micronaut library plugin would be applied as well as the graalvm companion plugin. None of the project extensions would be accessible from the build file, but they'd still be available through build logic.