Minor, improve Ant test on includeRuntime

Also check that we _do_ include runtime if includeRuntime is true.
This commit is contained in:
Alexander Udalov
2021-01-21 18:25:49 +01:00
committed by Alexander Udalov
parent a13eb4c8e6
commit e17153fab9
@@ -4,11 +4,12 @@ import java.util.jar.JarFile
fun main(args: Array<String>) { fun main(args: Array<String>) {
val jar = File(args[0]) val jar = File(args[0])
// if "includeRuntime" is specified to be true // if "includeRuntime" is specified to be true
var specifiedBeTrue = args[1].toBoolean() var shouldIncludeRuntime = args[1].toBoolean()
for (entry in JarFile(jar).entries()) { val hasKotlinPackage = JarFile(jar).entries().toList().any { it.name.startsWith("kotlin/") }
if (!specifiedBeTrue && entry.name.startsWith("kotlin/")) { if (shouldIncludeRuntime != hasKotlinPackage) {
println("Error: Kotlin runtime is expected to be excluded if the attribute \"includeRuntime\" is not specified to be true") println(
break; "Error: Kotlin runtime is expected to be included only if the attribute \"includeRuntime\" is specified to be true\n" +
} "includeRuntime = ${shouldIncludeRuntime}; hasKotlinPackage = $hasKotlinPackage"
)
} }
} }