diff --git a/prospero-cli/src/main/java/org/wildfly/prospero/cli/commands/UpdateCommand.java b/prospero-cli/src/main/java/org/wildfly/prospero/cli/commands/UpdateCommand.java index d1cdc898e..8bc1b8545 100644 --- a/prospero-cli/src/main/java/org/wildfly/prospero/cli/commands/UpdateCommand.java +++ b/prospero-cli/src/main/java/org/wildfly/prospero/cli/commands/UpdateCommand.java @@ -29,6 +29,8 @@ import java.util.stream.Collectors; import org.apache.commons.io.FileUtils; +import org.eclipse.aether.resolution.VersionRangeResolutionException; +import org.eclipse.aether.version.Version; import org.jboss.galleon.ProvisioningException; import org.jboss.galleon.diff.FsDiff; import org.jboss.galleon.diff.FsEntry; @@ -117,9 +119,9 @@ public Integer call() throws Exception { log.tracef("Perform full update"); console.println(CliMessages.MESSAGES.updateHeader(installationDir)); - + InstallationMetadata installationMetadata = InstallationMetadata.loadInstallation(installationDir); try (UpdateAction updateAction = actionFactory.update(installationDir, mavenOptions, console, repositories)) { - performUpdate(updateAction, yes, console, installationDir); + performUpdate(updateAction, yes, console, installationDir, repositories); } } @@ -129,10 +131,16 @@ public Integer call() throws Exception { return ReturnCodes.SUCCESS; } - private boolean performUpdate(UpdateAction updateAction, boolean yes, CliConsole console, Path installDir) throws OperationException, ProvisioningException { + private boolean performUpdate(UpdateAction updateAction, boolean yes, CliConsole console, Path installDir, List repositories) throws OperationException, ProvisioningException { Path targetDir = null; try { targetDir = Files.createTempDirectory("update-candidate"); + final List manifestUpdates = updateAction.findManifestUpdates(repositories.get(0)); + if(!manifestUpdates.isEmpty()){ + for(Version version: manifestUpdates){ + console.println("Manifest version update detected: Version ["+ version + "]is now available."); + } + } if (buildUpdate(updateAction, targetDir, yes, console, () -> console.confirmUpdates())) { console.println(""); console.buildUpdatesComplete(); @@ -151,7 +159,7 @@ private boolean performUpdate(UpdateAction updateAction, boolean yes, CliConsole } else { return false; } - } catch (IOException e) { + } catch (IOException | VersionRangeResolutionException e) { throw ProsperoLogger.ROOT_LOGGER.unableToCreateTemporaryDirectory(e); } finally { if (targetDir != null) { @@ -422,17 +430,17 @@ private FeaturePackLocation getFpl(InstallationProfile knownFeaturePack, String public UpdateCommand(CliConsole console, ActionFactory actionFactory) { super(console, actionFactory, CliConstants.Commands.UPDATE, List.of( - new UpdateCommand.PrepareCommand(console, actionFactory), - new UpdateCommand.ApplyCommand(console, actionFactory), - new UpdateCommand.PerformCommand(console, actionFactory), - new UpdateCommand.ListCommand(console, actionFactory), + new PrepareCommand(console, actionFactory), + new ApplyCommand(console, actionFactory), + new PerformCommand(console, actionFactory), + new ListCommand(console, actionFactory), new SubscribeCommand(console, actionFactory)) ); + } - private static boolean buildUpdate(UpdateAction updateAction, Path updateDirectory, boolean yes, CliConsole console, Supplier confirmation) throws OperationException, ProvisioningException { + private static boolean buildUpdate(UpdateAction updateAction, Path updateDirectory, boolean yes, CliConsole console, Supplier confirmation) throws OperationException, ProvisioningException, VersionRangeResolutionException { final UpdateSet updateSet = updateAction.findUpdates(); - console.updatesFound(updateSet.getArtifactUpdates()); if (updateSet.isEmpty()) { return false; @@ -470,5 +478,4 @@ public static Path detectProsperoInstallationPath() throws ArgumentParsingExcept } return Paths.get(modulePath).toAbsolutePath().getParent(); } - } diff --git a/prospero-common/src/main/java/org/wildfly/prospero/actions/UpdateAction.java b/prospero-common/src/main/java/org/wildfly/prospero/actions/UpdateAction.java index 7b1e5c4c1..5a6fa30d4 100644 --- a/prospero-common/src/main/java/org/wildfly/prospero/actions/UpdateAction.java +++ b/prospero-common/src/main/java/org/wildfly/prospero/actions/UpdateAction.java @@ -24,6 +24,14 @@ import java.util.List; import org.apache.commons.io.FileUtils; +import org.eclipse.aether.DefaultRepositorySystemSession; +import org.eclipse.aether.RepositorySystem; +import org.eclipse.aether.artifact.DefaultArtifact; +import org.eclipse.aether.repository.RemoteRepository; +import org.eclipse.aether.resolution.VersionRangeRequest; +import org.eclipse.aether.resolution.VersionRangeResolutionException; +import org.eclipse.aether.resolution.VersionRangeResult; +import org.eclipse.aether.version.Version; import org.jboss.galleon.util.PathsUtils; import org.wildfly.channel.Channel; import org.wildfly.channel.Repository; @@ -171,4 +179,17 @@ private ProsperoConfig addTemporaryRepositories(List repositories) { return new ProsperoConfig(channels, prosperoConfig.getMavenOptions()); } + + public List findManifestUpdates(Repository repository) throws VersionRangeResolutionException { + final RepositorySystem system = mavenSessionManager.newRepositorySystem(); + final DefaultRepositorySystemSession session = mavenSessionManager.newRepositorySystemSession(system); + final List repositories = List.of(new RemoteRepository.Builder("repo", "default", repository.getUrl()).build()); + + VersionRangeRequest versionRangeRequest = new VersionRangeRequest(new DefaultArtifact("org.jboss.eap.channels", "eap-8.0", "manifest", "yaml", "(,)"), + repositories, null); + VersionRangeResult versionRangeResult = system.resolveVersionRange(session, versionRangeRequest); + + return versionRangeResult.getVersions(); // discovered versions + } + }