File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -267,6 +267,10 @@ data class OrtResult(
267267 * analyzer root is the input directory of the analyzer.
268268 */
269269 fun getFilePathRelativeToAnalyzerRoot (project : Project , path : String ): String {
270+ if (project.id.type.startsWith(" SPDX" , ignoreCase = true ) && project.vcsProcessed == VcsInfo .EMPTY ) {
271+ return project.definitionFilePath
272+ }
273+
270274 val vcsPath = relativeProjectVcsPath.getValue(project.id)
271275
272276 requireNotNull(vcsPath) {
Original file line number Diff line number Diff line change @@ -202,6 +202,23 @@ class OrtResultTest : WordSpec({
202202 ortResult.getDefinitionFilePathRelativeToAnalyzerRoot(project3) shouldBe " path/2/project3/build.gradle"
203203 }
204204
205+ " return the path to the definition file if an SPDX project has no VCS information" {
206+ val project = Project .EMPTY .copy(
207+ id = Identifier (" SPDX::core-image-minimal-qemux86-64.rootfs-20260321090222" ),
208+ definitionFilePath = " project/spdx.json"
209+ )
210+ val ortResult = OrtResult (
211+ Repository (
212+ vcs = VcsInfo (type = VcsType .GIT , url = " https://example.com/git" , revision = " " )
213+ ),
214+ AnalyzerRun .EMPTY .copy(
215+ result = AnalyzerResult .EMPTY .copy(projects = setOf (project))
216+ )
217+ )
218+
219+ ortResult.getDefinitionFilePathRelativeToAnalyzerRoot(project) shouldBe " project/spdx.json"
220+ }
221+
205222 " fail if no repository matches" {
206223 val vcs = VcsInfo (type = VcsType .GIT , url = " https://example.com/git" , revision = " " )
207224 val nestedVcs1 = VcsInfo (type = VcsType .GIT , url = " https://example.com/git1" , revision = " " )
You can’t perform that action at this time.
0 commit comments