com.dipien.byebyejetifier.scanner.ScannerProcessor.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of bye-bye-jetifier Show documentation
Show all versions of bye-bye-jetifier Show documentation
Gradle Plugin to verify if you can keep Android Jetifier disabled
package com.dipien.byebyejetifier.scanner
import com.dipien.byebyejetifier.archive.Archive
import com.dipien.byebyejetifier.archive.ArchiveFile
import com.dipien.byebyejetifier.archive.ArchiveItemVisitor
import com.dipien.byebyejetifier.common.LoggerHelper
class ScannerProcessor(
private val context: ScannerContext,
private val scannerList: List
) : ArchiveItemVisitor {
fun scanLibrary(archive: Archive): List {
val scanResults = mutableListOf()
archive.accept(this, scanResults)
return scanResults
}
override fun visit(archive: Archive, scanResults: MutableList) {
archive.files.forEach {
it.accept(this, scanResults)
}
}
override fun visit(archiveFile: ArchiveFile, scanResults: MutableList) {
if (context.isExcludedFileFromScanning(archiveFile)) {
LoggerHelper.debug("Excluded for scanning: ${archiveFile.relativePath}")
return
}
var fileLogged = false
scannerList.forEach {
if (it.canScan(archiveFile)) {
if (!fileLogged) {
fileLogged = true
LoggerHelper.debug("File: ${archiveFile.relativePath}")
}
scanResults.addAll(it.scan(archiveFile))
}
}
}
}