fun check()

in buildSrc/src/main/kotlin/org/jetbrains/compose/reload/build/withShadowingPlugin.kt [149:198]


    fun check() {
        val entries = inputs.files.flatMap { file ->
            ZipFile(file).use { zipFile ->
                zipFile.entries().asSequence().toList().mapNotNull { entry ->
                    if (entry.isDirectory) {
                        return@mapNotNull entry.name
                    } else if (entry.name.endsWith(".class")) {
                        val parent = Path(entry.name).parent
                        if (parent != null) {
                            return@mapNotNull parent.invariantSeparatorsPathString
                        }
                    } else {
                        return@mapNotNull entry.name
                    }
                    null
                }
            }
        }.toSet()

        val actualText = buildString {
            appendLine("Contains packages and resources found in the jar file")
            appendLine("########################################################")
            appendLine()
            entries.sorted().forEach { entry ->
                appendLine(entry)
            }
        }.trim().lines().joinToString("\n")

        val expectFile = output.get().asFile
        if (!expectFile.exists()) {
            expectFile.writeText(actualText)
            throw AssertionError("File ${expectFile.toURI()} did not exist; Generated.")
        }

        val expectText = output.get().asFile.readText()
            .trim().lines().joinToString("\n")
        if (expectText != actualText) {
            val actualFile = expectFile.resolveSibling(
                "${expectFile.nameWithoutExtension}-actual.${expectFile.extension}"
            )

            actualFile.writeText(actualText)

            throw AssertionError(
                "Inconsistent jar dump:\n" +
                    "expected: ${expectFile.toURI()}\n" +
                    "actual: ${actualFile.toURI()}"
            )
        }
    }