diff --git a/src/functionalTest/kotlin/com/github/jengelman/gradle/plugins/shadow/util/AppendableMavenRepository.kt b/src/functionalTest/kotlin/com/github/jengelman/gradle/plugins/shadow/util/AppendableMavenRepository.kt index f4956cde3..5793e0ef2 100644 --- a/src/functionalTest/kotlin/com/github/jengelman/gradle/plugins/shadow/util/AppendableMavenRepository.kt +++ b/src/functionalTest/kotlin/com/github/jengelman/gradle/plugins/shadow/util/AppendableMavenRepository.kt @@ -124,7 +124,7 @@ class AppendableMavenRepository( } fun build(): Path { - if (!::existingJar.isInitialized) error("No jar file provided for $coordinate") + check(::existingJar.isInitialized) { "No jar file provided for $coordinate" } return existingJar.also { check(it.exists()) { "Jar file doesn't exist for $coordinate in: $it" } check(it.isRegularFile()) { "Jar is not a regular file for $coordinate in: $it" } diff --git a/src/functionalTest/kotlin/com/github/jengelman/gradle/plugins/shadow/util/JarPath.kt b/src/functionalTest/kotlin/com/github/jengelman/gradle/plugins/shadow/util/JarPath.kt index ffd80d546..13302d12d 100644 --- a/src/functionalTest/kotlin/com/github/jengelman/gradle/plugins/shadow/util/JarPath.kt +++ b/src/functionalTest/kotlin/com/github/jengelman/gradle/plugins/shadow/util/JarPath.kt @@ -30,7 +30,7 @@ fun ZipFile.getContent(entryName: String): String { } fun ZipFile.getStream(entryName: String): InputStream { - val entry = getEntry(entryName) ?: error("Entry $entryName not found in all entries: ${entries().toList()}") + val entry = requireNotNull(getEntry(entryName)) { "Entry $entryName not found in all entries: ${entries().toList()}" } return getInputStream(entry) } diff --git a/src/functionalTest/kotlin/com/github/jengelman/gradle/plugins/shadow/util/RunProcess.kt b/src/functionalTest/kotlin/com/github/jengelman/gradle/plugins/shadow/util/RunProcess.kt index c15413598..d9e3f5218 100644 --- a/src/functionalTest/kotlin/com/github/jengelman/gradle/plugins/shadow/util/RunProcess.kt +++ b/src/functionalTest/kotlin/com/github/jengelman/gradle/plugins/shadow/util/RunProcess.kt @@ -9,8 +9,8 @@ fun runProcess( val err = process.errorStream.bufferedReader().use { it.readText() } val out = process.inputStream.bufferedReader().use { it.readText() } - if (exitCode != 0 || err.isNotEmpty()) { - error("Error occurred when running command line: $err") + check(exitCode == 0 && err.isEmpty()) { + "Error occurred when running command line: $err" } return out diff --git a/src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/transformers/TransformerContext.kt b/src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/transformers/TransformerContext.kt index 59c412e18..71e3f5cfa 100644 --- a/src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/transformers/TransformerContext.kt +++ b/src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/transformers/TransformerContext.kt @@ -18,7 +18,7 @@ public data class TransformerContext @JvmOverloads constructor( public fun relocators(relocators: Set): Builder = apply { this.relocators = relocators } public fun build(): TransformerContext = TransformerContext( path = path, - inputStream = inputStream ?: error("inputStream is required"), + inputStream = requireNotNull(inputStream) { "inputStream is required" }, relocators = relocators, ) } diff --git a/src/test/kotlin/com/github/jengelman/gradle/plugins/shadow/transformers/ServiceFileTransformerTest.kt b/src/test/kotlin/com/github/jengelman/gradle/plugins/shadow/transformers/ServiceFileTransformerTest.kt index 1b59c60be..28f539c8d 100644 --- a/src/test/kotlin/com/github/jengelman/gradle/plugins/shadow/transformers/ServiceFileTransformerTest.kt +++ b/src/test/kotlin/com/github/jengelman/gradle/plugins/shadow/transformers/ServiceFileTransformerTest.kt @@ -158,7 +158,7 @@ class ServiceFileTransformerTest : BaseTransformerTest() } fun ZipFile.getStream(entryName: String): InputStream { - val entry = getEntry(entryName) ?: error("Entry $entryName not found in all entries: ${entries().toList()}") + val entry = requireNotNull(getEntry(entryName)) { "Entry $entryName not found in all entries: ${entries().toList()}" } return getInputStream(entry) }