aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/com/replaymod/gradle/remap/Transformer.kt
diff options
context:
space:
mode:
authorJonas Herzig <jonas@spark-squared.com>2020-05-22 12:00:34 +0200
committerJonas Herzig <jonas@spark-squared.com>2020-05-22 12:00:34 +0200
commit39b3db94179e8fb99041fb0d303140697c091585 (patch)
tree4a4efa35b3612a25d53b1cf12f21fa1bb5d4c18f /src/main/kotlin/com/replaymod/gradle/remap/Transformer.kt
parentc0cdf855f33ad27f9ea6741781a52ab37afce6be (diff)
downloadRemap-39b3db94179e8fb99041fb0d303140697c091585.tar.gz
Remap-39b3db94179e8fb99041fb0d303140697c091585.tar.bz2
Remap-39b3db94179e8fb99041fb0d303140697c091585.zip
Properly dispose of root Disposable once done
Diffstat (limited to 'src/main/kotlin/com/replaymod/gradle/remap/Transformer.kt')
-rw-r--r--src/main/kotlin/com/replaymod/gradle/remap/Transformer.kt4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/main/kotlin/com/replaymod/gradle/remap/Transformer.kt b/src/main/kotlin/com/replaymod/gradle/remap/Transformer.kt
index 3849483..ed3b53c 100644
--- a/src/main/kotlin/com/replaymod/gradle/remap/Transformer.kt
+++ b/src/main/kotlin/com/replaymod/gradle/remap/Transformer.kt
@@ -44,6 +44,7 @@ class Transformer(private val map: MappingSet) {
@Throws(IOException::class)
fun remap(sources: Map<String, String>): Map<String, Pair<String, List<Pair<Int, String>>>> {
val tmpDir = Files.createTempDirectory("remap")
+ val disposable = Disposer.newDisposable()
try {
for ((unitName, source) in sources) {
val path = tmpDir.resolve(unitName)
@@ -59,7 +60,7 @@ class Transformer(private val map: MappingSet) {
config.put<MessageCollector>(CLIConfigurationKeys.MESSAGE_COLLECTOR_KEY, PrintingMessageCollector(System.err, MessageRenderer.GRADLE_STYLE, true))
val environment = KotlinCoreEnvironment.createForProduction(
- Disposer.newDisposable(),
+ disposable,
config,
EnvironmentConfigFiles.JVM_CONFIG_FILES
)
@@ -100,6 +101,7 @@ class Transformer(private val map: MappingSet) {
return results
} finally {
Files.walk(tmpDir).map<File> { it.toFile() }.sorted(Comparator.reverseOrder()).forEach { it.delete() }
+ Disposer.dispose(disposable)
}
}