Skip to content

Commit 4b60d35

Browse files
committed
fix(bulk-model-sync-gradle): use kotlin io use instead of closing client manually
1 parent c338e8b commit 4b60d35

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

bulk-model-sync-gradle/src/main/kotlin/org/modelix/model/sync/bulk/gradle/tasks/ExportFromModelServer.kt

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -69,30 +69,30 @@ abstract class ExportFromModelServer @Inject constructor(of: ObjectFactory) : De
6969

7070
@TaskAction
7171
fun export() {
72-
val client = ModelClientV2PlatformSpecificBuilder()
72+
val modelClient = ModelClientV2PlatformSpecificBuilder()
7373
.url(url.get())
7474
.build()
75+
modelClient.use { client ->
76+
runBlocking { client.init() }
7577

76-
runBlocking { client.init() }
77-
78-
val branch = if (revision.isPresent) {
79-
getBranchByRevision(client)
80-
} else {
81-
getBranchByRepoIdAndBranch(client)
82-
}
78+
val branch = if (revision.isPresent) {
79+
getBranchByRevision(client)
80+
} else {
81+
getBranchByRepoIdAndBranch(client)
82+
}
8383

84-
branch.runRead {
85-
val root = branch.getRootNode()
86-
logger.info("Got root node: {}", root)
87-
val outputDir = outputDir.get().asFile
84+
branch.runRead {
85+
val root = branch.getRootNode()
86+
logger.info("Got root node: {}", root)
87+
val outputDir = outputDir.get().asFile
8888

89-
getIncludedModules(root).forEach {
90-
val fileName = it.getPropertyValue(BuiltinLanguages.jetbrains_mps_lang_core.INamedConcept.name)
91-
val outputFile = outputDir.resolve("$fileName.json")
92-
ModelExporter(it).export(outputFile)
89+
getIncludedModules(root).forEach {
90+
val fileName = it.getPropertyValue(BuiltinLanguages.jetbrains_mps_lang_core.INamedConcept.name)
91+
val outputFile = outputDir.resolve("$fileName.json")
92+
ModelExporter(it).export(outputFile)
93+
}
9394
}
9495
}
95-
client.close()
9696
}
9797

9898
private fun getIncludedModules(root: INode): Iterable<INode> {

0 commit comments

Comments
 (0)