Skip to content

Commit 1826194

Browse files
committed
Make PublicApiTest more robust when looking for .jar file
* It was not working after `gradlew publishToMavenLocal` due to extra jar files in the build/libs
1 parent c20bc93 commit 1826194

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

binary-compatibility-validator/test/PublicApiTest.kt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,16 @@ class PublicApiTest(
5555

5656
private fun getJarPath(libsDir: File): File {
5757
val regex = Regex("$moduleName-.+\\.jar")
58-
val files = (libsDir.listFiles() ?: throw Exception("Cannot list files in $libsDir"))
58+
var files = (libsDir.listFiles() ?: throw Exception("Cannot list files in $libsDir"))
5959
.filter { it.name.let {
6060
it matches regex
6161
&& !it.endsWith("-sources.jar")
6262
&& !it.endsWith("-javadoc.jar")
6363
&& !it.endsWith("-tests.jar")}
6464
&& !it.name.contains("-metadata-")}
65-
return files.singleOrNull() ?: throw Exception("No single file matching $regex in $libsDir:\n${files.joinToString("\n")}")
65+
if (files.size > 1) // maybe multiplatform?
66+
files = files.filter { it.name.startsWith("$moduleName-jvm-") }
67+
return files.singleOrNull() ?:
68+
error("No single file matching $regex in $libsDir:\n${files.joinToString("\n")}")
6669
}
6770
}

0 commit comments

Comments
 (0)