Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,5 @@ dependencies {
implementation(projects.utils.ortUtils)

implementation(libs.kotlinx.serialization.json)
implementation(libs.semver4j)
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ import org.ossreviewtoolkit.utils.common.withoutSuffix
import org.ossreviewtoolkit.utils.ort.downloadText
import org.ossreviewtoolkit.utils.ort.okHttpClient

import org.semver4j.Semver

internal fun getGitHubTree(owner: String, repo: String, revision: String): List<String> {
val json = okHttpClient
.downloadText("https://api.github.com/repos/$owner/$repo/git/trees/$revision?recursive=1")
Expand All @@ -39,7 +41,10 @@ internal fun getGitHubTree(owner: String, repo: String, revision: String): List<
}

internal fun getSpringProjectPaths(projectName: String, projectVersion: String): Map<String, String> {
val paths = getGitHubTree("spring-projects", projectName, "v$projectVersion")
// Use a simple way to get the first valid version out of a range.
val coercedVersion = Semver.coerce(projectVersion)

val paths = getGitHubTree("spring-projects", projectName, "v$coercedVersion")

val projectPaths = paths.mapNotNull { path ->
path.withoutSuffix("/build.gradle")?.takeIf { it.startsWith(projectName) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class SpringPackageCurationProviderTest : StringSpec({
)
}

"Get the correct paths for Spring Boot projects" {
"Get the correct VCS path for spring-boot-antlib with a fixed version" {
val id = Identifier("Maven:org.springframework.boot:spring-boot-antlib:3.5.4")
val pkg = Package.EMPTY.copy(
id = id,
Expand All @@ -60,4 +60,21 @@ class SpringPackageCurationProviderTest : StringSpec({
)
)
}

"Get the correct VCS path for spring-boot-test-autoconfigure with a version range" {
val id = Identifier("Maven:org.springframework.boot:spring-boot-test-autoconfigure:[3.3.0,)")
val pkg = Package.EMPTY.copy(
id = id,
vcsProcessed = VcsInfo.EMPTY.copy(url = "https://github.com/spring-projects/spring-boot.git")
)

provider.getCurationsFor(setOf(pkg)) shouldContainExactly setOf(
PackageCuration(
id = id,
data = PackageCurationData(
vcs = VcsInfoCurationData(path = "spring-boot-project/spring-boot-test-autoconfigure")
)
)
)
}
})
Loading