From b342c00554ff9bb445400b3763411e4576ca73c8 Mon Sep 17 00:00:00 2001 From: Jan-Niclas Struewer Date: Tue, 23 Jul 2024 17:42:37 +0200 Subject: [PATCH] added a dedicated --multi-file-mode flag to signal whether to analyze files from subdirectories or only a single file. --- .../DependencyGraphCommand.kt | 24 ++++++++++++------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/src/main/kotlin/commands/createDependencyGraph/DependencyGraphCommand.kt b/src/main/kotlin/commands/createDependencyGraph/DependencyGraphCommand.kt index 637e3aa..6f06768 100644 --- a/src/main/kotlin/commands/createDependencyGraph/DependencyGraphCommand.kt +++ b/src/main/kotlin/commands/createDependencyGraph/DependencyGraphCommand.kt @@ -1,6 +1,7 @@ package commands.createDependencyGraph import com.github.ajalt.clikt.core.CliktCommand +import com.github.ajalt.clikt.parameters.options.flag import com.github.ajalt.clikt.parameters.options.option import com.github.ajalt.clikt.parameters.options.required import com.github.ajalt.clikt.parameters.types.path @@ -33,6 +34,8 @@ class CreateDependencyGraph : CliktCommand() { .path(mustExist = false, canBeFile = false) .required() + private val multiFileMode by option().flag(default = false) + override fun run(): Unit = runBlocking { logger.info { "Running ORT on projects $projectsDir" } @@ -41,15 +44,18 @@ class CreateDependencyGraph : CliktCommand() { val dependencyGraphService = DependencyGraphService() outputPath.createDirectories() - val subDirs = Files.walk(projectsDir).toList().toMutableList() - // the first element is the base path which we can't analyze - subDirs.removeFirst() - subDirs.filter { Files.isDirectory(it) } - .map { it.toAbsolutePath().toFile() } - .forEach { subDir -> - processProject(subDir, dependencyGraphService, dependencyAnalyzer) - } - + if(multiFileMode) { + val subDirs = Files.walk(projectsDir).toList().toMutableList() + // the first element is the base path which we can't analyze + subDirs.removeFirst() + subDirs.filter { Files.isDirectory(it) } + .map { it.toAbsolutePath().toFile() } + .forEach { subDir -> + processProject(subDir, dependencyGraphService, dependencyAnalyzer) + } + } else { + processProject(projectsDir.toAbsolutePath().toFile(), dependencyGraphService, dependencyAnalyzer) + } dependencyGraphService.close() }