• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

devonfw / IDEasy / 28658329500

03 Jul 2026 11:43AM UTC coverage: 71.312% (-0.04%) from 71.351%
28658329500

Pull #2105

github

web-flow
Merge 23a524516 into 2504d944a
Pull Request #2105: #2056 Replaced progress bar with progress information for plugin installation

4699 of 7284 branches covered (64.51%)

Branch coverage included in aggregate %.

12097 of 16269 relevant lines covered (74.36%)

3.15 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

75.4
cli/src/main/java/com/devonfw/tools/ide/context/IdeContext.java
1
package com.devonfw.tools.ide.context;
2

3
import java.nio.file.Files;
4
import java.nio.file.Path;
5

6
import com.devonfw.tools.ide.cli.CliAbortException;
7
import com.devonfw.tools.ide.cli.CliException;
8
import com.devonfw.tools.ide.cli.CliOfflineException;
9
import com.devonfw.tools.ide.commandlet.CommandletManager;
10
import com.devonfw.tools.ide.common.SystemPath;
11
import com.devonfw.tools.ide.environment.EnvironmentVariables;
12
import com.devonfw.tools.ide.environment.EnvironmentVariablesType;
13
import com.devonfw.tools.ide.environment.IdeSystem;
14
import com.devonfw.tools.ide.git.GitContext;
15
import com.devonfw.tools.ide.io.FileAccess;
16
import com.devonfw.tools.ide.io.IdeProgressBar;
17
import com.devonfw.tools.ide.io.IdeProgressBarNone;
18
import com.devonfw.tools.ide.log.IdeLogLevel;
19
import com.devonfw.tools.ide.merge.DirectoryMerger;
20
import com.devonfw.tools.ide.network.NetworkStatus;
21
import com.devonfw.tools.ide.os.SystemInfo;
22
import com.devonfw.tools.ide.os.WindowsPathSyntax;
23
import com.devonfw.tools.ide.process.ProcessContext;
24
import com.devonfw.tools.ide.step.Step;
25
import com.devonfw.tools.ide.tool.corepack.Corepack;
26
import com.devonfw.tools.ide.tool.custom.CustomToolRepository;
27
import com.devonfw.tools.ide.tool.gradle.Gradle;
28
import com.devonfw.tools.ide.tool.mvn.Mvn;
29
import com.devonfw.tools.ide.tool.mvn.MvnRepository;
30
import com.devonfw.tools.ide.tool.npm.Npm;
31
import com.devonfw.tools.ide.tool.npm.NpmRepository;
32
import com.devonfw.tools.ide.tool.pip.PipRepository;
33
import com.devonfw.tools.ide.tool.repository.ToolRepository;
34
import com.devonfw.tools.ide.url.model.UrlMetadata;
35
import com.devonfw.tools.ide.variable.IdeVariables;
36
import com.devonfw.tools.ide.version.IdeVersion;
37
import com.devonfw.tools.ide.version.VersionIdentifier;
38

39
/**
40
 * Interface for the context of IDEasy and the potential current project. Central constants for names of files and folders are defined here and should be
41
 * referenced instead of duplicating such string literals across the code-base. All central components can be accessed from here such as:
42
 * <ul>
43
 * <li>{@link #getPath() system path} (abstraction of PATH environment variable)</li>
44
 * <li>{@link #getCommandletManager() commandlet manager} (access {@link com.devonfw.tools.ide.commandlet.Commandlet}s)</li>
45
 * <li>{@link #getFileAccess() file access} (file and I/O operations on a higher level of abstraction)</li>
46
 * <li>{@link #getNetworkStatus() network status} (determine if we are online or offline)</li>
47
 * <li>{@link #newProcess() process context} (start external programs as process including logging, error handling, background and output processing)</li>
48
 * <li>{@link #newStep(String) step} creation (a sub-task that may fail without stopping the overall process)</li>
49
 * <li>{@link #newProgressBar(String, long, String, long) progress bar} (to display long-running progress for UX)</li>
50
 * <li>{@link #getGitContext() git context} (for git operations like clone, fetch, pull, etc.)</li>
51
 * <li>{@link #getSystemInfo() system info} (for information about OS and CPU architecture)</li>
52
 * <li>{@link #getVariables() environment variables} (to access and modify IDEasy variables according to our configuration layout)</li>
53
 * 
54
 * <li>{@link #question(Object[], String, Object...) question} (for interaction to let the end-user decide)</li>
55
 * <li>{@link #getUrls() url metadata} (access ide-urls to find versions, download URLs, dependency and security metadata)</li>
56
 * <li>{@link #getDefaultToolRepository() tool repository} (for abstraction of version resolution and download of tools)</li>
57
 * <li>{@link #getSystem() ide system} (abstraction of {@link java.lang.System} for system environment variables)</li>
58
 * </ul>
59
 */
