All Downloads are FREE. Search and download functionalities are using the official Maven repository.

main.kotlin.org.virtuslab.bazelsteward.app.LibraryToTextFilesMapper.kt Maven / Gradle / Ivy

Go to download

Bazel Steward is a bot that helps you keep your library dependencies, Bazel and Bazel rules up-to-date.

There is a newer version: 1.5.2
Show newest version
package org.virtuslab.bazelsteward.app

import org.virtuslab.bazelsteward.app.provider.SearchPatternProvider
import org.virtuslab.bazelsteward.core.FileFinder
import org.virtuslab.bazelsteward.core.PathPattern
import org.virtuslab.bazelsteward.core.common.TextFile
import org.virtuslab.bazelsteward.core.library.Library

class LibraryToTextFilesMapper(
  private val searchPatternProvider: SearchPatternProvider,
  private val fileFinder: FileFinder,
) {

  private val cache: MutableMap, List> = mutableMapOf()

  fun map(currentLibrary: Library): List {
    return searchPatternProvider.resolveForLibrary(currentLibrary).let {
      val pathPatternsSet = it.toSet()
      cache[pathPatternsSet]
        ?: fileFinder.find(it).also { fileList ->
          cache[pathPatternsSet] = fileList
        }
    }
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy