Skip to content

Commit

Permalink
fix(analyzer): Suffix project types with "Project"
Browse files Browse the repository at this point in the history
To avoid one root cause of duplicate project vs package IDs, add a
"Project" suffix to the `type` of project IDs.

This change does not affect IDs used in package curation or package
configurations as these really only apply to packages, not projects.

Signed-off-by: Sebastian Schuberth <[email protected]>
  • Loading branch information
sschuberth committed Nov 7, 2024
1 parent ac5aded commit 212fcad
Show file tree
Hide file tree
Showing 56 changed files with 205 additions and 195 deletions.
10 changes: 9 additions & 1 deletion analyzer/src/main/kotlin/AnalyzerResultBuilder.kt
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,15 @@ class AnalyzerResultBuilder {
* Add the given [project] to this builder. This function can be used for projects that have been obtained
* independently of a [ProjectAnalyzerResult].
*/
fun addProject(project: Project) = apply { projects += project }
fun addProject(project: Project) =
apply {
if (project.id.type.endsWith("Project")) {
projects += project
} else {
val projectId = project.id.copy(type = "${project.id.type}Project")
projects += project.copy(id = projectId)
}
}

/**
* Add the given [packageSet] to this builder. This function can be used for packages that have been obtained
Expand Down
8 changes: 4 additions & 4 deletions analyzer/src/test/kotlin/AnalyzerResultBuilderTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -73,16 +73,16 @@ class AnalyzerResultBuilderTest : WordSpec() {
private val scope2 = Scope("scope-2", setOf(pkgRef2))

private val project1 = Project.EMPTY.copy(
id = Identifier("type-1", "namespace-1", "project-1", "version-1"),
id = Identifier("Type1Project", "namespace-1", "project-1", "version-1"),
scopeDependencies = setOf(scope1),
definitionFilePath = "project1"
)
private val project2 = Project.EMPTY.copy(
id = Identifier("type-2", "namespace-2", "project-2", "version-2"),
id = Identifier("Type2Project", "namespace-2", "project-2", "version-2"),
scopeDependencies = setOf(scope1, scope2)
)
private val project3 = Project.EMPTY.copy(
id = Identifier("type-1", "namespace-3", "project-1.2", "version-1"),
id = Identifier("Type1Project", "namespace-3", "project-1.2", "version-1"),
scopeNames = setOf("scope-2"),
scopeDependencies = null
)
Expand Down Expand Up @@ -297,7 +297,7 @@ class AnalyzerResultBuilderTest : WordSpec() {
.addResult(analyzerResult2)
.build()

mergedResults.dependencyGraphs.keys should containExactlyInAnyOrder("type-1", "type-2")
mergedResults.dependencyGraphs.keys should containExactlyInAnyOrder("Type1Project", "Type2Project")
}

"apply scope excludes" {
Expand Down
2 changes: 1 addition & 1 deletion cli/src/funTest/assets/semver4j-ort-result.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ analyzer:
allow_dynamic_versions: false
result:
projects:
- id: "Maven:com.vdurmont:semver4j:3.1.0"
- id: "MavenProject:com.vdurmont:semver4j:3.1.0"
definition_file_path: "pom.xml"
declared_licenses:
- "The MIT License"
Expand Down
2 changes: 1 addition & 1 deletion cli/src/funTest/kotlin/OrtMainFunTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ class OrtMainFunTest : StringSpec() {

ortResult.analyzer shouldNotBeNull {
result.projects should haveSize(1)
result.projects.single().id.type shouldBe "Unmanaged"
result.projects.single().id.type shouldBe "UnmanagedProject"
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ analyzer:
skip_excluded: false
result:
projects:
- id: "Unmanaged::Example project name:"
- id: "UnmanagedProject::Example project name:"
definition_file_path: ""
declared_licenses: []
declared_licenses_processed: {}
Expand Down
3 changes: 2 additions & 1 deletion model/src/main/kotlin/DependencyGraphNavigator.kt
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ class DependencyGraphNavigator(
override fun directDependencies(project: Project, scopeName: String): Sequence<DependencyNode> {
// TODO: Relax this assumption that package manager names start with the name of the type of project
// they manage, for example that "GradleInspector" manages "Gradle" projects.
val managers = graphs.keys.filter { it.startsWith(project.id.type) }
val projectType = project.id.type.removeSuffix("Project")
val managers = graphs.keys.filter { it.startsWith(projectType) }

val manager = requireNotNull(managers.singleOrNull()) {
"All of the $managers managers are able to manage '${project.id.type}' projects. Please enable only one " +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ analyzer:
allow_dynamic_versions: false
result:
projects:
- id: "Maven:com.vdurmont:semver4j:3.1.0"
- id: "MavenProject:com.vdurmont:semver4j:3.1.0"
definition_file_path: "pom.xml"
authors:
- "Vincent DURMONT"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ analyzer:
- "Gradle"
result:
projects:
- id: "Gradle::Gradle-Example:"
- id: "GradleProject::Gradle-Example:"
definition_file_path: "analyzer/src/funTest/assets/projects/synthetic/gradle/build.gradle"
declared_licenses: []
declared_licenses_processed: {}
Expand All @@ -68,7 +68,7 @@ analyzer:
path: "analyzer/src/funTest/assets/projects/synthetic/gradle"
homepage_url: ""
scopes: []
- id: "Gradle:org.ossreviewtoolkit.gradle.example:app:1.0.0"
- id: "GradleProject:org.ossreviewtoolkit.gradle.example:app:1.0.0"
definition_file_path: "analyzer/src/funTest/assets/projects/synthetic/gradle/app/build.gradle"
declared_licenses: []
declared_licenses_processed: {}
Expand All @@ -86,11 +86,11 @@ analyzer:
scopes:
- name: "compileClasspath"
dependencies:
- id: "Gradle:org.ossreviewtoolkit.gradle.example:lib:1.0.0"
- id: "GradleProject:org.ossreviewtoolkit.gradle.example:lib:1.0.0"
linkage: "PROJECT_DYNAMIC"
- name: "runtimeClasspath"
dependencies:
- id: "Gradle:org.ossreviewtoolkit.gradle.example:lib:1.0.0"
- id: "GradleProject:org.ossreviewtoolkit.gradle.example:lib:1.0.0"
linkage: "PROJECT_DYNAMIC"
dependencies:
- id: "Maven:org.apache.commons:commons-text:1.1"
Expand All @@ -99,18 +99,18 @@ analyzer:
- id: "Maven:org.apache.struts:struts2-assembly:2.5.14.1"
- name: "testCompileClasspath"
dependencies:
- id: "Gradle:org.ossreviewtoolkit.gradle.example:lib:1.0.0"
- id: "GradleProject:org.ossreviewtoolkit.gradle.example:lib:1.0.0"
linkage: "PROJECT_DYNAMIC"
- name: "testRuntimeClasspath"
dependencies:
- id: "Gradle:org.ossreviewtoolkit.gradle.example:lib:1.0.0"
- id: "GradleProject:org.ossreviewtoolkit.gradle.example:lib:1.0.0"
linkage: "PROJECT_DYNAMIC"
dependencies:
- id: "Maven:org.apache.commons:commons-text:1.1"
dependencies:
- id: "Maven:org.apache.commons:commons-lang3:3.5"
- id: "Maven:org.apache.struts:struts2-assembly:2.5.14.1"
- id: "Gradle:org.ossreviewtoolkit.gradle.example:lib:1.0.0"
- id: "GradleProject:org.ossreviewtoolkit.gradle.example:lib:1.0.0"
definition_file_path: "analyzer/src/funTest/assets/projects/synthetic/gradle/lib/build.gradle"
declared_licenses: []
declared_licenses_processed: {}
Expand Down Expand Up @@ -156,7 +156,7 @@ analyzer:
dependencies:
- id: "Maven:org.apache.commons:commons-lang3:3.5"
- id: "Maven:org.apache.struts:struts2-assembly:2.5.14.1"
- id: "Gradle:org.ossreviewtoolkit.gradle.example:lib-without-repo:1.0.0"
- id: "GradleProject:org.ossreviewtoolkit.gradle.example:lib-without-repo:1.0.0"
definition_file_path: "analyzer/src/funTest/assets/projects/synthetic/gradle/lib-without-repo/build.gradle"
declared_licenses: []
declared_licenses_processed: {}
Expand Down
2 changes: 1 addition & 1 deletion model/src/test/assets/maven-expected-output-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ project:
scopes:
- name: "compile"
dependencies:
- id: "Maven:org.ossreviewtoolkit.maven:maven-lib:1.0-SNAPSHOT"
- id: "MavenProject:org.ossreviewtoolkit.maven:maven-lib:1.0-SNAPSHOT"
linkage: "PROJECT_DYNAMIC"
dependencies:
- id: "Maven:org.apache.beam:beam-parent:2.3.0"
Expand Down
10 changes: 5 additions & 5 deletions model/src/test/assets/result-with-issues-graph-old.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ analyzer:
allow_dynamic_versions: false
result:
projects:
- id: "SBT:com.pbassiner:common_2.12:0.1-SNAPSHOT"
- id: "SBTProject:com.pbassiner:common_2.12:0.1-SNAPSHOT"
definition_file_path: "common/target-scala-2.12-common_2.12-0.1-SNAPSHOT.pom"
authors:
- "com.pbassiner"
Expand All @@ -47,7 +47,7 @@ analyzer:
scope_names:
- "compile"
- "test"
- id: "SBT:com.pbassiner:multi1_2.12:0.1-SNAPSHOT"
- id: "SBTProject:com.pbassiner:multi1_2.12:0.1-SNAPSHOT"
definition_file_path: "multi1/target-scala-2.12-multi1_2.12-0.1-SNAPSHOT.pom"
authors:
- "com.pbassiner"
Expand All @@ -67,7 +67,7 @@ analyzer:
scope_names:
- "compile"
- "test"
- id: "SBT:com.pbassiner:multi2_2.12:0.1-SNAPSHOT"
- id: "SBTProject:com.pbassiner:multi2_2.12:0.1-SNAPSHOT"
definition_file_path: "multi2/target-scala-2.12-multi2_2.12-0.1-SNAPSHOT.pom"
authors:
- "com.pbassiner"
Expand All @@ -87,7 +87,7 @@ analyzer:
scope_names:
- "compile"
- "test"
- id: "SBT:com.pbassiner:sbt-multi-project-example_2.12:0.1-SNAPSHOT"
- id: "SBTProject:com.pbassiner:sbt-multi-project-example_2.12:0.1-SNAPSHOT"
definition_file_path: "target-scala-2.12-sbt-multi-project-example_2.12-0.1-SNAPSHOT.pom"
authors:
- "com.pbassiner"
Expand Down Expand Up @@ -1205,7 +1205,7 @@ analyzer:
- "Maven:org.scalaz:scalaz-core_2.12:7.2.8"
- "Maven:com.github.julien-truffaut:monocle-macro_2.12:1.4.0"
- "Maven:org.typelevel:macro-compat_2.12:1.1.1"
- "SBT:com.pbassiner:common_2.12:0.1-SNAPSHOT"
- "SBTProject:com.pbassiner:common_2.12:0.1-SNAPSHOT"
- "Maven:com.github.pureconfig:pureconfig_2.12:0.8.0"
- "Maven:com.chuusai:shapeless_2.12:2.3.2"
- "Maven:com.github.pureconfig:pureconfig-macros_2.12:0.8.0"
Expand Down
10 changes: 5 additions & 5 deletions model/src/test/assets/result-with-issues-graph.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ analyzer:
allow_dynamic_versions: false
result:
projects:
- id: "SBT:com.pbassiner:common_2.12:0.1-SNAPSHOT"
- id: "SBTProject:com.pbassiner:common_2.12:0.1-SNAPSHOT"
definition_file_path: "common/target-scala-2.12-common_2.12-0.1-SNAPSHOT.pom"
authors:
- "com.pbassiner"
Expand All @@ -47,7 +47,7 @@ analyzer:
scope_names:
- "compile"
- "test"
- id: "SBT:com.pbassiner:multi1_2.12:0.1-SNAPSHOT"
- id: "SBTProject:com.pbassiner:multi1_2.12:0.1-SNAPSHOT"
definition_file_path: "multi1/target-scala-2.12-multi1_2.12-0.1-SNAPSHOT.pom"
authors:
- "com.pbassiner"
Expand All @@ -67,7 +67,7 @@ analyzer:
scope_names:
- "compile"
- "test"
- id: "SBT:com.pbassiner:multi2_2.12:0.1-SNAPSHOT"
- id: "SBTProject:com.pbassiner:multi2_2.12:0.1-SNAPSHOT"
definition_file_path: "multi2/target-scala-2.12-multi2_2.12-0.1-SNAPSHOT.pom"
authors:
- "com.pbassiner"
Expand All @@ -87,7 +87,7 @@ analyzer:
scope_names:
- "compile"
- "test"
- id: "SBT:com.pbassiner:sbt-multi-project-example_2.12:0.1-SNAPSHOT"
- id: "SBTProject:com.pbassiner:sbt-multi-project-example_2.12:0.1-SNAPSHOT"
definition_file_path: "target-scala-2.12-sbt-multi-project-example_2.12-0.1-SNAPSHOT.pom"
authors:
- "com.pbassiner"
Expand Down Expand Up @@ -1205,7 +1205,7 @@ analyzer:
- "Maven:org.scalaz:scalaz-core_2.12:7.2.8"
- "Maven:com.github.julien-truffaut:monocle-macro_2.12:1.4.0"
- "Maven:org.typelevel:macro-compat_2.12:1.1.1"
- "SBT:com.pbassiner:common_2.12:0.1-SNAPSHOT"
- "SBTProject:com.pbassiner:common_2.12:0.1-SNAPSHOT"
- "Maven:com.github.pureconfig:pureconfig_2.12:0.8.0"
- "Maven:com.chuusai:shapeless_2.12:2.3.2"
- "Maven:com.github.pureconfig:pureconfig-macros_2.12:0.8.0"
Expand Down
12 changes: 6 additions & 6 deletions model/src/test/assets/result-with-issues-scopes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ analyzer:
allow_dynamic_versions: false
result:
projects:
- id: "SBT:com.pbassiner:common_2.12:0.1-SNAPSHOT"
- id: "SBTProject:com.pbassiner:common_2.12:0.1-SNAPSHOT"
definition_file_path: "common/target-scala-2.12-common_2.12-0.1-SNAPSHOT.pom"
authors:
- "com.pbassiner"
Expand Down Expand Up @@ -90,7 +90,7 @@ analyzer:
source: "Gradle"
message: "Test issue 2"
severity: "ERROR"
- id: "SBT:com.pbassiner:multi1_2.12:0.1-SNAPSHOT"
- id: "SBTProject:com.pbassiner:multi1_2.12:0.1-SNAPSHOT"
definition_file_path: "multi1/target-scala-2.12-multi1_2.12-0.1-SNAPSHOT.pom"
authors:
- "com.pbassiner"
Expand Down Expand Up @@ -139,7 +139,7 @@ analyzer:
- id: "Maven:com.fasterxml.jackson.core:jackson-core:2.8.9"
- id: "Maven:org.scala-lang:scala-library:2.12.3"
- id: "Maven:org.slf4j:jcl-over-slf4j:1.7.25"
- id: "SBT:com.pbassiner:common_2.12:0.1-SNAPSHOT"
- id: "SBTProject:com.pbassiner:common_2.12:0.1-SNAPSHOT"
linkage: "PROJECT_DYNAMIC"
- name: "test"
dependencies:
Expand All @@ -151,7 +151,7 @@ analyzer:
- id: "Maven:org.scala-lang.modules:scala-parser-combinators_2.12:1.0.4"
- id: "Maven:org.scala-lang.modules:scala-xml_2.12:1.0.5"
- id: "Maven:org.scalactic:scalactic_2.12:3.0.4"
- id: "SBT:com.pbassiner:multi2_2.12:0.1-SNAPSHOT"
- id: "SBTProject:com.pbassiner:multi2_2.12:0.1-SNAPSHOT"
definition_file_path: "multi2/target-scala-2.12-multi2_2.12-0.1-SNAPSHOT.pom"
authors:
- "com.pbassiner"
Expand Down Expand Up @@ -201,7 +201,7 @@ analyzer:
- id: "Maven:com.fasterxml.jackson.core:jackson-core:2.8.9"
- id: "Maven:org.scala-lang:scala-library:2.12.3"
- id: "Maven:org.slf4j:jcl-over-slf4j:1.7.25"
- id: "SBT:com.pbassiner:common_2.12:0.1-SNAPSHOT"
- id: "SBTProject:com.pbassiner:common_2.12:0.1-SNAPSHOT"
linkage: "PROJECT_DYNAMIC"
- name: "test"
dependencies:
Expand All @@ -213,7 +213,7 @@ analyzer:
- id: "Maven:org.scala-lang.modules:scala-parser-combinators_2.12:1.0.4"
- id: "Maven:org.scala-lang.modules:scala-xml_2.12:1.0.5"
- id: "Maven:org.scalactic:scalactic_2.12:3.0.4"
- id: "SBT:com.pbassiner:sbt-multi-project-example_2.12:0.1-SNAPSHOT"
- id: "SBTProject:com.pbassiner:sbt-multi-project-example_2.12:0.1-SNAPSHOT"
definition_file_path: "target-scala-2.12-sbt-multi-project-example_2.12-0.1-SNAPSHOT.pom"
authors:
- "com.pbassiner"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ analyzer:
skip_excluded: false
result:
projects:
- id: "SBT:com.pbassiner:common_2.12:0.1.0-SNAPSHOT"
- id: "SBTProject:com.pbassiner:common_2.12:0.1.0-SNAPSHOT"
definition_file_path: "common/target-scala-2.12-common_2.12-0.1.0-SNAPSHOT.pom"
authors:
- "com.pbassiner"
Expand Down Expand Up @@ -81,7 +81,7 @@ analyzer:
- id: "Maven:org.scala-lang.modules:scala-parser-combinators_2.12:1.0.4"
- id: "Maven:org.scala-lang.modules:scala-xml_2.12:1.0.5"
- id: "Maven:org.scalactic:scalactic_2.12:3.0.4"
- id: "SBT:com.pbassiner:multi1_2.12:0.1.0-SNAPSHOT"
- id: "SBTProject:com.pbassiner:multi1_2.12:0.1.0-SNAPSHOT"
definition_file_path: "multi1/target-scala-2.12-multi1_2.12-0.1.0-SNAPSHOT.pom"
authors:
- "com.pbassiner"
Expand Down Expand Up @@ -130,7 +130,7 @@ analyzer:
- id: "Maven:com.fasterxml.jackson.core:jackson-core:2.8.9"
- id: "Maven:org.scala-lang:scala-library:2.12.15"
- id: "Maven:org.slf4j:jcl-over-slf4j:1.7.25"
- id: "SBT:com.pbassiner:common_2.12:0.1.0-SNAPSHOT"
- id: "SBTProject:com.pbassiner:common_2.12:0.1.0-SNAPSHOT"
linkage: "PROJECT_DYNAMIC"
- name: "test"
dependencies:
Expand All @@ -142,7 +142,7 @@ analyzer:
- id: "Maven:org.scala-lang.modules:scala-parser-combinators_2.12:1.0.4"
- id: "Maven:org.scala-lang.modules:scala-xml_2.12:1.0.5"
- id: "Maven:org.scalactic:scalactic_2.12:3.0.4"
- id: "SBT:com.pbassiner:multi2_2.12:0.1.0-SNAPSHOT"
- id: "SBTProject:com.pbassiner:multi2_2.12:0.1.0-SNAPSHOT"
definition_file_path: "multi2/target-scala-2.12-multi2_2.12-0.1.0-SNAPSHOT.pom"
authors:
- "com.pbassiner"
Expand Down Expand Up @@ -192,7 +192,7 @@ analyzer:
- id: "Maven:com.fasterxml.jackson.core:jackson-core:2.8.9"
- id: "Maven:org.scala-lang:scala-library:2.12.15"
- id: "Maven:org.slf4j:jcl-over-slf4j:1.7.25"
- id: "SBT:com.pbassiner:common_2.12:0.1.0-SNAPSHOT"
- id: "SBTProject:com.pbassiner:common_2.12:0.1.0-SNAPSHOT"
linkage: "PROJECT_DYNAMIC"
- name: "test"
dependencies:
Expand All @@ -204,7 +204,7 @@ analyzer:
- id: "Maven:org.scala-lang.modules:scala-parser-combinators_2.12:1.0.4"
- id: "Maven:org.scala-lang.modules:scala-xml_2.12:1.0.5"
- id: "Maven:org.scalactic:scalactic_2.12:3.0.4"
- id: "SBT:com.pbassiner:sbt-multi-project-example_2.12:0.1.0-SNAPSHOT"
- id: "SBTProject:com.pbassiner:sbt-multi-project-example_2.12:0.1.0-SNAPSHOT"
definition_file_path: "target-scala-2.12-sbt-multi-project-example_2.12-0.1.0-SNAPSHOT.pom"
authors:
- "com.pbassiner"
Expand Down
Loading

0 comments on commit 212fcad

Please sign in to comment.