Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ import FileUtil.*
import org.slf4j.LoggerFactory

import java.nio.file.{Files, Path}
import scala.collection.mutable
import scala.util.{Failure, Success}
import scala.jdk.CollectionConverters.*

enum GradleConfigKeys {
case ProjectName, ConfigurationName
Expand Down Expand Up @@ -106,7 +108,27 @@ object DependencyResolver {
file.toString.endsWith("pom.xml")
}

private def findSupportedBuildFiles(currentDir: Path, depth: Int = 0): List[Path] = {
private def findSupportedBuildFiles(dir: Path, maxDepth: Int = MaxSearchDepth): List[Path] = {
val buildFiles = Files.walk(dir, maxDepth).iterator.asScala.filter { file =>
(!Files.isDirectory(file)) && (isGradleBuildFile(file) || isMavenBuildFile(file))
}.toList

if (buildFiles.isEmpty) {
logger.info("findSupportedBuildFiles reached max depth before finding build files")
}

val old = findSupportedBuildFilesOld(dir)

if (old.sorted != buildFiles.sorted) {
throw new RuntimeException(s"Unequal results: old $old\nnew $buildFiles")
}

logger.info(s"Found $buildFiles")

buildFiles.toList
}

private def findSupportedBuildFilesOld(currentDir: Path, depth: Int = 0): List[Path] = {
if (depth >= MaxSearchDepth) {
logger.info("findSupportedBuildFiles reached max depth before finding build files")
Nil
Expand Down
Loading