use of org.graalvm.component.installer.Version in project graal by oracle.
the class QueryCommandBase method findRequiredGraalVMVersion.
protected String findRequiredGraalVMVersion(ComponentInfo info) {
String s = info.getRequiredGraalValues().get(CAP_GRAALVM_VERSION);
if (s == null) {
return val(s);
}
Version v = Version.fromString(s);
return v.displayString();
}
use of org.graalvm.component.installer.Version in project graal by oracle.
the class UpgradeCommand method configureProcess.
ComponentInfo configureProcess() throws IOException {
input.existingFiles().setVerifyJars(verifyJars);
Version min = input.getLocalRegistry().getGraalVersion();
String s = input.peekParameter();
Version v = min;
Version.Match filter = min.match(allowDistUpgrades() ? Version.Match.Type.MOSTRECENT : Version.Match.Type.COMPATIBLE);
if (s != null) {
try {
Version.Match.Type mt = Version.Match.Type.COMPATIBLE;
if (s.startsWith("=")) {
mt = Version.Match.Type.EXACT;
s = s.substring(1);
} else if (s.startsWith("+")) {
mt = Version.Match.Type.INSTALLABLE;
s = s.substring(1);
}
v = Version.fromUserString(s);
// cannot just compare user vs. graal, must match the user to the list of Graals to
// resolve the
// uncertaint parts (-x and possible suffix)
filter = v.match(mt);
if (min.compareTo(v) > 0) {
throw feedback.failure("UPGRADE_CannotDowngrade", null, v.displayString());
}
input.nextParameter();
input.existingFiles().matchVersion(filter);
} catch (IllegalArgumentException ex) {
// not a version, continue with component upgrade
}
}
// allow dist upgrade when searching for components
for (ComponentParam p : input.existingFiles()) {
helper.addComponent(p);
}
ComponentInfo info = helper.findGraalVersion(filter);
return info;
}
use of org.graalvm.component.installer.Version in project graal by oracle.
the class InstallCommand method verifyInstaller.
boolean verifyInstaller(Installer inst) {
ComponentInfo info = inst.getComponentInfo();
Verifier vrf = inst.createVerifier();
vrf.setVersionMatch(matchInstallVesion());
vrf.validateRequirements(info);
boolean keep = force || vrf.shouldInstall(info);
if (!keep) {
// component will be skipped, do not bother with validation
feedback.output("INSTALL_ComponentAlreadyInstalled", inst.getComponentInfo().getName(), inst.getComponentInfo().getId());
return false;
}
ComponentInfo existing = input.getLocalRegistry().findComponent(info.getId());
if (existing != null) {
// will refuse to install existing bundled components:
if (existing.getDistributionType() != DistributionType.OPTIONAL) {
throw new DependencyException.Conflict(existing.getId(), info.getVersionString(), existing.getVersionString(), feedback.l10n("INSTALL_CannotReplaceBundledComponent", existing.getName(), existing, existing.getVersionString()));
}
}
Version minV = vrf.getMinVersion();
if (minV != null && minV.compareTo(this.minRequiredGraalVersion) > 0) {
minRequiredGraalVersion = minV;
}
addDependencies(info);
return true;
}
use of org.graalvm.component.installer.Version in project graal by oracle.
the class AvailableCommand method filterDisplayedVersions.
@Override
protected List<ComponentInfo> filterDisplayedVersions(String id, Collection<ComponentInfo> infos) {
if (input.optValue(Commands.OPTION_ALL) != null) {
return super.filterDisplayedVersions(id, infos);
}
Set<Version> seen = new HashSet<>();
Collection<ComponentInfo> filtered = new ArrayList<>();
Verifier vrf = new Verifier(feedback, input.getLocalRegistry(), input.getRegistry());
vrf.setCollectErrors(true);
vrf.setSilent(true);
vrf.ignoreExisting(true);
if (showUpdates) {
vrf.setVersionMatch(getRegistry().getGraalVersion().match(Version.Match.Type.INSTALLABLE));
} else {
vrf.setVersionMatch(getRegistry().getGraalVersion().match(Version.Match.Type.SATISFIES_COMPATIBLE));
}
if (defaultFilter) {
List<ComponentInfo> sorted = new ArrayList<>(infos);
Collections.sort(sorted, ComponentInfo.versionComparator().reversed());
for (ComponentInfo ci : sorted) {
// for non-core components, only display those compatible with the current release.
if (vrf.validateRequirements(ci).hasErrors()) {
continue;
}
if (CommonConstants.GRAALVM_CORE_PREFIX.equals(ci.getId())) {
if (!showCore || // graalvm core does not depend on anything:
!vrf.getVersionMatch().test(ci.getVersion())) {
// filter out graalvm core by default
continue;
}
}
// select just the most recent version
filtered.add(ci);
break;
}
} else {
for (ComponentInfo ci : infos) {
if (seen.add(ci.getVersion().installVersion())) {
filtered.add(ci);
}
}
}
return super.filterDisplayedVersions(id, filtered);
}
use of org.graalvm.component.installer.Version in project graal by oracle.
the class RemoteStorageTest method checkMultipleGraalVMDependencies.
@Test
public void checkMultipleGraalVMDependencies() throws Exception {
loadCatalog("catalogMultiVersions.properties");
Set<ComponentInfo> rubies = remStorage.loadComponentMetadata("ruby");
Set<Version> versions = new HashSet<>();
for (ComponentInfo ci : rubies) {
Version compVersion = ci.getVersion();
assertTrue(versions.add(compVersion));
String gv = ci.getRequiredGraalValues().get(BundleConstants.GRAAL_VERSION);
assertEquals(gv, compVersion.toString());
}
}
Aggregations