Skip to content

Commit

Permalink
devonfw#637: Option to disable updates (devonfw#765)
Browse files Browse the repository at this point in the history
  • Loading branch information
KianRolf authored Nov 22, 2024
1 parent 8fd99a8 commit 6b41eef
Show file tree
Hide file tree
Showing 9 changed files with 36 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ public class ContextCommandlet extends Commandlet {

private final FlagProperty offline;

private final FlagProperty skipUpdates;

private final LocaleProperty locale;

private IdeStartContextImpl startContext;
Expand All @@ -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));
}

Expand Down Expand Up @@ -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());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -538,6 +538,11 @@ public boolean isOfflineMode() {
return this.startContext.isOfflineMode();
}

@Override
public boolean isSkipUpdatesMode() {
return this.startContext.isSkipUpdatesMode();
}

@Override
public boolean isOnline() {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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}.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
*/
public class IdeStartContextImpl extends IdeLoggerImpl implements IdeStartContext {

private boolean skipUpdatesMode;

private boolean offlineMode;

private boolean forceMode;
Expand Down Expand Up @@ -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() {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down
1 change: 1 addition & 0 deletions cli/src/main/resources/nls/Help.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions cli/src/main/resources/nls/Help_de.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
Expand Down

0 comments on commit 6b41eef

Please sign in to comment.