-
Notifications
You must be signed in to change notification settings - Fork 580
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Configuration annotation processor. #3250
Configuration annotation processor. #3250
Conversation
common/configurable/src/main/java/io/helidon/common/configurable/ThreadPoolSupplier.java
Outdated
Show resolved
Hide resolved
security/providers/abac/src/main/java/io/helidon/security/providers/abac/AbacProvider.java
Outdated
Show resolved
Hide resolved
Awesome! 👏 |
c130191
to
08eec7f
Compare
...rocessor/src/test/java/io/helidon/config/metadata/processor/ConfigMetadataProcessorTest.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've made some detailed comments attached to lines.
Would the build-tools
repo, rather than the main repo, be a better fit for the new modules? All the interesting work--or all the work?--happens at build-time.
config/metadata/src/main/java/io/helidon/config/metadata/Configured.java
Outdated
Show resolved
Hide resolved
@tjquinno The processor depends on the new metadata module, It has a high coupling with config overall. Having it co-located with config is a nice convenience. If it were located in build-tools it would make things quite complicated. |
@romain-grecourt Neither For sure the processor is tightly coupled to the metadata, but I am not seeing the high coupling you are from either of those to config itself. And now that I look at the poms again, |
(not doing a quote reply as this is the very next comment)
If you look at the processor implementation you can see it visits config code. E.g. configType = elementUtils.getTypeElement("io.helidon.config.Config").asType(); |
I did get that On the other hand, I do get how messy it can get if a module in one repo depends on one from another repo and each has its own release cadence, etc. and I was never arguing for that. It just seems a shame that build-time stuff drifts into the main repo. Always trade-offs. |
I think the annotations are part of Helidon public API, so these should be part of Helidon itself. The annotation processor could be part of build tools, but then we would have a cyclic dependency (even if a "soft" one). If we did any change in the annotations, we would need to release new build tools, then upgrade to them in Helidon to be able to update the annotations themself. |
Signed-off-by: Tomas Langer <tomas.langer@oracle.com>
Signed-off-by: Tomas Langer <tomas.langer@oracle.com>
Signed-off-by: Tomas Langer <tomas.langer@oracle.com>
Documentation. Signed-off-by: Tomas Langer <tomas.langer@oracle.com>
…now value Signed-off-by: Tomas Langer <tomas.langer@oracle.com>
Signed-off-by: Tomas Langer <tomas.langer@oracle.com>
Signed-off-by: Tomas Langer <tomas.langer@oracle.com>
Signed-off-by: Tomas Langer <tomas.langer@oracle.com>
Signed-off-by: Tomas Langer <tomas.langer@oracle.com>
Signed-off-by: Tomas Langer <tomas.langer@oracle.com>
551fb13
to
949cf92
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
Follow up issue: #3463 |
Signed-off-by: Tomas Langer tomas.langer@oracle.com
Documentation is now here: https://github.com/oracle/helidon/pull/3250/files#diff-fb1435883a8ac748d3e2ac8dd8e416d4ff9b32912b3595631479d5f2e3d90f19
To see what can be done - please check the new example. Just add a dependency that has metadata on the classpath, and run it (I would recommend
helidon-microprofile
bundle, as that contains most of the types that were created as part of this PR.Annotations are in module
helidon-config-metadata
The annotation processor is in module
helidon-config-metadata-processor
.There are a few new annotations:
io.helidon.config.metadata.Configured
- marks a Builder or a class as configurable through configurationio.helidon.config.metadata.ConfiguredOption
(repeatable) - defines a single configuration optionio.helidon.config.metadata.ConfiguredValue
- possible values of an option (such as enum values)Configured
has the following properties:root()
- root configured classes can be configured in configuration (such asapplication.yaml
) as standalone components. Example:server
,security
,tracing
prefix()
- the configuration prefix used for this class (such asserver
for web server,abac
for ABAC security provider), empty for most nested configurations, as they use the key defined on owning typeignoreBuildMethod()
- treat this type as an abstract class/interface and not as a builder type (for cases where the builder is used as a parameter to another builder that builds the target type. This is not according to our guidelines, but used for example inKeyConfig
for PEM and Keystore buildersprovides()
- interfaces/abstract classes implemented by this type that are used as providers to another configuration. Example:SecurityProvider
SPI in Security, where each provider has its own configurationConfigureOption
has the following properties:key()
- defines key in configuration. Guessed from method name when on builder method (failOnError ->fail-on-error
)type()
- type of the configuration value. May be another@Configured
type. In such a case that type can be used as a subtree of the key of this property. Guessed from method parameter when on builder method (primitive types are boxed)description()
- description, created from Javadoc when on builder methodrequired()
- set totrue
for required options, false by defaultvalue()
- what is the default value of this property, optional (if not defined and not required, default is defined in documentation)experimental()
- marks an experimental propertykind()
- can be configured toLIST
,MAP
orVALUE
,VALUE
is the defaultprovider()
- set to true if this is provided by a provider that may be in another moduleallowedValues()
- values with description for possible options of a property. Guessed from enum and javadoc for enumerations.deprecated()
- deprecated option - description should describe how to change thismergeWithParent()
- whether to ignore the key of this property and use all keys in the nested object instead (only for nested types, defaults tofalse
)Annotations are processed and a
META-INF/helidon/config-metadata-json
is created for each moduleSee the readme mentioned above that describes the JSON structure. If you build helidon from this PR, a few metadata files get generated (see
security/security
,webserver/webserver
and some security providers (oidc
,http-basic-auth
,abac
).Required follow up - I will create these issues once this PR is merged, as working on them would not be benefitial now:
application.yaml
from current project (as the example in this PR does), or that would generate a document with the same information (HTML?)