Skip to content

Commit bca9510

Browse files
committed
feat(analyzer)!: Pass the configuration also to mapDefinitionFiles()
This will be required by an upcoming fix. Signed-off-by: Sebastian Schuberth <[email protected]>
1 parent 65c7148 commit bca9510

File tree

17 files changed

+72
-20
lines changed

17 files changed

+72
-20
lines changed

analyzer/src/main/kotlin/Analyzer.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ class Analyzer(private val config: AnalyzerConfiguration, private val labels: Ma
9999
config.excludes(repositoryConfiguration)
100100
)
101101
}.mapNotNull { (manager, files) ->
102-
val mappedFiles = manager.mapDefinitionFiles(absoluteProjectPath, files)
102+
val mappedFiles = manager.mapDefinitionFiles(absoluteProjectPath, files, config)
103103
Pair(manager, mappedFiles).takeIf { mappedFiles.isNotEmpty() }
104104
}.toMap(mutableMapOf())
105105

analyzer/src/main/kotlin/PackageManager.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,11 @@ abstract class PackageManager(val projectType: String) : Plugin {
230230
/**
231231
* Optional mapping of found [definitionFiles] before dependency resolution.
232232
*/
233-
open fun mapDefinitionFiles(analysisRoot: File, definitionFiles: List<File>): List<File> = definitionFiles
233+
open fun mapDefinitionFiles(
234+
analysisRoot: File,
235+
definitionFiles: List<File>,
236+
analyzerConfig: AnalyzerConfiguration
237+
): List<File> = definitionFiles
234238

235239
/**
236240
* Return if this package manager must run before or after certain other package managers. This can manually be

plugins/package-managers/bazel/src/main/kotlin/Bazel.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,11 @@ class Bazel(
155155
* source.json file and under a directory with a metadata.json file. This simple metric avoids parsing the .bazelrc
156156
* in the top directory of the project to find out if a MODULE.bazel file is part of a local registry or not.
157157
*/
158-
override fun mapDefinitionFiles(analysisRoot: File, definitionFiles: List<File>): List<File> =
158+
override fun mapDefinitionFiles(
159+
analysisRoot: File,
160+
definitionFiles: List<File>,
161+
analyzerConfig: AnalyzerConfiguration
162+
): List<File> =
159163
definitionFiles.mapNotNull { file ->
160164
file.takeUnless {
161165
it.resolveSibling(SOURCE_JSON).isFile && it.parentFile.resolveSibling(METADATA_JSON).isFile

plugins/package-managers/cargo/src/main/kotlin/Cargo.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,11 @@ class Cargo(override val descriptor: PluginDescriptor = CargoFactory.descriptor)
123123
}
124124
}
125125

126-
override fun mapDefinitionFiles(analysisRoot: File, definitionFiles: List<File>): List<File> {
126+
override fun mapDefinitionFiles(
127+
analysisRoot: File,
128+
definitionFiles: List<File>,
129+
analyzerConfig: AnalyzerConfiguration
130+
): List<File> {
127131
fun File.isVirtualWorkspace(): Boolean {
128132
var foundWorkspace = false
129133
var foundPackage = false

plugins/package-managers/composer/src/funTest/kotlin/ComposerFunTest.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import java.io.File
3131

3232
import org.ossreviewtoolkit.analyzer.resolveSingleProject
3333
import org.ossreviewtoolkit.model.Identifier
34+
import org.ossreviewtoolkit.model.config.AnalyzerConfiguration
3435
import org.ossreviewtoolkit.model.toYaml
3536
import org.ossreviewtoolkit.utils.test.getAssetFile
3637
import org.ossreviewtoolkit.utils.test.matchExpectedResult
@@ -44,7 +45,8 @@ class ComposerFunTest : StringSpec({
4445
"projectA/vendor/dependency1/composer.json",
4546
"projectB/composer.json",
4647
"projectB/vendor/dependency2/composer.json"
47-
).map { File(it) }
48+
).map { File(it) },
49+
AnalyzerConfiguration()
4850
)
4951

5052
projectFiles.map { it.path } should containExactly(

plugins/package-managers/composer/src/main/kotlin/Composer.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,11 @@ class Composer(override val descriptor: PluginDescriptor = ComposerFactory.descr
107107
ComposerCommand.checkVersion()
108108
}
109109

110-
override fun mapDefinitionFiles(analysisRoot: File, definitionFiles: List<File>): List<File> {
110+
override fun mapDefinitionFiles(
111+
analysisRoot: File,
112+
definitionFiles: List<File>,
113+
analyzerConfig: AnalyzerConfiguration
114+
): List<File> {
111115
val projectFiles = definitionFiles.toMutableList()
112116

113117
// Ignore definition files from vendor directories that reside next to other definition files, to avoid the

plugins/package-managers/conan/src/main/kotlin/Conan.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,11 @@ class Conan(
154154
* If a Bazel project uses some Conan packages, the corresponding Conan files should not be picked up by the Conan
155155
* package manager. Therefore, the Conan file is checked to NOT contain the BazelDeps and BazelToolchain generators.
156156
*/
157-
override fun mapDefinitionFiles(analysisRoot: File, definitionFiles: List<File>): List<File> =
157+
override fun mapDefinitionFiles(
158+
analysisRoot: File,
159+
definitionFiles: List<File>,
160+
analyzerConfig: AnalyzerConfiguration
161+
): List<File> =
158162
definitionFiles.mapNotNull { file ->
159163
file.takeUnless {
160164
val content = it.readText()

plugins/package-managers/go/src/main/kotlin/GoMod.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,11 @@ internal object GoCommand : CommandLineTool {
9595
class GoMod(override val descriptor: PluginDescriptor = GoModFactory.descriptor) : PackageManager("GoMod") {
9696
override val globsForDefinitionFiles = listOf("go.mod")
9797

98-
override fun mapDefinitionFiles(analysisRoot: File, definitionFiles: List<File>): List<File> =
98+
override fun mapDefinitionFiles(
99+
analysisRoot: File,
100+
definitionFiles: List<File>,
101+
analyzerConfig: AnalyzerConfiguration
102+
): List<File> =
99103
definitionFiles.filterNot { definitionFile ->
100104
"vendor" in definitionFile
101105
.parentFile

plugins/package-managers/maven/src/main/kotlin/Maven.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,11 @@ class Maven(override val descriptor: PluginDescriptor = MavenFactory.descriptor,
8686
* Map the given [definitionFiles] to a list of files that should be processed. This implementation filters out
8787
* projects that require the Tycho build extension.
8888
*/
89-
override fun mapDefinitionFiles(analysisRoot: File, definitionFiles: List<File>): List<File> {
89+
override fun mapDefinitionFiles(
90+
analysisRoot: File,
91+
definitionFiles: List<File>,
92+
analyzerConfig: AnalyzerConfiguration
93+
): List<File> {
9094
val tychoRoots = definitionFiles.filter(::isTychoProject).map { it.parentFile }
9195

9296
// All pom files under a Tycho project will be handled by Tycho and therefore need to be excluded.

plugins/package-managers/maven/src/main/kotlin/tycho/Tycho.kt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,11 @@ class Tycho(override val descriptor: PluginDescriptor = TychoFactory.Companion.d
100100
*/
101101
private lateinit var graphBuilder: DependencyGraphBuilder<DependencyNode>
102102

103-
override fun mapDefinitionFiles(analysisRoot: File, definitionFiles: List<File>): List<File> =
104-
definitionFiles.filter(::isTychoProject)
103+
override fun mapDefinitionFiles(
104+
analysisRoot: File,
105+
definitionFiles: List<File>,
106+
analyzerConfig: AnalyzerConfiguration
107+
): List<File> = definitionFiles.filter(::isTychoProject)
105108

106109
override fun resolveDependencies(
107110
analysisRoot: File,

0 commit comments

Comments
 (0)