Skip to content

Commit ea76222

Browse files
committed
Make inputJar source override inputClassesDirs
It allows to use the default task setup created by BCV plugin and only configure input jar to switch to another source of classes.
1 parent 6414bee commit ea76222

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

src/main/kotlin/KotlinApiBuildTask.kt

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -62,22 +62,19 @@ open class KotlinApiBuildTask @Inject constructor(
6262
outputApiDir.mkdirs()
6363

6464
val inputClassesDirs = inputClassesDirs
65-
if (listOfNotNull(inputClassesDirs, inputJar.orNull).size != 1) {
66-
throw GradleException("KotlinApiBuildTask should have either inputClassesDirs, or inputJar properties set")
67-
}
6865
val signatures = when {
66+
// inputJar takes precedence if specified
67+
inputJar.isPresent ->
68+
JarFile(inputJar.get().asFile).use { it.loadApiFromJvmClasses() }
6969
inputClassesDirs != null ->
7070
inputClassesDirs.asFileTree.asSequence()
7171
.filter {
7272
!it.isDirectory && it.name.endsWith(".class") && !it.name.startsWith("META-INF/")
7373
}
7474
.map { it.inputStream() }
7575
.loadApiFromJvmClasses()
76-
inputJar.isPresent ->
77-
JarFile(inputJar.get().asFile)
78-
.loadApiFromJvmClasses()
7976
else ->
80-
error("Unreachable")
77+
throw GradleException("KotlinApiBuildTask should have either inputClassesDirs, or inputJar property set")
8178
}
8279

8380

0 commit comments

Comments
 (0)