Auto-generate the "Common application properties"

Prior to this commit, the application properties listed in the reference
documentation would be manually managed and updated.

This commit adds a new `spring-boot-configuration-docs` project that
extracts that information from the available JSON metadata and writes
Asciidoctor tables ready for inclusion in the reference documentation.

The `generateConfigurationPropertyTables.groovy` is using this library
and configures the sections and how namespaces should be organized.

Fixes gh-8237
This commit is contained in:
Brian Clozel
2019-02-18 15:34:53 +01:00
parent add8c6f295
commit 2a2bfb9915
15 changed files with 892 additions and 1549 deletions

View File

@@ -0,0 +1,79 @@
import org.springframework.boot.configurationdocs.ConfigurationMetadataDocumentWriter
import org.springframework.boot.configurationdocs.DocumentOptions
import org.springframework.core.io.UrlResource
import java.nio.file.Path
import java.nio.file.Paths
def getConfigMetadataInputStreams() {
def mainMetadata = getClass().getClassLoader().getResources("META-INF/spring-configuration-metadata.json")
def additionalMetadata = getClass().getClassLoader().getResources("META-INF/additional-spring-configuration-metadata.json")
def streams = []
streams += mainMetadata.collect { new UrlResource(it).getInputStream() }
streams += additionalMetadata.collect { new UrlResource(it).getInputStream() }
return streams
}
def generateConfigMetadataDocumentation() {
def streams = getConfigMetadataInputStreams()
try {
Path outputPath = Paths.get(project.build.directory, 'generated-resources', 'config-docs')
def builder = DocumentOptions.builder();
builder
.addSection("core")
.withKeyPrefixes("debug", "trace", "logging", "spring.aop", "spring.application",
"spring.autoconfigure", "spring.banner", "spring.beaninfo", "spring.config",
"spring.info", "spring.jmx", "spring.main", "spring.messages", "spring.pid",
"spring.profiles", "spring.quartz", "spring.reactor", "spring.task",
"spring.mandatory-file-encoding", "info", "spring.output.ansi.enabled")
.addSection("mail")
.withKeyPrefixes("spring.mail", "spring.sendgrid")
.addSection("cache")
.withKeyPrefixes("spring.cache")
.addSection("server")
.withKeyPrefixes("server")
.addSection("web")
.withKeyPrefixes("spring.hateoas",
"spring.http", "spring.servlet", "spring.jersey",
"spring.mvc", "spring.resources", "spring.webflux")
.addSection("json")
.withKeyPrefixes("spring.jackson", "spring.gson")
.addSection("templating")
.withKeyPrefixes("spring.freemarker", "spring.groovy", "spring.mustache", "spring.thymeleaf")
.addOverride("spring.groovy.template.configuration", "See GroovyMarkupConfigurer")
.addSection("security")
.withKeyPrefixes("spring.security", "spring.ldap", "spring.session")
.addSection("data-migration")
.withKeyPrefixes("spring.flyway", "spring.liquibase")
.addSection("data")
.withKeyPrefixes("spring.couchbase", "spring.elasticsearch", "spring.h2",
"spring.influx", "spring.mongodb", "spring.redis",
"spring.dao", "spring.data", "spring.datasource", "spring.jooq",
"spring.jdbc", "spring.jpa")
.addOverride("spring.datasource.dbcp2", "Commons DBCP2 specific settings")
.addOverride("spring.datasource.tomcat", "Tomcat datasource specific settings")
.addOverride("spring.datasource.hikari", "Hikari specific settings")
.addSection("transaction")
.withKeyPrefixes("spring.jta", "spring.transaction")
.addSection("integration")
.withKeyPrefixes("spring.activemq", "spring.artemis", "spring.batch",
"spring.integration", "spring.jms", "spring.kafka", "spring.rabbitmq", "spring.hazelcast",
"spring.webservices")
.addSection("actuator")
.withKeyPrefixes("management")
.addSection("devtools")
.withKeyPrefixes("spring.devtools")
.addSection("testing")
.withKeyPrefixes("spring.test");
ConfigurationMetadataDocumentWriter writer = new ConfigurationMetadataDocumentWriter();
writer.writeDocument(outputPath, builder.build(), streams.toArray(new InputStream[0]));
}
finally {
streams.each { it.close() }
}
}
generateConfigMetadataDocumentation()