com.likethesalad.stem.locator.entrypoints.common.utils.TemplatesProviderJarsFinder.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of stem-plugin Show documentation
Show all versions of stem-plugin Show documentation
This is a Gradle plugin for Android applications which resolves XML string references in other XML strings.
package com.likethesalad.stem.locator.entrypoints.common.utils
import com.likethesalad.android.templates.common.utils.CommonConstants.PROVIDER_PACKAGE_NAME
import com.likethesalad.android.templates.provider.api.TemplatesProvider
import io.github.classgraph.ClassGraph
import io.github.classgraph.ScanResult
import org.gradle.api.file.FileCollection
import java.io.File
class TemplatesProviderJarsFinder(val allJarFiles: FileCollection) {
val templateProviderJars: List by lazy {
findTemplateProviderJars(allJarFiles.files)
}
private fun findTemplateProviderJars(allJars: Set): List {
val scanResult = scanJars(allJars) ?: return emptyList()
return scanResult.use {
scanResult.getClassesImplementing(TemplatesProvider::class.java.name).map { info ->
info.classpathElementFile
}
}
}
private fun scanJars(jarFiles: Set): ScanResult? {
if (jarFiles.isEmpty()) {
return null
}
return ClassGraph()
.acceptPackages(PROVIDER_PACKAGE_NAME)
.overrideClasspath(jarFiles)
.scan()
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy