-
Notifications
You must be signed in to change notification settings - Fork 342
/
catalogbuilder.groovy
36 lines (29 loc) · 1.24 KB
/
catalogbuilder.groovy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import groovy.json.JsonSlurper
import org.apache.camel.catalog.DefaultCamelCatalog
import org.yaml.snakeyaml.Yaml
import org.yaml.snakeyaml.DumperOptions
def slurper = new JsonSlurper()
def catalog = new DefaultCamelCatalog()
def output = new TreeMap()
output['version'] = catalog.loadedVersion
output['components'] = [:]
catalog.findComponentNames().sort().each { name ->
def json = slurper.parseText(catalog.componentJSonSchema(name))
output['components'][name] = [:]
output['components'][name]['dependency'] = [:]
output['components'][name]['dependency']['groupId'] = json.component.groupId
output['components'][name]['dependency']['artifactId'] = json.component.artifactId
output['components'][name]['dependency']['version'] = json.component.version
output['components'][name]['schemes'] = [ json.component.scheme.trim() ]
if (json.component.alternativeSchemes) {
json.component.alternativeSchemes.split(',').each {
scheme -> output['components'][name]['schemes'] << scheme.trim()
}
}
}
def options = new DumperOptions()
options.indent = 2
options.defaultFlowStyle = DumperOptions.FlowStyle.BLOCK
new File(catalogOutputFile).newWriter().withWriter {
w -> w << new Yaml(options).dump(output)
}