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 6, 2022
1 parent 658faf4 commit c21db93
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions src/main/kotlin/KotlinApiBuildTask.kt
Expand Up @@ -62,22 +62,20 @@ 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)
.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 c21db93

Please sign in to comment.