Skip to content

Commit

Permalink
added a dedicated --multi-file-mode flag to signal whether to analyze…
Browse files Browse the repository at this point in the history
… files from subdirectories or only a single file.
  • Loading branch information
janniclas committed Jul 23, 2024
1 parent 73462a2 commit b342c00
Showing 1 changed file with 15 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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" }
Expand All @@ -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()
}

Expand Down

0 comments on commit b342c00

Please sign in to comment.