Skip to content

Commit a15728a

Browse files
committed
feat(model): Support Ivy's "Sub Revision Matcher" syntax
See [1]. This is not covered by the Semver4j library because that matcher does not necessarily cover a strict range of versions. [1]: https://ant.apache.org/ivy/history/2.1.0/settings/version-matchers.html Signed-off-by: Sebastian Schuberth <sebastian@doubleopen.org>
1 parent ccd89ae commit a15728a

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

model/src/main/kotlin/utils/VersionUtils.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ package org.ossreviewtoolkit.model.utils
2222
import org.apache.logging.log4j.kotlin.logger
2323

2424
import org.ossreviewtoolkit.model.Identifier
25+
import org.ossreviewtoolkit.utils.common.withoutSuffix
2526
import org.ossreviewtoolkit.utils.ort.showStackTrace
2627

2728
import org.semver4j.Semver
@@ -40,8 +41,12 @@ fun Identifier.hasIvyVersionRange(): Boolean = version.getIvyVersionRanges().get
4041
*/
4142
internal fun Identifier.isApplicableIvyVersion(pkgId: Identifier): Boolean =
4243
runCatching {
44+
// Support "Exact Revision Matcher" syntax.
4345
if (version == pkgId.version) return true
4446

47+
// Support "Sub Revision Matcher" syntax.
48+
if (version.withoutSuffix("+")?.let { prefix -> pkgId.version.startsWith(prefix) } == true) return true
49+
4550
// `Semver.satisfies(String)` requires a valid version range to work as expected, see:
4651
// https://github.com/semver4j/semver4j/issues/132.
4752
val ranges = version.getIvyVersionRanges()

0 commit comments

Comments
 (0)