Skip to content

Commit

Permalink
Make logging output of MoCompile tasks more comprehensive
Browse files Browse the repository at this point in the history
*.mo files in the same directory are summarized and sorted alphabetically.
The warning about duplicate filenames is now more visible.
  • Loading branch information
floscher committed Oct 1, 2018
1 parent 6ca0102 commit 9755123
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
4 changes: 3 additions & 1 deletion src/main/kotlin/task/LangCompile.kt
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@ open class LangCompile
}
logger.lifecycle(" into ${destinationDir.absolutePath}/$subdirectory")
langPaths.filter { it.value.size >= 2 }.forEach { lang, paths ->
logger.warn("\nWARNING: For language $lang there are multiple *.lang files, of which only the last one in the following list is used:\n * ${paths.joinToString("\n * ")}\n")
val warnMsg = "\nWARNING: For language $lang there are multiple *.lang files, of which only the last one in the following list is used:\n * ${paths.joinToString("\n * ")}\n"
logger.warn(warnMsg)
project.gradle.buildFinished { logger.warn(warnMsg) }
}
}
}
16 changes: 11 additions & 5 deletions src/main/kotlin/task/MoCompile.kt
Original file line number Diff line number Diff line change
Expand Up @@ -58,18 +58,24 @@ open class MoCompile
project.fileTree(outDir)
.filter { it.isFile && it.name.endsWith(".lang") }
.forEach { it.delete() }

inputFiles.groupBy { it.parentFile.absolutePath }.forEach { dir, files ->
logger.lifecycle(" from $dir : ${files.map { it.nameWithoutExtension }.sorted().joinToString(", ")}")
}

val langMap = mutableMapOf<String, Map<MsgId, MsgStr>>()
inputFiles.forEach {
logger.lifecycle(" ${it.absolutePath}" + if (langMap.containsKey(it.nameWithoutExtension)) {
" (will overwrite existing file!)"
} else {
""
})
langMap[it.nameWithoutExtension] = MoReader(it.toURI().toURL()).readFile()
}

logger.lifecycle("Writing the *.lang files into ${outDir.absolutePath}")
LangWriter().writeLangFile(outDir, langMap, project.extensions.josm.i18n.mainLanguage)

inputFiles.groupBy { it.nameWithoutExtension }.filter { it.value.size >= 2 }.forEach { lang, paths ->
val warnMsg = "\nWARNING: For language $lang there are multiple *.mo files, of which only the last one in the following list is used:\n * ${paths.joinToString("\n * ")}\n"
logger.warn(warnMsg)
project.gradle.buildFinished { logger.warn(warnMsg) }
}
}
}
}
2 changes: 1 addition & 1 deletion src/main/kotlin/task/PoCompile.kt
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ open class PoCompile
}
}
convertedFiles.groupBy { it.parentFile.absolutePath }.forEach { dir, files ->
logger.lifecycle(" from $dir :\n ${files.map { it.nameWithoutExtension }.sorted().joinToString(", ")}")
logger.lifecycle(" from $dir : ${files.map { it.nameWithoutExtension }.sorted().joinToString(", ")}")
}
logger.lifecycle(" into $outDir")

Expand Down

0 comments on commit 9755123

Please sign in to comment.