|
|
@ -112,21 +112,35 @@ val checkJar by tasks.registering { |
|
|
|
doLast { |
|
|
|
doLast { |
|
|
|
val file = jar.get().archiveFile.get().asFile |
|
|
|
val file = jar.get().archiveFile.get().asFile |
|
|
|
ZipFile(file).use { zip -> |
|
|
|
ZipFile(file).use { zip -> |
|
|
|
val nonJbComposeClasses = zip.entries().asIterator().asSequence().filter { |
|
|
|
checkJarContainsExpectedPackages(zip) |
|
|
|
!it.isDirectory |
|
|
|
} |
|
|
|
&& it.name.endsWith(".class") |
|
|
|
} |
|
|
|
&& !it.name.startsWith("org/jetbrains/compose") |
|
|
|
} |
|
|
|
}.toList() |
|
|
|
|
|
|
|
if (nonJbComposeClasses.any()) { |
|
|
|
// we want to avoid accidentally including unexpected jars/packages, e.g kotlin-stdlib etc |
|
|
|
error(buildString { |
|
|
|
fun checkJarContainsExpectedPackages(jar: ZipFile) { |
|
|
|
appendLine("Some classes from $file are not from 'org.jetbrains.compose' package:") |
|
|
|
val expectedPackages = arrayOf( |
|
|
|
for (entry in nonJbComposeClasses) { |
|
|
|
"org/jetbrains/compose", |
|
|
|
appendLine(" * ${entry.name}") |
|
|
|
"kotlinx/serialization" |
|
|
|
} |
|
|
|
) |
|
|
|
}) |
|
|
|
val unexpectedClasses = arrayListOf<String>() |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
for (entry in jar.entries()) { |
|
|
|
|
|
|
|
if (entry.isDirectory || !entry.name.endsWith(".class")) continue |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (expectedPackages.none { prefix -> entry.name.startsWith(prefix) }) { |
|
|
|
|
|
|
|
unexpectedClasses.add(entry.name) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (unexpectedClasses.any()) { |
|
|
|
|
|
|
|
error(buildString { |
|
|
|
|
|
|
|
appendLine("Some classes from ${jar.name} are not from 'org.jetbrains.compose' package:") |
|
|
|
|
|
|
|
unexpectedClasses.forEach { |
|
|
|
|
|
|
|
appendLine(" * $it") |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
tasks.check { |
|
|
|
tasks.check { |
|
|
|