Commit Graph

209 Commits (a825e9f49375adfdb0219fe732cb190479e32245)

Author SHA1 Message Date
Phillip Webb 7b09cbee35 Don't generate empty configuration meta-data
Update ConfigurationMetadataAnnotationProcessor to only write non-empty
meta-data files.

Fixes gh-1858
10 years ago
Phillip Webb 3c9476fbe6 Polish 10 years ago
Stephane Nicoll 2786234eb4 Detect builder-style setter
Previously, a setter method that was returning the current instance was
not identified as a "setter" by the configuration processor. As a result,
builder-style APIs were not covered by the configuration metadata.

If a setter returns either void or the current class, it is now
recognized as a valid setter.

Fixes gh-1854
10 years ago
Stephane Nicoll 5946a44b7b Fix typo 10 years ago
Phillip Webb 2696d37097 Protect against transitive additional meta-data
Update ConfigurationMetadataAnnotationProcessor to ensure that only
local `additional-spring-configuration-metadata.json` files are merged
with the final output.

See gh-1830
10 years ago
Phillip Webb 7e5bb9697c Call meta-data processor regardless of annotations
Update ConfigurationMetadataAnnotationProcessor so that it gets called
even if the source code doesn't include any @ConfigurationProperties
items.

See gh-1830
10 years ago
Stephane Nicoll a46396f691 Add @NestedConfigurationProperty meta-data support
Add a @NestedConfigurationProperty annotation which can be used to
customize how configuration mete-data is generated.

Prior to this commit only inner-classes where considered nested
(see Tomcat in ServerProperties). Using this new annotation, the Ssl
property in ServerProperties can be detected as well.

See gh-1001
10 years ago
Phillip Webb c73adcd198 Add a defaultValue attribute to config meta-data
Update `ConfigurationMetadataAnnotationProcessor` to include the
'defaultValue' of a property when possible. For example the
'defaultValue' or 'server.port' is '8080'.

Default values are detected by inspecting the field assignments of
@ConfigurationProperties items. In order to detect field values some
internals of the Java compiler are used. To save a dependency on
'tools.jar' internal javac classes are accessed using reflection.

See gh-1001
10 years ago
Stephane Nicoll 884c058e57 Add processor to generate configuration meta-data
Adds an annotation processor to generates a JSON meta-data file at
compile time from @ConfigurationProperties items. Each meta-data file
can include an array or 'properties' and 'groups'.

A 'property' is a single item that may appear in a Spring Boot
'application.properties' file with a given value. For example,
'server.port' and 'server.context-path' are properties. Each property
may optionally include 'type' and 'description' attributes to provide
the data type (e.g. `java.lang.Integer`, `java.lang.String`) and
some short documentation (taken from the field javadoc) about what the
property is for. For consistency, the type of a primitive is translated
to its wrapper counterpart, i.e. `boolean` becomes `java.lang.Boolean`.

A 'group' provides a higher level grouping of properties. For example
the 'server.port' and 'server.context-path' properties are in the
'server' group.

Both 'property' and 'group' items may additional have 'sourceType' and
'sourceMethod' attributes to indicate the source that contributed them.

Users may use `META-INF/additional-spring-configuration-metadata.json`
to manually provide additionally meta-data that is not covered by
@ConfigurationProperties objects. The contents of this file will be
read and merged with harvested items. The complete meta-data file is
finally written to `META-INF/spring-configuration-metadata.json`.

See gh-1001
10 years ago