2014-06-05 22:37:32 +08:00
|
|
|
def processModule(File moduleDir, File generatedResourcesDir) {
|
|
|
|
def moduleName = moduleDir.name
|
|
|
|
def factoriesFile = new File(moduleDir, 'META-INF/spring.factories')
|
|
|
|
new File(generatedResourcesDir, "auto-configuration-classes-${moduleName}.adoc")
|
|
|
|
.withPrintWriter {
|
|
|
|
generateAutoConfigurationClassTable(moduleName, factoriesFile, it)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
def generateAutoConfigurationClassTable(String module, File factories, PrintWriter writer) {
|
|
|
|
writer.println '[cols="4,1"]'
|
|
|
|
writer.println '|==='
|
2014-06-10 11:03:17 +08:00
|
|
|
writer.println '| Configuration Class | Links'
|
2014-06-05 22:37:32 +08:00
|
|
|
|
|
|
|
getAutoConfigurationClasses(factories).each {
|
|
|
|
writer.println ''
|
2017-10-12 00:51:04 +08:00
|
|
|
writer.println "| {github-code}/spring-boot-project/$module/src/main/java/$it.path.{sc-ext}[`$it.name`]"
|
2014-06-10 11:03:17 +08:00
|
|
|
writer.println "| {dc-root}/$it.path.{dc-ext}[javadoc]"
|
2014-06-05 22:37:32 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
writer.println '|==='
|
|
|
|
}
|
|
|
|
|
|
|
|
def getAutoConfigurationClasses(File factories) {
|
|
|
|
factories.withInputStream {
|
|
|
|
def properties = new Properties()
|
|
|
|
properties.load(it)
|
|
|
|
properties.get('org.springframework.boot.autoconfigure.EnableAutoConfiguration')
|
|
|
|
.split(',')
|
|
|
|
.collect {
|
|
|
|
def path = it.replace('.', '/')
|
|
|
|
def name = it.substring(it.lastIndexOf('.') + 1)
|
|
|
|
[ 'path': path, 'name': name]
|
|
|
|
}
|
|
|
|
.sort {a, b -> a.name.compareTo(b.name)}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
def autoConfigDir = new File(project.build.directory, 'auto-config')
|
|
|
|
def generatedResourcesDir = new File(project.build.directory, 'generated-resources')
|
2014-06-10 11:03:17 +08:00
|
|
|
autoConfigDir.eachDir { processModule(it, generatedResourcesDir) }
|