Skip to content

Commit

Permalink
Make inputJar source override inputClassesDirs
Browse files Browse the repository at this point in the history
It allows to use the default task setup created by BCV plugin and only configure
input jar to switch to another source of classes.
  • Loading branch information
ilya-g committed Oct 20, 2022
1 parent 6414bee commit ea76222
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions src/main/kotlin/KotlinApiBuildTask.kt
Original file line number Diff line number Diff line change
Expand Up @@ -62,22 +62,19 @@ open class KotlinApiBuildTask @Inject constructor(
outputApiDir.mkdirs()

val inputClassesDirs = inputClassesDirs
if (listOfNotNull(inputClassesDirs, inputJar.orNull).size != 1) {
throw GradleException("KotlinApiBuildTask should have either inputClassesDirs, or inputJar properties set")
}
val signatures = when {
// inputJar takes precedence if specified
inputJar.isPresent ->
JarFile(inputJar.get().asFile).use { it.loadApiFromJvmClasses() }
inputClassesDirs != null ->
inputClassesDirs.asFileTree.asSequence()
.filter {
!it.isDirectory && it.name.endsWith(".class") && !it.name.startsWith("META-INF/")
}
.map { it.inputStream() }
.loadApiFromJvmClasses()
inputJar.isPresent ->
JarFile(inputJar.get().asFile)
.loadApiFromJvmClasses()
else ->
error("Unreachable")
throw GradleException("KotlinApiBuildTask should have either inputClassesDirs, or inputJar property set")
}


Expand Down

0 comments on commit ea76222

Please sign in to comment.