@@ -22,68 +22,68 @@ import org.gradle.api.Task
22
22
import org.yaml.snakeyaml.Yaml
23
23
24
24
internal fun Task.tweakConnectorYamlFiles (dir : File , newOutputDir : String ) {
25
- logger.info(" Tweaking connector.yaml files in {}" , dir.absolutePath)
26
- dir.walk().forEach { file ->
27
- if (file.isFile && file.name == " connector.yaml" ) {
28
- tweakConnectorYamlFile(file, newOutputDir)
29
- } else {
30
- logger.debug(" skipping file: {}" , file.absolutePath)
25
+ logger.info(" Tweaking connector.yaml files in {}" , dir.absolutePath)
26
+ dir.walk().forEach { file ->
27
+ if (file.isFile && file.name == " connector.yaml" ) {
28
+ tweakConnectorYamlFile(file, newOutputDir)
29
+ } else {
30
+ logger.debug(" skipping file: {}" , file.absolutePath)
31
+ }
31
32
}
32
- }
33
33
}
34
34
35
35
internal fun Task.tweakConnectorYamlFile (file : File , newOutputDir : String ) {
36
- logger.info(" Tweaking connector.yaml file: {}" , file.absolutePath)
36
+ logger.info(" Tweaking connector.yaml file: {}" , file.absolutePath)
37
37
38
- fun Map <* , * >.withTweakedKotlinSdk () =
39
- filterKeys { it == " kotlinSdk" }
40
- .mapValues { (_, value) ->
41
- val kotlinSdkMap =
42
- value as ? Map <* , * >
43
- ? : throw GradleException (
44
- " Parsing ${file.absolutePath} failed: \" kotlinSdk\" is " +
45
- (if (value == = null ) " null" else value::class .qualifiedName) +
46
- " , but expected ${Map ::class .qualifiedName} " +
47
- " (error code m697s27yxn)"
48
- )
49
- kotlinSdkMap.mapValues { (key, value) ->
50
- if (key == " outputDir" ) {
51
- newOutputDir
52
- } else {
38
+ fun Map <* , * >.withTweakedKotlinSdk () =
39
+ filterKeys { it == " kotlinSdk" }
40
+ .mapValues { (_, value) ->
41
+ val kotlinSdkMap =
42
+ value as ? Map <* , * >
43
+ ? : throw GradleException (
44
+ " Parsing ${file.absolutePath} failed: \" kotlinSdk\" is " +
45
+ (if (value == = null ) " null" else value::class .qualifiedName) +
46
+ " , but expected ${Map ::class .qualifiedName} " +
47
+ " (error code m697s27yxn)"
48
+ )
49
+ kotlinSdkMap.mapValues { (key, value) ->
50
+ if (key == " outputDir" ) {
51
+ newOutputDir
52
+ } else {
53
+ value
54
+ }
55
+ }
56
+ }
57
+
58
+ fun Map <* , * >.withTweakedGenerateNode () = mapValues { (key, value) ->
59
+ if (key != " generate" ) {
53
60
value
54
- }
61
+ } else {
62
+ val generateMap =
63
+ value as ? Map <* , * >
64
+ ? : throw GradleException (
65
+ " Parsing ${file.absolutePath} failed: \" generate\" is " +
66
+ (if (value == = null ) " null" else value::class .qualifiedName) +
67
+ " , but expected ${Map ::class .qualifiedName} " +
68
+ " (error code 9c2p857gq6)"
69
+ )
70
+ generateMap.withTweakedKotlinSdk()
55
71
}
56
- }
57
-
58
- fun Map <* , * >.withTweakedGenerateNode () = mapValues { (key, value) ->
59
- if (key != " generate" ) {
60
- value
61
- } else {
62
- val generateMap =
63
- value as ? Map <* , * >
64
- ? : throw GradleException (
65
- " Parsing ${file.absolutePath} failed: \" generate\" is " +
66
- (if (value == = null ) " null" else value::class .qualifiedName) +
67
- " , but expected ${Map ::class .qualifiedName} " +
68
- " (error code 9c2p857gq6)"
69
- )
70
- generateMap.withTweakedKotlinSdk()
71
72
}
72
- }
73
73
74
- val yaml = Yaml ()
75
- val rootObject = file.reader(Charsets .UTF_8 ).use { reader -> yaml.load<Any ?>(reader) }
74
+ val yaml = Yaml ()
75
+ val rootObject = file.reader(Charsets .UTF_8 ).use { reader -> yaml.load<Any ?>(reader) }
76
76
77
- val rootMap =
78
- rootObject as ? Map <* , * >
79
- ? : throw GradleException (
80
- " Parsing ${file.absolutePath} failed: root is " +
81
- (if (rootObject == = null ) " null" else rootObject::class .qualifiedName) +
82
- " , but expected ${Map ::class .qualifiedName} " +
83
- " (error code 45dw8jx8jd)"
84
- )
77
+ val rootMap =
78
+ rootObject as ? Map <* , * >
79
+ ? : throw GradleException (
80
+ " Parsing ${file.absolutePath} failed: root is " +
81
+ (if (rootObject == = null ) " null" else rootObject::class .qualifiedName) +
82
+ " , but expected ${Map ::class .qualifiedName} " +
83
+ " (error code 45dw8jx8jd)"
84
+ )
85
85
86
- val newRootMap = rootMap.withTweakedGenerateNode()
86
+ val newRootMap = rootMap.withTweakedGenerateNode()
87
87
88
- file.writer(Charsets .UTF_8 ).use { writer -> yaml.dump(newRootMap, writer) }
88
+ file.writer(Charsets .UTF_8 ).use { writer -> yaml.dump(newRootMap, writer) }
89
89
}
0 commit comments