diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc index d3115ae8c..92616229d 100644 --- a/CHANGELOG.adoc +++ b/CHANGELOG.adoc @@ -7,6 +7,7 @@ This file documents all notable changes to https://github.com/devonfw/IDEasy[IDE Release with new features and bugfixes: * https://github.com/devonfw/IDEasy/issues/589[#589]: Fix NLS Bundles for Linux and MacOS +* https://github.com/devonfw/IDEasy/issues/637[#637]: Added option to disable updates * https://github.com/devonfw/IDEasy/issues/764[#764]: IDEasy not working properly in CMD * https://github.com/devonfw/IDEasy/issues/754[#754]: Again messages break processable command output diff --git a/cli/src/main/java/com/devonfw/tools/ide/commandlet/ContextCommandlet.java b/cli/src/main/java/com/devonfw/tools/ide/commandlet/ContextCommandlet.java index df8a57224..f3f77d0ef 100644 --- a/cli/src/main/java/com/devonfw/tools/ide/commandlet/ContextCommandlet.java +++ b/cli/src/main/java/com/devonfw/tools/ide/commandlet/ContextCommandlet.java @@ -26,6 +26,8 @@ public class ContextCommandlet extends Commandlet { private final FlagProperty offline; + private final FlagProperty skipUpdates; + private final LocaleProperty locale; private IdeStartContextImpl startContext; @@ -42,6 +44,7 @@ public ContextCommandlet() { this.debug = add(new FlagProperty("--debug", false, "-d")); this.quiet = add(new FlagProperty("--quiet", false, "-q")); this.offline = add(new FlagProperty("--offline", false, "-o")); + this.skipUpdates = add(new FlagProperty("--skip-updates", false)); this.locale = add(new LocaleProperty("--locale", false, null)); } @@ -73,6 +76,7 @@ public void run() { this.startContext.setForceMode(this.force.isTrue()); this.startContext.setQuietMode(this.quiet.isTrue()); this.startContext.setOfflineMode(this.offline.isTrue()); + this.startContext.setSkipUpdatesMode(this.skipUpdates.isTrue()); this.startContext.setLocale(this.locale.getValue()); } diff --git a/cli/src/main/java/com/devonfw/tools/ide/context/AbstractIdeContext.java b/cli/src/main/java/com/devonfw/tools/ide/context/AbstractIdeContext.java index 338a6081e..0b969d2ce 100644 --- a/cli/src/main/java/com/devonfw/tools/ide/context/AbstractIdeContext.java +++ b/cli/src/main/java/com/devonfw/tools/ide/context/AbstractIdeContext.java @@ -538,6 +538,11 @@ public boolean isOfflineMode() { return this.startContext.isOfflineMode(); } + @Override + public boolean isSkipUpdatesMode() { + return this.startContext.isSkipUpdatesMode(); + } + @Override public boolean isOnline() { diff --git a/cli/src/main/java/com/devonfw/tools/ide/context/IdeStartContext.java b/cli/src/main/java/com/devonfw/tools/ide/context/IdeStartContext.java index c95bf94df..e1a9b13eb 100644 --- a/cli/src/main/java/com/devonfw/tools/ide/context/IdeStartContext.java +++ b/cli/src/main/java/com/devonfw/tools/ide/context/IdeStartContext.java @@ -31,6 +31,11 @@ public interface IdeStartContext extends IdeLogger { */ boolean isOfflineMode(); + /** + * @return {@code true} if quickStart mode is activated (-s/--quickStart), {@code false} otherwise. + */ + boolean isSkipUpdatesMode(); + /** * @return the current {@link Locale}. Either configured via command-line option or {@link Locale#getDefault() default}. */ diff --git a/cli/src/main/java/com/devonfw/tools/ide/context/IdeStartContextImpl.java b/cli/src/main/java/com/devonfw/tools/ide/context/IdeStartContextImpl.java index 31d2701fc..b7963c53c 100644 --- a/cli/src/main/java/com/devonfw/tools/ide/context/IdeStartContextImpl.java +++ b/cli/src/main/java/com/devonfw/tools/ide/context/IdeStartContextImpl.java @@ -13,6 +13,8 @@ */ public class IdeStartContextImpl extends IdeLoggerImpl implements IdeStartContext { + private boolean skipUpdatesMode; + private boolean offlineMode; private boolean forceMode; @@ -88,6 +90,20 @@ public void setOfflineMode(boolean offlineMode) { this.offlineMode = offlineMode; } + @Override + public boolean isSkipUpdatesMode() { + + return this.skipUpdatesMode; + } + + /** + * @param skipUpdatesMode new value of {@link #isSkipUpdatesMode()} ()}. + */ + public void setSkipUpdatesMode(boolean skipUpdatesMode) { + + this.skipUpdatesMode = skipUpdatesMode; + } + @Override public Locale getLocale() { diff --git a/cli/src/main/java/com/devonfw/tools/ide/tool/LocalToolCommandlet.java b/cli/src/main/java/com/devonfw/tools/ide/tool/LocalToolCommandlet.java index 08614fc7b..e5a7be510 100644 --- a/cli/src/main/java/com/devonfw/tools/ide/tool/LocalToolCommandlet.java +++ b/cli/src/main/java/com/devonfw/tools/ide/tool/LocalToolCommandlet.java @@ -75,18 +75,13 @@ public final boolean install(boolean silent, EnvironmentContext environmentConte VersionIdentifier installedVersion = getInstalledVersion(); Step step = this.context.newStep(silent, "Install " + this.tool, configuredVersion); try { - // TODO https://github.com/devonfw/IDEasy/issues/664 - boolean enableOptimization = false; - // performance: avoid calling installTool if already up-to-date - if (enableOptimization & configuredVersion.equals(installedVersion)) { // here we can add https://github.com/devonfw/IDEasy/issues/637 - return toolAlreadyInstalled(silent, installedVersion, step); - } // install configured version of our tool in the software repository if not already installed ToolInstallation installation = installTool(configuredVersion, environmentContext); // check if we already have this version installed (linked) locally in IDE_HOME/software VersionIdentifier resolvedVersion = installation.resolvedVersion(); - if (resolvedVersion.equals(installedVersion) && !installation.newInstallation()) { + if ((resolvedVersion.equals(installedVersion) && !installation.newInstallation()) + || (configuredVersion.matches(installedVersion) && context.isSkipUpdatesMode())) { return toolAlreadyInstalled(silent, installedVersion, step); } if (!isIgnoreSoftwareRepo()) { diff --git a/cli/src/main/resources/nls/Help.properties b/cli/src/main/resources/nls/Help.properties index 0ebd40e67..c7cfa44cc 100644 --- a/cli/src/main/resources/nls/Help.properties +++ b/cli/src/main/resources/nls/Help.properties @@ -117,6 +117,7 @@ opt.--offline=enable offline mode (skip updates or git pull, fail downloads or g opt.--quiet=disable info logging (only log success, warning or error). opt.--skip-repositories=skip the setup of repositories. opt.--skip-tools=skip the installation/update of tools. +opt.--skip-updates=disables tool updates if the configured versions match the installed versions. opt.--trace=enable trace logging. opt.--version=Print the IDE version and exit. options=Options: diff --git a/cli/src/main/resources/nls/Help_de.properties b/cli/src/main/resources/nls/Help_de.properties index efab2481a..b6210648a 100644 --- a/cli/src/main/resources/nls/Help_de.properties +++ b/cli/src/main/resources/nls/Help_de.properties @@ -117,6 +117,7 @@ opt.--offline=Aktiviert den Offline-Modus (Überspringt Aktualisierungen oder gi opt.--quiet=Deaktiviert Info Logging ( nur success, warning und error). opt.--skip-repositories=Überspringt die Einrichtung der Repositories. opt.--skip-tools=Überspringt die Installation/Aktualisierung der Tools. +opt.--skip-updates=Deaktiviert Aktualisierungen von Tools wenn die installierten Versionen mit den konfigurierten Versionen übereinstimmen. opt.--trace=Aktiviert Trace-Ausgaben (detaillierte Fehleranalyse). opt.--version=Zeigt die IDE Version an und beendet das Programm. options=Optionen: diff --git a/cli/src/test/java/com/devonfw/tools/ide/commandlet/HelpCommandletTest.java b/cli/src/test/java/com/devonfw/tools/ide/commandlet/HelpCommandletTest.java index 27797e574..02b1d599f 100644 --- a/cli/src/test/java/com/devonfw/tools/ide/commandlet/HelpCommandletTest.java +++ b/cli/src/test/java/com/devonfw/tools/ide/commandlet/HelpCommandletTest.java @@ -146,6 +146,7 @@ private void assertOptionLogMessages(IdeTestContext context) { assertThat(context).logAtInfo().hasEntries( "--locale the locale (e.g. '--locale=de' for German language).", + "--skip-updates disables tool updates if the configured versions match the installed versions.", "-b | --batch enable batch mode (non-interactive).", "-d | --debug enable debug logging.", "-f | --force enable force mode.",