Skip to content

Commit

Permalink
Support version-ranges and no-version for units in IU target locations
Browse files Browse the repository at this point in the history
  • Loading branch information
HannesWell committed Oct 16, 2024
1 parent 5d487d6 commit 9f1624f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ private static IInstallableUnit findUnits(Unit unitReference, IQueryable<IInstal

private static IQueryResult<IInstallableUnit> findUnit(Unit unitReference, IQueryable<IInstallableUnit> units)
throws TargetDefinitionSyntaxException {
Version version = parseVersion(unitReference);
VersionRange version = parseVersion(unitReference);

// the createIUQuery treats 0.0.0 version as "any version", and all other versions as exact versions
IQuery<IInstallableUnit> matchingIUQuery = QueryUtil.createIUQuery(unitReference.getId(), version);
Expand All @@ -285,9 +285,9 @@ private static IQueryResult<IInstallableUnit> findUnit(Unit unitReference, IQuer
return queryResult;
}

private static Version parseVersion(Unit unitReference) throws TargetDefinitionSyntaxException {
private static VersionRange parseVersion(Unit unitReference) throws TargetDefinitionSyntaxException {
try {
return Version.parseVersion(unitReference.getVersion());
return VersionRange.create(unitReference.getVersion());
} catch (IllegalArgumentException e) {
throw new TargetDefinitionSyntaxException(NLS.bind("Cannot parse version \"{0}\" of unit \"{1}\"",
unitReference.getVersion(), unitReference.getId()), e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -755,6 +755,9 @@ private static IULocation parseIULocation(Element dom) {
for (Element unitDom : getChildren(dom, "unit")) {
String id = unitDom.getAttribute("id");
String version = unitDom.getAttribute("version");
if (version == null || version.isBlank()) {
version = "0.0.0";
}
units.add(new Unit(id, version));
}
final List<Repository> repositories = new ArrayList<>();
Expand Down

0 comments on commit 9f1624f

Please sign in to comment.