60
public interface IdeContext extends IdeStartContext {
61

62
  /**
63
   * The default settings URL.
64
   *
65
   * @see com.devonfw.tools.ide.commandlet.AbstractUpdateCommandlet
66
   */
67
  String DEFAULT_SETTINGS_REPO_URL = "https://github.com/devonfw/ide-settings.git";
68

69
  /** The name of the workspaces folder. */
70
  String FOLDER_WORKSPACES = "workspaces";
71

72
  /** The name of the {@link #getSettingsPath() settings} folder. */
73
  String FOLDER_SETTINGS = "settings";
74

75
  /** The name of the {@link #getSoftwarePath() software} folder. */
76
  String FOLDER_SOFTWARE = "software";
77

78
  /** The name of the {@link #getUrlsPath() urls} folder. */
79
  String FOLDER_URLS = "urls";
80

81
  /** The name of the conf folder for project specific user configurations. */
82
  String FOLDER_CONF = "conf";
83

84
  /**
85
   * The name of the folder inside IDE_ROOT reserved for IDEasy. Intentionally starting with an underscore and not a dot to prevent effects like OS hiding,
86
   * maven filtering, .gitignore and to distinguish from {@link #FOLDER_DOT_IDE}.
87
   *
88
   * @see #getIdePath()
89
   */
90
  String FOLDER_UNDERSCORE_IDE = "_ide";
91

92
  /**
93
   * The name of the folder inside {@link #FOLDER_UNDERSCORE_IDE} with the current IDEasy installation.
94
   *
95
   * @see #getIdeInstallationPath()
96
   */
97
  String FOLDER_INSTALLATION = "installation";
98

99
  /**
100
   * The name of the hidden folder for IDE configuration in the users home directory or status information in the IDE_HOME directory.
101
   *
102
   * @see #getUserHomeIde()
103
   */
104
  String FOLDER_DOT_IDE = ".ide";
105

106
  /** The name of the updates folder for temporary data and backup. */
107
  String FOLDER_UPDATES = "updates";
108

109
  /** The name of the volume folder for mounting archives like *.dmg. */
110
  String FOLDER_VOLUME = "volume";
111

112
  /** The name of the backups folder for backup. */
113
  String FOLDER_BACKUPS = "backups";
114

115
  /** The name of the logs folder for log-files (in {@link #FOLDER_UNDERSCORE_IDE}). */
116
  String FOLDER_LOGS = "logs";
117

118
  /** The name of the downloads folder. */
119
  String FOLDER_DOWNLOADS = "Downloads";
120

121
  /** The name of the bin folder where executable files are found by default. */
122
  String FOLDER_BIN = "bin";
123

124
  /** The name of the repositories folder where properties files are stores for each repository */
125
  String FOLDER_REPOSITORIES = "repositories";
126

127
  /** The name of the repositories folder where properties files are stores for each repository */
128
  String FOLDER_LEGACY_REPOSITORIES = "projects";
129

130
  /** The name of the Contents folder inside a MacOS app. */
131
  String FOLDER_CONTENTS = "Contents";
132

133
  /** The name of the Resources folder inside a MacOS app. */
134
  String FOLDER_RESOURCES = "Resources";
135

136
  /** The name of the app folder inside a MacOS app. */
137
  String FOLDER_APP = "app";
138

139
  /** The name of the extra folder inside the software folder */
140
  String FOLDER_EXTRA = "extra";
141

142
  /**
143
   * The name of the {@link #getPluginsPath() plugins folder} and also the plugins folder inside the IDE folders of {@link #getSettingsPath() settings} (e.g.
144
   * settings/eclipse/plugins).
145
   */
146
  String FOLDER_PLUGINS = "plugins";
147

148
  /**
149
   * The name of the workspace folder inside the IDE specific {@link #FOLDER_SETTINGS settings} containing the configuration templates in #FOLDER_SETUP
150
   * #FOLDER_UPDATE.
151
   */
152
  String FOLDER_WORKSPACE = "workspace";
153

154
  /**
155
   * The name of the setup folder inside the {@link #FOLDER_WORKSPACE workspace} folder containing the templates for the configuration templates for the initial
156
   * setup of a workspace. This is closely related with the {@link #FOLDER_UPDATE update} folder.
157
   */
158
  String FOLDER_SETUP = "setup";
159

160
  /**
161
   * The name of the update folder inside the {@link #FOLDER_WORKSPACE workspace} folder containing the templates for the configuration templates for the update
162
   * of a workspace. Configurations in this folder will be applied every time the IDE is started. They will override the settings the user may have manually
163
   * configured every time. This is only for settings that have to be the same for every developer in the project. An example would be the number of spaces used
164
   * for indentation and other code-formatting settings. If all developers in a project team use the same formatter settings, this will actively prevent
165
   * diff-wars. However, the entire team needs to agree on these settings.<br> Never configure aspects inside this update folder that may be of personal flavor
166
   * such as the color theme. Otherwise developers will hate you as you actively take away their freedom to customize the IDE to their personal needs and
167
   * wishes. Therefore do all "biased" or "flavored" configurations in {@link #FOLDER_SETUP setup} so these are only pre-configured but can be changed by the
168
   * user as needed.
169
   */
170
  String FOLDER_UPDATE = "update";
171

172
  /**
173
   * The name of the folder inside {@link #FOLDER_UNDERSCORE_IDE _ide} folder containing internal resources and scripts of IDEasy.
174
   */
175
  String FOLDER_INTERNAL = "internal";
176

177
  /** The file where the installed software version is written to as plain text. */
178
  String FILE_SOFTWARE_VERSION = ".ide.software.version";
179

180
  /** The file where the installed software version is written to as plain text. */
181
  String FILE_LEGACY_SOFTWARE_VERSION = ".devon.software.version";
182

183
  /** The file for the license agreement. */
184
  String FILE_LICENSE_AGREEMENT = ".license.agreement";
185

186
  /** The file extension for a {@link java.util.Properties} file. */
187
  String EXT_PROPERTIES = ".properties";
188

189
  /** The default for {@link #getWorkspaceName()}. */
190
  String WORKSPACE_MAIN = "main";
191

192
  /** The folder with the configuration template files from the settings. */
193
  String FOLDER_TEMPLATES = "templates";
194

195
  /** Legacy folder name used as compatibility fallback if {@link #FOLDER_TEMPLATES} does not exist. */
196
  String FOLDER_LEGACY_TEMPLATES = "devon";
197

198
  /** The default folder name for {@link #getIdeRoot() IDE_ROOT}. */
199
  String FOLDER_PROJECTS = "projects";
200

201
  /**
202
   * file containing the current local commit hash of the settings repository.
203
   */
204
  String SETTINGS_COMMIT_ID = ".commit.id";
205

206
  /** The IDEasy ASCII logo. */
207
  String LOGO = """
4✔
208
      __       ___ ___  ___
209
      ╲ ╲     |_ _|   ╲| __|__ _ ____ _
210
       > >     | || |) | _|/ _` (_-< || |
211
      /_/ ___ |___|___/|___╲__,_/__/╲_, |
212
         |___|                       |__/
213
      """.replace('╲', '\\');
2✔
214

215
  /**
216
   * The keyword for project name convention.
217
   */
218
  String SETTINGS_REPOSITORY_KEYWORD = "settings";
219
  String IS_NOT_INSTALLED_BUT_REQUIRED = "is not installed on your computer but required by IDEasy.";
220
  String WINDOWS_GIT_DOWNLOAD_URL = "https://git-scm.com/download/";
221
  String PLEASE_DOWNLOAD_AND_INSTALL_GIT = "Please download and install git";
222

223
  /**
224
   * @return the {@link NetworkStatus} for online check and related operations.
225
   */
226
  NetworkStatus getNetworkStatus();
227

228
  /**
229
   * @return {@code true} if {@link #isOfflineMode() offline mode} is active or we are NOT {@link #isOnline() online}, {@code false} otherwise.
230
   * @deprecated use {@link #getNetworkStatus()}
231
   */
232
  default boolean isOffline() {
233

234
    return getNetworkStatus().isOffline();
4✔
235
  }
236

237
  /**
238
   * @return {@code true} if we are currently online (Internet access is available), {@code false} otherwise.
239
   * @deprecated use {@link #getNetworkStatus()}
240
   */
241
  default boolean isOnline() {
242

243
    return getNetworkStatus().isOnline();
×
244
  }
245

246
  /**
247
   * Print the IDEasy {@link #LOGO logo}.
248
   */
249
  default void printLogo() {
250

251
    AbstractIdeContext.LOG.info(LOGO);
3✔
252
  }
1✔
253

254
  /**
255
   * Asks the user for a single string input.
256
   *
257
   * @param message The information message to display.
258
   * @param defaultValue The default value to return when no input is provided or {@code null} to keep asking until the user entered a non empty value.
259
   * @return The string input from the user, or the default value if no input is provided.
260
   */
261
  String askForInput(String message, String defaultValue);
262

263
  /**
264
   * Asks the user for a single string input.
265
   *
266
   * @param message The information message to display.
267
   * @return The string input from the user.
268
   */
269
  default String askForInput(String message) {
270
    return askForInput(message, null);
5✔
271
  }
272

273
  /**
274
   * @param question the question to ask.
275
   * @param args arguments for filling the templates
276
   * @return {@code true} if the user answered with "yes", {@code false} otherwise ("no").
277
   */
278
  default boolean question(String question, Object... args) {
279

280
    String yes = "yes";
2✔
281
    String option = question(new String[] { yes, "no" }, question, args);
16✔
282
    if (yes.equals(option)) {
4!
283
      return true;
2✔
284
    }
285
    return false;
×
286
  }
287

288
  /**
289
   * @param <O> type of the option. E.g. {@link String}.
290
   * @param options the available options for the user to answer. There should be at least two options given as otherwise the question cannot make sense.
291
   * @param question the question to ask.
292
   * @return the option selected by the user as answer.
293
   */
294
  @SuppressWarnings("unchecked")
295
  <O> O question(O[] options, String question, Object... args);
296

297
  /**
298
   * Will ask the given question. If the user answers with "yes" the method will return and the process can continue. Otherwise if the user answers with "no" an
299
   * exception is thrown to abort further processing.
300
   *
301
   * @param questionTemplate the yes/no question to {@link #question(String, Object...) ask}.
302
   * @param args the arguments to fill the placeholders in the question template.
303
   * @throws CliAbortException if the user answered with "no" and further processing shall be aborted.
304
   */
305
  default void askToContinue(String questionTemplate, Object... args) {
306
    boolean yesContinue = question(questionTemplate, args);
5✔
307
    if (!yesContinue) {
2!
308
      throw new CliAbortException();
×
309
    }
310
  }
1✔
311

312
  /**
313
   * @param purpose the purpose why Internet connection is required.
314
   * @param explicitOnlineCheck if {@code true}, perform an explicit {@link #isOffline()} check; if {@code false} use {@link #isOfflineMode()}.
315
   * @throws CliException if you are {@link #isOffline() offline}.
316
   */
317
  default void requireOnline(String purpose, boolean explicitOnlineCheck) {
318

319
    if (explicitOnlineCheck) {
2✔
320
      if (isOffline()) {
3✔
321
        throw CliOfflineException.ofPurpose(purpose);
3✔
322
      }
323
    } else {
324
      if (isOfflineMode()) {
3!
325
        throw CliOfflineException.ofPurpose(purpose);
3✔
326
      }
327
    }
328
  }
1✔
329

330
  /**
331
   * @return the {@link SystemInfo}.
332
   */
333
  SystemInfo getSystemInfo();
334

335
  /**
336
   * @return the {@link EnvironmentVariables} with full inheritance.
337
   */
338
  EnvironmentVariables getVariables();
339

340
  /**
341
   * @return the {@link FileAccess}.
342
   */
343
  FileAccess getFileAccess();
344

345
  /**
346
   * @return the {@link CommandletManager}.
347
   */
348
  CommandletManager getCommandletManager();
349

350
  /**
351
   * @return the default {@link ToolRepository}.
352
   */
353
  ToolRepository getDefaultToolRepository();
354

355
  /**
356
   * @return the {@link CustomToolRepository}.
357
   */
358
  CustomToolRepository getCustomToolRepository();
359

360
  /**
361
   * @return the {@link MvnRepository}.
362
   */
363
  MvnRepository getMvnRepository();
364

365
  /**
366
   * @return the {@link NpmRepository}.
367
   */
368
  NpmRepository getNpmRepository();
369

370
  /**
371
   * @return the {@link PipRepository}.
372
   */
373
  PipRepository getPipRepository();
374

375
  /**
376
   * @return the {@link Path} to the IDE instance directory. You can have as many IDE instances on the same computer as independent tenants for different
377
   *     isolated projects.
378
   * @see com.devonfw.tools.ide.variable.IdeVariables#IDE_HOME
379
   */
380
  Path getIdeHome();
381

382
  /**
383
   * @return the name of the current project.
384
   * @see com.devonfw.tools.ide.variable.IdeVariables#PROJECT_NAME
385
   */
386
  String getProjectName();
387

388
  /**
389
   * @return the IDEasy version the {@link #getIdeHome() current project} was created with or migrated to.
390
   */
391
  VersionIdentifier getProjectVersion();
392

393
  /**
394
   * @param version the new value of {@link #getProjectVersion()}.
395
   */
396
  void setProjectVersion(VersionIdentifier version);
397

398
  /**
399
   * @return the {@link Path} to the IDE installation root directory. This is the top-level folder where the {@link #getIdeHome() IDE instances} are located as
400
   *     sub-folder. There is a reserved ".ide" folder where central IDE data is stored such as the {@link #getUrlsPath() download metadata} and the central
401
   *     software repository.
402
   * @see com.devonfw.tools.ide.variable.IdeVariables#IDE_ROOT
403
   */
404
  Path getIdeRoot();
405

406
  /**
407
   * @return the {@link Path} to the {@link #FOLDER_UNDERSCORE_IDE}.
408
   * @see #getIdeRoot()
409
   * @see #FOLDER_UNDERSCORE_IDE
410
   */
411
  Path getIdePath();
412

413
  /**
414
   * @return the {@link Path} to the {@link #FOLDER_INSTALLATION installation} folder of IDEasy. This is a link to the (latest) installed release of IDEasy. On
415
   *     upgrade a new release is installed and the link is switched to the new release.
416
   */
417
  default Path getIdeInstallationPath() {
418

419
    Path idePath = getIdePath();
3✔
420
    if (idePath == null) {
2!
421
      return null;
×
422
    }
423
    return idePath.resolve(FOLDER_INSTALLATION);
4✔
424
  }
425

426
  /**
427
   * @return the current working directory ("user.dir"). This is the directory where the user's shell was located when the IDE CLI was invoked.
428
   */
429
  Path getCwd();
430

431
  /**
432
   * @return the {@link Path} for the temporary directory to use. Will be different from the OS specific temporary directory (java.io.tmpDir).
433
   */
434
  Path getTempPath();
435

436
  /**
437
   * @return the {@link Path} for the temporary download directory to use.
438
   */
439
  Path getTempDownloadPath();
440

441
  /**
442
   * @return the {@link Path} to the download metadata (ide-urls). Here a git repository is cloned and updated (pulled) to always have the latest metadata to
443
   *     download tools.
444
   * @see com.devonfw.tools.ide.url.model.folder.UrlRepository
445
   */
446
  Path getUrlsPath();
447

448
  /**
449
   * @return the {@link UrlMetadata}. Will be lazily instantiated and thereby automatically be cloned or pulled (by default).
450
   */
451
  UrlMetadata getUrls();
452

453
  /**
454
   * @return the {@link Path} to the download cache. All downloads will be placed here using a unique naming pattern that allows to reuse these artifacts. So if
455
   *     the same artifact is requested again it will be taken from the cache to avoid downloading it again.
456
   */
457
  Path getDownloadPath();
458

459
  /**
460
   * @return the {@link Path} to the software folder inside {@link #getIdeHome() IDE_HOME}. All tools for that IDE instance will be linked here from the
461
   *     {@link #getSoftwareRepositoryPath() software repository} as sub-folder named after the according tool.
462
   */
463
  Path getSoftwarePath();
464

465
  /**
466
   * @return the {@link Path} to the extra folder inside software folder inside {@link #getIdeHome() IDE_HOME}. All tools for that IDE instance will be linked
467
   *     here from the {@link #getSoftwareRepositoryPath() software repository} as sub-folder named after the according tool.
468
   */
469
  Path getSoftwareExtraPath();
470

471
  /**
472
   * @return the {@link Path} to the global software repository. This is the central directory where the tools are extracted physically on the local disc. Those
473
   *     are shared among all IDE instances (see {@link #getIdeHome() IDE_HOME}) via symbolic links (see {@link #getSoftwarePath()}). Therefore this repository
474
   *     follows the sub-folder structure {@code «repository»/«tool»/«edition»/«version»/}. So multiple versions of the same tool exist here as different
475
   *     folders. Further, such software may not be modified so e.g. installation of plugins and other kind of changes to such tool need to happen strictly out
476
   *     of the scope of this folders.
477
   */
478
  Path getSoftwareRepositoryPath();
479

480
  /**
481
   * @return the {@link Path} to the {@link #FOLDER_PLUGINS plugins folder} inside {@link #getIdeHome() IDE_HOME}. All plugins of the IDE instance will be
482
   *     stored here. For each tool that supports plugins a sub-folder with the tool name will be created where the plugins for that tool get installed.
483
   */
484
  Path getPluginsPath();
485

486
  /**
487
   * @return the {@link Path} to the central tool repository. All tools will be installed in this location using the directory naming schema of
488
   *     {@code «repository»/«tool»/«edition»/«version»/}. Actual {@link #getIdeHome() IDE instances} will only contain symbolic links to the physical tool
489
   *     installations in this repository. This allows to share and reuse tool installations across multiple {@link #getIdeHome() IDE instances}. The variable
490
   *     {@code «repository»} is typically {@code default} for the tools from our standard {@link #getUrlsPath() ide-urls download metadata} but this will
491
   *     differ for custom tools from a private repository.
492
   */
493
  Path getToolRepositoryPath();
494

495
  /**
496
   * @return the {@link Path} to the users home directory. Typically initialized via the {@link System#getProperty(String) system property} "user.home".
497
   * @see com.devonfw.tools.ide.variable.IdeVariables#HOME
498
   */
499
  Path getUserHome();
500

501
  /**
502
   * @return the {@link Path} to the ".ide" subfolder in the {@link #getUserHome() users home directory}.
503
   */
504
  Path getUserHomeIde();
505

506
  /**
507
   * @return the {@link Path} to the {@link #FOLDER_SETTINGS settings} folder with the cloned git repository containing the project configuration.
508
   */
509
  Path getSettingsPath();
510

511
  /**
512
   * @return the {@link Path} to the {@link #FOLDER_REPOSITORIES repositories} folder with legacy fallback if not present or {@code null} if not found.
513
   */
514
  default Path getRepositoriesPath() {
515

516
    Path settingsPath = getSettingsPath();
3✔
517
    if (settingsPath == null) {
2!
518
      return null;
×
519
    }
520
    Path repositoriesPath = settingsPath.resolve(IdeContext.FOLDER_REPOSITORIES);
4✔
521
    if (Files.isDirectory(repositoriesPath)) {
5✔
522
      return repositoriesPath;
2✔
523
    }
524
    Path legacyRepositoriesPath = settingsPath.resolve(IdeContext.FOLDER_LEGACY_REPOSITORIES);
4✔
525
    if (Files.isDirectory(legacyRepositoriesPath)) {
5!
526
      return legacyRepositoriesPath;
×
527
    }
528
    return null;
2✔
529
  }
530

531
  /**
532
   * @return the {@link Path} to the {@code settings} folder with the cloned git repository containing the project configuration only if the settings repository
533
   *     is in fact a git repository.
534
   */
535
  Path getSettingsGitRepository();
536

537
  /**
538
   * @return {@code true} if the settings repository is a symlink or a junction to a code-repository.
539
   */
540
  boolean isSettingsCodeRepository();
541

542
  /**
543
   * @return the {@link Path} to the file containing the last tracked commit Id of the settings repository.
544
   */
545
  Path getSettingsCommitIdPath();
546

547
  /**
548
   * @return the {@link Path} to the templates folder inside the {@link #getSettingsPath() settings}. The relative directory structure in this templates folder
549
   *     is to be applied to {@link #getIdeHome() IDE_HOME} when the project is set up.
550
   */
551
  default Path getSettingsTemplatePath() {
552
    Path settingsFolder = getSettingsPath();
3✔
553
    Path templatesFolder = settingsFolder.resolve(IdeContext.FOLDER_TEMPLATES);
4✔
554
    if (!Files.isDirectory(templatesFolder)) {
5✔
555
      Path templatesFolderLegacy = settingsFolder.resolve(IdeContext.FOLDER_LEGACY_TEMPLATES);
4✔
556
      if (Files.isDirectory(templatesFolderLegacy)) {
5!
557
        templatesFolder = templatesFolderLegacy;
×
558
      } else {
559
        AbstractIdeContext.LOG.warn("No templates found in settings git repo neither in {} nor in {} - configuration broken", templatesFolder,
5✔
560
            templatesFolderLegacy);
561
        return null;
2✔
562
      }
563
    }
564
    return templatesFolder;
2✔
565
  }
566

567
  /**
568
   * @return the {@link Path} to the {@code conf} folder with instance specific tool configurations and the
569
   *     {@link EnvironmentVariablesType#CONF user specific project configuration}.
570
   */
571
  Path getConfPath();
572

573
  /**
574
   * @return the {@link Path} to the workspaces base folder containing the individual {@link #getWorkspacePath(String) workspaces}.
575
   * @see #getWorkspacePath(String)
576
   */
577
  Path getWorkspacesBasePath();
578

579
  /**
580
   * @return the {@link Path} to the workspace.
581
   * @see #getWorkspaceName()
582
   */
583
  Path getWorkspacePath();
584

585
  /**
586
   * @param workspace the specific workspace name.
587
   * @return the {@link Path} to the specified workspace.
588
   */
589
  Path getWorkspacePath(String workspace);
590

591
  /**
592
   * @return the name of the workspace. Defaults to {@link #WORKSPACE_MAIN}.
593
   */
594
  String getWorkspaceName();
595

596
  /**
597
   * @return the value of the system {@link IdeVariables#PATH PATH} variable. It is automatically extended according to the tools available in
598
   *     {@link #getSoftwarePath() software path} unless {@link #getIdeHome() IDE_HOME} was not found.
599
   */
600
  SystemPath getPath();
601

602
  /**
603
   * @return a new {@link ProcessContext} to {@link ProcessContext#run() run} external commands.
604
   */
605
  ProcessContext newProcess();
606

607
  /**
608
   * @param title the {@link IdeProgressBar#getTitle() title}.
609
   * @param size the {@link IdeProgressBar#getMaxSize() expected maximum size}.
610
   * @param unitName the {@link IdeProgressBar#getUnitName() unit name}.
611
   * @param unitSize the {@link IdeProgressBar#getUnitSize() unit size}.
612
   * @return the new {@link IdeProgressBar} to use.
613
   */
614
  IdeProgressBar newProgressBar(String title, long size, String unitName, long unitSize);
615

616
  /**
617
   * @param title the {@link IdeProgressBar#getTitle() title}.
618
   * @param size the {@link IdeProgressBar#getMaxSize() expected maximum size} in bytes.
619
   * @return the new {@link IdeProgressBar} to use.
620
   */
621
  default IdeProgressBar newProgressBarInMib(String title, long size) {
622

623
    if ((size > 0) && (size < 1024)) {
8✔
624
      return new IdeProgressBarNone(title, size, IdeProgressBar.UNIT_NAME_MB, IdeProgressBar.UNIT_SIZE_MB);
8✔
625
    }
626
    return newProgressBar(title, size, IdeProgressBar.UNIT_NAME_MB, IdeProgressBar.UNIT_SIZE_MB);
7✔
627
  }
628

629
  /**
630
   * @param size the {@link IdeProgressBar#getMaxSize() expected maximum size} in bytes.
631
   * @return the new {@link IdeProgressBar} for copy.
632
   */
633
  default IdeProgressBar newProgressBarForDownload(long size) {
634

635
    return newProgressBarInMib(IdeProgressBar.TITLE_DOWNLOADING, size);
5✔
636
  }
637

638
  /**
639
   * @param size the {@link IdeProgressBar#getMaxSize() expected maximum size} in bytes.
640
   * @return the new {@link IdeProgressBar} for extracting.
641
   */
642
  default IdeProgressBar newProgressbarForExtracting(long size) {
643

644
    return newProgressBarInMib(IdeProgressBar.TITLE_EXTRACTING, size);
5✔
645
  }
646

647
  /**
648
   * @param size the {@link IdeProgressBar#getMaxSize() expected maximum size} in bytes.
649
   * @return the new {@link IdeProgressBar} for copy.
650
   */
651
  default IdeProgressBar newProgressbarForCopying(long size) {
652

653
    return newProgressBarInMib(IdeProgressBar.TITLE_COPYING, size);
5✔
654
  }
655

656
  /**
657
   * @param size the {@link IdeProgressBar#getMaxSize() expected maximum} plugin count.
658
   * @return the new {@link IdeProgressBar} to use.
659
   */
660
  default IdeProgressBar newProgressBarForPlugins(long size) {
661
    return newProgressBar(IdeProgressBar.TITLE_INSTALL_PLUGIN, size, IdeProgressBar.UNIT_NAME_PLUGIN, IdeProgressBar.UNIT_SIZE_PLUGIN);
×
662
  }
663

664
  /**
665
   * @return the {@link DirectoryMerger} used to configure and merge the workspace for an {@link com.devonfw.tools.ide.tool.ide.IdeToolCommandlet IDE}.
666
   */
667
  DirectoryMerger getWorkspaceMerger();
668

669
  /**
670
   * @return the {@link Path} to the working directory from where the command is executed.
671
   */
672
  Path getDefaultExecutionDirectory();
673

674
  /**
675
   * @return the {@link IdeSystem} instance wrapping {@link System}.
676
   */
677
  IdeSystem getSystem();
678

679
  /**
680
   * @return the {@link GitContext} used to run several git commands.
681
   */
682
  GitContext getGitContext();
683

684
  /**
685
   * @return the String value for the variable MAVEN_ARGS, or null if called outside an IDEasy installation.
686
   */
687
  default String getMavenArgs() {
688

689
    if (getIdeHome() == null) {
3✔
690
      return null;
2✔
691
    }
692
    Mvn mvn = getCommandletManager().getCommandlet(Mvn.class);
6✔
693
    return mvn.getMavenArgs();
3✔
694
  }
695

696
  /**
697
   * @return the path for the variable GRADLE_USER_HOME, or null if called outside an IDEasy installation.
698
   */
699
  default Path getGradleUserHome() {
700

701
    if (getIdeHome() == null) {
3✔
702
      return null;
2✔
703
    }
704
    Gradle gradle = getCommandletManager().getCommandlet(Gradle.class);
6✔
705
    return gradle.getOrCreateGradleConfFolder();
3✔
706
  }
707

708
  /**
709
   * @return the {@link Path} pointing to the maven configuration directory (where "settings.xml" or "settings-security.xml" are located).
710
   */
711
  default Path getMavenConfigurationFolder() {
712

713
    if (getIdeHome() == null) {
3✔
714
      // fallback to USER_HOME/.m2 folder if called outside an IDEasy project
715
      return getUserHome().resolve(Mvn.MVN_CONFIG_LEGACY_FOLDER);
5✔
716
    }
717
    Mvn mvn = getCommandletManager().getCommandlet(Mvn.class);
6✔
718
    return mvn.getMavenConfigurationFolder();
3✔
719
  }
720

721
  /**
722
   * Updates the current working directory (CWD) and configures the environment paths according to the specified parameters. This method is central to changing
723
   * the IDE's notion of where it operates, affecting where configurations, workspaces, settings, and other resources are located or loaded from.
724
   *
725
   * @return the current {@link Step} of processing.
726
   */
727
  Step getCurrentStep();
728

729
  /**
730
   * @param name the {@link Step#getName() name} of the new {@link Step}.
731
   * @return the new {@link Step} that has been created and started.
732
   */
733
  default Step newStep(String name) {
734

735
    return newStep(name, Step.NO_PARAMS);
5✔
736
  }
737

738
  /**
739
   * @param name the {@link Step#getName() name} of the new {@link Step}.
740
   * @param parameters the {@link Step#getParameter(int) parameters} of the {@link Step}.
741
   * @return the new {@link Step} that has been created and started.
742
   */
743
  default Step newStep(String name, Object... parameters) {
744

745
    return newStep(false, name, parameters);
6✔
746
  }
747

748
  /**
749
   * @param silent the {@link Step#isSilent() silent flag}.
750
   * @param name the {@link Step#getName() name} of the new {@link Step}.
751
   * @param parameters the {@link Step#getParameter(int) parameters} of the {@link Step}.
752
   * @return the new {@link Step} that has been created and started.
753
   */
754
  Step newStep(boolean silent, String name, Object... parameters);
755

756
  /**
757
   * @param lambda the {@link Runnable} to {@link Runnable#run() run} while the {@link com.devonfw.tools.ide.log.IdeLogger logging} is entirely disabled.
758
   *     After this the logging will be enabled again. Collected log messages will then be logged at the end.
759
   */
760
  default void runWithoutLogging(Runnable lambda) {
761

762
    runWithoutLogging(lambda, IdeLogLevel.TRACE);
×
763
  }
×
764

765
  /**
766
   * @param lambda the {@link Runnable} to {@link Runnable#run() run} while the {@link com.devonfw.tools.ide.log.IdeLogger logging} is entirely disabled.
767
   *     After this the logging will be enabled again. Collected log messages will then be logged at the end.
768
   * @param threshold the {@link IdeLogLevel} to use as threshold for filtering logs while logging is disabled and log messages are collected. Use
769
   *     {@link IdeLogLevel#TRACE} to collect all logs and ensure nothing gets lost (will still not log anything that is generally not active in regular
770
   *     logging) and e.g. use {@link IdeLogLevel#ERROR} to discard all logs except errors.
771
   */
772
  void runWithoutLogging(Runnable lambda, IdeLogLevel threshold);
773

774
  /**
775
   * Updates the current working directory (CWD) and configures the environment paths according to the specified parameters. This method is central to changing
776
   * the IDE's notion of where it operates, affecting where configurations, workspaces, settings, and other resources are located or loaded from.
777
   *
778
   * @param ideHome The path to the IDE home directory.
779
   */
780
  default void setIdeHome(Path ideHome) {
781

782
    setCwd(ideHome, WORKSPACE_MAIN, ideHome);
5✔
783
  }
1✔
784

785
  /**
786
   * Updates the current working directory (CWD) and configures the environment paths according to the specified parameters. This method is central to changing
787
   * the IDE's notion of where it operates, affecting where configurations, workspaces, settings, and other resources are located or loaded from.
788
   *
789
   * @param userDir The path to set as the current working directory.
790
   * @param workspace The name of the workspace within the IDE's environment.
791
   * @param ideHome The path to the IDE home directory.
792
   */
793
  void setCwd(Path userDir, String workspace, Path ideHome);
794

795
  /**
796
   * Finds the path to the Bash executable.
797
   *
798
   * @return the {@link Path} to the Bash executable, or {@code null} if Bash is not found.
799
   */
800
  Path findBash();
801

802
  /**
803
   * Finds the path to the Bash executable.
804
   *
805
   * @return the {@link Path} to the Bash executable. Throws a {@link CliException} if no bash was found.
806
   */
807
  default Path findBashRequired() {
808
    Path bash = findBash();
3✔
809
    if (bash == null) {
2!
810
      String message = "Bash " + IS_NOT_INSTALLED_BUT_REQUIRED;
×
811
      if (getSystemInfo().isWindows()) {
×
812
        message += " " + PLEASE_DOWNLOAD_AND_INSTALL_GIT + ":\n " + WINDOWS_GIT_DOWNLOAD_URL;
×
813
        throw new CliException(message);
×
814
      }
815
      bash = Path.of("bash");
×
816
    }
817

818
    return bash;
2✔
819
  }
820

821
  /**
822
   * @return the {@link WindowsPathSyntax} used for {@link Path} conversion or {@code null} for no such conversion (typically if not on Windows).
823
   */
824
  WindowsPathSyntax getPathSyntax();
825

826
  /**
827
   * logs the status of {@link #getIdeHome() IDE_HOME} and {@link #getIdeRoot() IDE_ROOT}.
828
   */
829
  void logIdeHomeAndRootStatus();
830

831
  /**
832
   * @param version the {@link VersionIdentifier} to write.
833
   * @param installationPath the {@link Path directory} where to write the version to a {@link #FILE_SOFTWARE_VERSION version file}.
834
   */
835
  void writeVersionFile(VersionIdentifier version, Path installationPath);
836

837
  /**
838
   * Verifies that current {@link IdeVersion} satisfies {@link IdeVariables#IDE_MIN_VERSION}.
839
   *
840
   * @param throwException whether to throw a {@link CliException} or just log a warning.
841
   */
842
  void verifyIdeMinVersion(boolean throwException);
843

844
  /**
845
   * @return the path for the variable COREPACK_HOME, or null if called outside an IDEasy installation.
846
   */
847
  default Path getCorePackHome() {
848
    if (getIdeHome() == null) {
×
849
      return null;
×
850
    }
851
    Corepack corepack = getCommandletManager().getCommandlet(Corepack.class);
×
852
    return corepack.getOrCreateCorepackHomeFolder();
×
853
  }
854

855
  /**
856
   * @return the path for the variable NPM_CONFIG_USERCONFIG, or null if called outside an IDEasy installation.
857
   */
858
  default Path getNpmConfigUserConfig() {
859
    if (getIdeHome() == null) {
3✔
860
      return null;
2✔
861
    }
862
    Npm npm = getCommandletManager().getCommandlet(Npm.class);
6✔
863
    return npm.getOrCreateNpmConfigUserConfig();
3✔
864
  }
865

866
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc