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

devonfw / IDEasy / 29098863710

10 Jul 2026 02:11PM UTC coverage: 72.291% (+0.07%) from 72.225%
29098863710

Pull #2149

github

web-flow
Merge cab6001a3 into 365f379a1
Pull Request #2149: #2102 set ideRoot during msi installation correctly

4887 of 7458 branches covered (65.53%)

Branch coverage included in aggregate %.

12585 of 16711 relevant lines covered (75.31%)

3.19 hits per line

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

77.78
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.tool.uv.UvRepository;
35
import com.devonfw.tools.ide.url.model.UrlMetadata;
36
import com.devonfw.tools.ide.variable.IdeVariables;
37
import com.devonfw.tools.ide.version.IdeVersion;
38
import com.devonfw.tools.ide.version.VersionIdentifier;
39

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

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

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

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

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

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

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

85
  /**
86
   * 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,
87
   * maven filtering, .gitignore and to distinguish from {@link #FOLDER_DOT_IDE}.
88
   *
89
   * @see #getIdePath()
90
   */
91
  String FOLDER_UNDERSCORE_IDE = "_ide";
92

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

161
  /**
162
   * The name of the update folder inside the {@link #FOLDER_WORKSPACE workspace} folder containing the templates for the configuration templates for the update
163
   * 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
164
   * 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
165
   * for indentation and other code-formatting settings. If all developers in a project team use the same formatter settings, this will actively prevent
166
   * 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
167
   * 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
168
   * 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
169
   * user as needed.
170
   */
171
  String FOLDER_UPDATE = "update";
172

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

255
  /**
256
   * Asks the user for a single string input.
257
   *
258
   * @param message The information message to display.
259
   * @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.
260
   * @return The string input from the user, or the default value if no input is provided.
261
   */
262
  String askForInput(String message, String defaultValue);
263

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

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

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

289
  /**
290
   * @param <O> type of the option. E.g. {@link String}.
291
   * @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.
292
   * @param question the question to ask.
293
   * @return the option selected by the user as answer.
294
   */
295
  @SuppressWarnings("unchecked")
296
  <O> O question(O[] options, String question, Object... args);
297

298
  /**
299
   * 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
300
   * exception is thrown to abort further processing.
301
   *
302
   * @param questionTemplate the yes/no question to {@link #question(String, Object...) ask}.
303
   * @param args the arguments to fill the placeholders in the question template.
304
   * @throws CliAbortException if the user answered with "no" and further processing shall be aborted.
305
   */
306
  default void askToContinue(String questionTemplate, Object... args) {
307
    boolean yesContinue = question(questionTemplate, args);
5✔
308
    if (!yesContinue) {
2!
309
      throw new CliAbortException();
×
310
    }
311
  }
1✔
312

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

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

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

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

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

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

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

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

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

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

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

376
  /**
377
   * @return the {@link UvRepository}.
378
   */
379
  UvRepository getUvRepository();
380

381
  /**
382
   * @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
383
   *     isolated projects.
384
   * @see com.devonfw.tools.ide.variable.IdeVariables#IDE_HOME
385
   */
386
  Path getIdeHome();
387

388
  /**
389
   * @return the name of the current project.
390
   * @see com.devonfw.tools.ide.variable.IdeVariables#PROJECT_NAME
391
   */
392
  String getProjectName();
393

394
  /**
395
   * @return the IDEasy version the {@link #getIdeHome() current project} was created with or migrated to.
396
   */
397
  VersionIdentifier getProjectVersion();
398

399
  /**
400
   * @param version the new value of {@link #getProjectVersion()}.
401
   */
402
  void setProjectVersion(VersionIdentifier version);
403

404
  /**
405
   * @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
406
   *     sub-folder. There is a reserved ".ide" folder where central IDE data is stored such as the {@link #getUrlsPath() download metadata} and the central
407
   *     software repository.
408
   * @see com.devonfw.tools.ide.variable.IdeVariables#IDE_ROOT
409
   */
410
  Path getIdeRoot();
411

412
  /**
413
   * @param ideRoot the new value of {@link #getIdeRoot() IDE_ROOT}. Typically detected automatically from the environment and working directory, but may need
414
   *     to be set explicitly (e.g. during the initial installation where the {@code IDE_ROOT} environment variable is not yet available but the install target
415
   *     is already known).
416
   */
417
  void setIdeRoot(Path ideRoot);
418

419
  /**
420
   * @return the {@link Path} to the {@link #FOLDER_UNDERSCORE_IDE}.
421
   * @see #getIdeRoot()
422
   * @see #FOLDER_UNDERSCORE_IDE
423
   */
424
  Path getIdePath();
425

426
  /**
427
   * @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
428
   *     upgrade a new release is installed and the link is switched to the new release.
429
   */
430
  default Path getIdeInstallationPath() {
431

432
    Path idePath = getIdePath();
3✔
433
    if (idePath == null) {
2!
434
      return null;
×
435
    }
436
    return idePath.resolve(FOLDER_INSTALLATION);
4✔
437
  }
438

439
  /**
440
   * @return the current working directory ("user.dir"). This is the directory where the user's shell was located when the IDE CLI was invoked.
441
   */
442
  Path getCwd();
443

444
  /**
445
   * @return the {@link Path} for the temporary directory to use. Will be different from the OS specific temporary directory (java.io.tmpDir).
446
   */
447
  Path getTempPath();
448

449
  /**
450
   * @return the {@link Path} for the temporary download directory to use.
451
   */
452
  Path getTempDownloadPath();
453

454
  /**
455
   * @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
456
   *     download tools.
457
   * @see com.devonfw.tools.ide.url.model.folder.UrlRepository
458
   */
459
  Path getUrlsPath();
460

461
  /**
462
   * @return the {@link UrlMetadata}. Will be lazily instantiated and thereby automatically be cloned or pulled (by default).
463
   */
464
  UrlMetadata getUrls();
465

466
  /**
467
   * @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
468
   *     the same artifact is requested again it will be taken from the cache to avoid downloading it again.
469
   */
470
  Path getDownloadPath();
471

472
  /**
473
   * @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
474
   *     {@link #getSoftwareRepositoryPath() software repository} as sub-folder named after the according tool.
475
   */
476
  Path getSoftwarePath();
477

478
  /**
479
   * @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
480
   *     here from the {@link #getSoftwareRepositoryPath() software repository} as sub-folder named after the according tool.
481
   */
482
  Path getSoftwareExtraPath();
483

484
  /**
485
   * @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
486
   *     are shared among all IDE instances (see {@link #getIdeHome() IDE_HOME}) via symbolic links (see {@link #getSoftwarePath()}). Therefore this repository
487
   *     follows the sub-folder structure {@code «repository»/«tool»/«edition»/«version»/}. So multiple versions of the same tool exist here as different
488
   *     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
489
   *     of the scope of this folders.
490
   */
491
  Path getSoftwareRepositoryPath();
492

493
  /**
494
   * @return the {@link Path} to the {@link #FOLDER_PLUGINS plugins folder} inside {@link #getIdeHome() IDE_HOME}. All plugins of the IDE instance will be
495
   *     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.
496
   */
497
  Path getPluginsPath();
498

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

508
  /**
509
   * @return the {@link Path} to the users home directory. Typically initialized via the {@link System#getProperty(String) system property} "user.home".
510
   * @see com.devonfw.tools.ide.variable.IdeVariables#HOME
511
   */
512
  Path getUserHome();
513

514
  /**
515
   * @return the {@link Path} to the ".ide" subfolder in the {@link #getUserHome() users home directory}.
516
   */
517
  Path getUserHomeIde();
518

519
  /**
520
   * @return the {@link Path} to the {@link #FOLDER_SETTINGS settings} folder with the cloned git repository containing the project configuration.
521
   */
522
  Path getSettingsPath();
523

524
  /**
525
   * @return the {@link Path} to the {@link #FOLDER_REPOSITORIES repositories} folder with legacy fallback if not present or {@code null} if not found.
526
   */
527
  default Path getRepositoriesPath() {
528

529
    Path settingsPath = getSettingsPath();
3✔
530
    if (settingsPath == null) {
2!
531
      return null;
×
532
    }
533
    Path repositoriesPath = settingsPath.resolve(IdeContext.FOLDER_REPOSITORIES);
4✔
534
    if (Files.isDirectory(repositoriesPath)) {
5✔
535
      return repositoriesPath;
2✔
536
    }
537
    Path legacyRepositoriesPath = settingsPath.resolve(IdeContext.FOLDER_LEGACY_REPOSITORIES);
4✔
538
    if (Files.isDirectory(legacyRepositoriesPath)) {
5!
539
      return legacyRepositoriesPath;
×
540
    }
541
    return null;
2✔
542
  }
543

544
  /**
545
   * @return the {@link Path} to the {@code settings} folder with the cloned git repository containing the project configuration only if the settings repository
546
   *     is in fact a git repository.
547
   */
548
  Path getSettingsGitRepository();
549

550
  /**
551
   * @return {@code true} if the settings repository is a symlink or a junction to a code-repository.
552
   */
553
  boolean isSettingsCodeRepository();
554

555
  /**
556
   * @return the {@link Path} to the file containing the last tracked commit Id of the settings repository.
557
   */
558
  Path getSettingsCommitIdPath();
559

560
  /**
561
   * @return the {@link Path} to the templates folder inside the {@link #getSettingsPath() settings}. The relative directory structure in this templates folder
562
   *     is to be applied to {@link #getIdeHome() IDE_HOME} when the project is set up.
563
   */
564
  default Path getSettingsTemplatePath() {
565
    Path settingsFolder = getSettingsPath();
3✔
566
    Path templatesFolder = settingsFolder.resolve(IdeContext.FOLDER_TEMPLATES);
4✔
567
    if (!Files.isDirectory(templatesFolder)) {
5✔
568
      Path templatesFolderLegacy = settingsFolder.resolve(IdeContext.FOLDER_LEGACY_TEMPLATES);
4✔
569
      if (Files.isDirectory(templatesFolderLegacy)) {
5!
570
        templatesFolder = templatesFolderLegacy;
×
571
      } else {
572
        AbstractIdeContext.LOG.warn("No templates found in settings git repo neither in {} nor in {} - configuration broken", templatesFolder,
5✔
573
            templatesFolderLegacy);
574
        return null;
2✔
575
      }
576
    }
577
    return templatesFolder;
2✔
578
  }
579

580
  /**
581
   * @return the {@link Path} to the {@code conf} folder with instance specific tool configurations and the
582
   *     {@link EnvironmentVariablesType#CONF user specific project configuration}.
583
   */
584
  Path getConfPath();
585

586
  /**
587
   * @return the {@link Path} to the workspaces base folder containing the individual {@link #getWorkspacePath(String) workspaces}.
588
   * @see #getWorkspacePath(String)
589
   */
590
  Path getWorkspacesBasePath();
591

592
  /**
593
   * @return the {@link Path} to the workspace.
594
   * @see #getWorkspaceName()
595
   */
596
  Path getWorkspacePath();
597

598
  /**
599
   * @param workspace the specific workspace name.
600
   * @return the {@link Path} to the specified workspace.
601
   */
602
  Path getWorkspacePath(String workspace);
603

604
  /**
605
   * @return the name of the workspace. Defaults to {@link #WORKSPACE_MAIN}.
606
   */
607
  String getWorkspaceName();
608

609
  /**
610
   * @return the value of the system {@link IdeVariables#PATH PATH} variable. It is automatically extended according to the tools available in
611
   *     {@link #getSoftwarePath() software path} unless {@link #getIdeHome() IDE_HOME} was not found.
612
   */
613
  SystemPath getPath();
614

615
  /**
616
   * @return a new {@link ProcessContext} to {@link ProcessContext#run() run} external commands.
617
   */
618
  ProcessContext newProcess();
619

620
  /**
621
   * @param title the {@link IdeProgressBar#getTitle() title}.
622
   * @param size the {@link IdeProgressBar#getMaxSize() expected maximum size}.
623
   * @param unitName the {@link IdeProgressBar#getUnitName() unit name}.
624
   * @param unitSize the {@link IdeProgressBar#getUnitSize() unit size}.
625
   * @return the new {@link IdeProgressBar} to use.
626
   */
627
  IdeProgressBar newProgressBar(String title, long size, String unitName, long unitSize);
628

629
  /**
630
   * @param title the {@link IdeProgressBar#getTitle() title}.
631
   * @param size the {@link IdeProgressBar#getMaxSize() expected maximum size} in bytes.
632
   * @return the new {@link IdeProgressBar} to use.
633
   */
634
  default IdeProgressBar newProgressBarInMib(String title, long size) {
635

636
    if ((size > 0) && (size < 1024)) {
8✔
637
      return new IdeProgressBarNone(title, size, IdeProgressBar.UNIT_NAME_MB, IdeProgressBar.UNIT_SIZE_MB);
8✔
638
    }
639
    return newProgressBar(title, size, IdeProgressBar.UNIT_NAME_MB, IdeProgressBar.UNIT_SIZE_MB);
7✔
640
  }
641

642
  /**
643
   * @param size the {@link IdeProgressBar#getMaxSize() expected maximum size} in bytes.
644
   * @return the new {@link IdeProgressBar} for copy.
645
   */
646
  default IdeProgressBar newProgressBarForDownload(long size) {
647

648
    return newProgressBarInMib(IdeProgressBar.TITLE_DOWNLOADING, size);
5✔
649
  }
650

651
  /**
652
   * @param size the {@link IdeProgressBar#getMaxSize() expected maximum size} in bytes.
653
   * @return the new {@link IdeProgressBar} for extracting.
654
   */
655
  default IdeProgressBar newProgressbarForExtracting(long size) {
656

657
    return newProgressBarInMib(IdeProgressBar.TITLE_EXTRACTING, size);
5✔
658
  }
659

660
  /**
661
   * @param size the {@link IdeProgressBar#getMaxSize() expected maximum size} in bytes.
662
   * @return the new {@link IdeProgressBar} for copy.
663
   */
664
  default IdeProgressBar newProgressbarForCopying(long size) {
665

666
    return newProgressBarInMib(IdeProgressBar.TITLE_COPYING, size);
5✔
667
  }
668

669
  /**
670
   * @param size the {@link IdeProgressBar#getMaxSize() expected maximum} plugin count.
671
   * @return the new {@link IdeProgressBar} to use.
672
   */
673
  default IdeProgressBar newProgressBarForPlugins(long size) {
674
    return newProgressBar(IdeProgressBar.TITLE_INSTALL_PLUGIN, size, IdeProgressBar.UNIT_NAME_PLUGIN, IdeProgressBar.UNIT_SIZE_PLUGIN);
7✔
675
  }
676

677
  /**
678
   * @return the {@link DirectoryMerger} used to configure and merge the workspace for an {@link com.devonfw.tools.ide.tool.ide.IdeToolCommandlet IDE}.
679
   */
680
  DirectoryMerger getWorkspaceMerger();
681

682
  /**
683
   * @return the {@link Path} to the working directory from where the command is executed.
684
   */
685
  Path getDefaultExecutionDirectory();
686

687
  /**
688
   * @return the {@link IdeSystem} instance wrapping {@link System}.
689
   */
690
  IdeSystem getSystem();
691

692
  /**
693
   * @return the {@link GitContext} used to run several git commands.
694
   */
695
  GitContext getGitContext();
696

697
  /**
698
   * @return the String value for the variable MAVEN_ARGS, or null if called outside an IDEasy installation.
699
   */
700
  default String getMavenArgs() {
701

702
    if (getIdeHome() == null) {
3✔
703
      return null;
2✔
704
    }
705
    Mvn mvn = getCommandletManager().getCommandlet(Mvn.class);
6✔
706
    return mvn.getMavenArgs();
3✔
707
  }
708

709
  /**
710
   * @return the path for the variable GRADLE_USER_HOME, or null if called outside an IDEasy installation.
711
   */
712
  default Path getGradleUserHome() {
713

714
    if (getIdeHome() == null) {
3✔
715
      return null;
2✔
716
    }
717
    Gradle gradle = getCommandletManager().getCommandlet(Gradle.class);
6✔
718
    return gradle.getOrCreateGradleConfFolder();
3✔
719
  }
720

721
  /**
722
   * @return the {@link Path} pointing to the maven configuration directory (where "settings.xml" or "settings-security.xml" are located).
723
   */
724
  default Path getMavenConfigurationFolder() {
725

726
    if (getIdeHome() == null) {
3✔
727
      // fallback to USER_HOME/.m2 folder if called outside an IDEasy project
728
      return getUserHome().resolve(Mvn.MVN_CONFIG_LEGACY_FOLDER);
5✔
729
    }
730
    Mvn mvn = getCommandletManager().getCommandlet(Mvn.class);
6✔
731
    return mvn.getMavenConfigurationFolder();
3✔
732
  }
733

734
  /**
735
   * Updates the current working directory (CWD) and configures the environment paths according to the specified parameters. This method is central to changing
736
   * the IDE's notion of where it operates, affecting where configurations, workspaces, settings, and other resources are located or loaded from.
737
   *
738
   * @return the current {@link Step} of processing.
739
   */
740
  Step getCurrentStep();
741

742
  /**
743
   * @param name the {@link Step#getName() name} of the new {@link Step}.
744
   * @return the new {@link Step} that has been created and started.
745
   */
746
  default Step newStep(String name) {
747

748
    return newStep(name, Step.NO_PARAMS);
5✔
749
  }
750

751
  /**
752
   * @param name the {@link Step#getName() name} of the new {@link Step}.
753
   * @param parameters the {@link Step#getParameter(int) parameters} of the {@link Step}.
754
   * @return the new {@link Step} that has been created and started.
755
   */
756
  default Step newStep(String name, Object... parameters) {
757

758
    return newStep(false, name, parameters);
6✔
759
  }
760

761
  /**
762
   * @param silent the {@link Step#isSilent() silent flag}.
763
   * @param name the {@link Step#getName() name} of the new {@link Step}.
764
   * @param parameters the {@link Step#getParameter(int) parameters} of the {@link Step}.
765
   * @return the new {@link Step} that has been created and started.
766
   */
767
  Step newStep(boolean silent, String name, Object... parameters);
768

769
  /**
770
   * @param lambda the {@link Runnable} to {@link Runnable#run() run} while the {@link com.devonfw.tools.ide.log.IdeLogger logging} is entirely disabled.
771
   *     After this the logging will be enabled again. Collected log messages will then be logged at the end.
772
   */
773
  default void runWithoutLogging(Runnable lambda) {
774

775
    runWithoutLogging(lambda, IdeLogLevel.TRACE);
4✔
776
  }
1✔
777

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

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

795
    setCwd(ideHome, WORKSPACE_MAIN, ideHome);
5✔
796
  }
1✔
797

798
  /**
799
   * Updates the current working directory (CWD) and configures the environment paths according to the specified parameters. This method is central to changing
800
   * the IDE's notion of where it operates, affecting where configurations, workspaces, settings, and other resources are located or loaded from.
801
   *
802
   * @param userDir The path to set as the current working directory.
803
   * @param workspace The name of the workspace within the IDE's environment.
804
   * @param ideHome The path to the IDE home directory.
805
   */
806
  void setCwd(Path userDir, String workspace, Path ideHome);
807

808
  /**
809
   * Finds the path to the Bash executable.
810
   *
811
   * @return the {@link Path} to the Bash executable, or {@code null} if Bash is not found.
812
   */
813
  Path findBash();
814

815
  /**
816
   * Finds the path to the Bash executable.
817
   *
818
   * @return the {@link Path} to the Bash executable. Throws a {@link CliException} if no bash was found.
819
   */
820
  default Path findBashRequired() {
821
    Path bash = findBash();
3✔
822
    if (bash == null) {
2!
823
      String message = "Bash " + IS_NOT_INSTALLED_BUT_REQUIRED;
×
824
      if (getSystemInfo().isWindows()) {
×
825
        message += " " + PLEASE_DOWNLOAD_AND_INSTALL_GIT + ":\n " + WINDOWS_GIT_DOWNLOAD_URL;
×
826
        throw new CliException(message);
×
827
      }
828
      bash = Path.of("bash");
×
829
    }
830

831
    return bash;
2✔
832
  }
833

834
  /**
835
   * @return the {@link WindowsPathSyntax} used for {@link Path} conversion or {@code null} for no such conversion (typically if not on Windows).
836
   */
837
  WindowsPathSyntax getPathSyntax();
838

839
  /**
840
   * logs the status of {@link #getIdeHome() IDE_HOME} and {@link #getIdeRoot() IDE_ROOT}.
841
   */
842
  void logIdeHomeAndRootStatus();
843

844
  /**
845
   * @param version the {@link VersionIdentifier} to write.
846
   * @param installationPath the {@link Path directory} where to write the version to a {@link #FILE_SOFTWARE_VERSION version file}.
847
   */
848
  void writeVersionFile(VersionIdentifier version, Path installationPath);
849

850
  /**
851
   * Verifies that current {@link IdeVersion} satisfies {@link IdeVariables#IDE_MIN_VERSION}.
852
   *
853
   * @param throwException whether to throw a {@link CliException} or just log a warning.
854
   */
855
  void verifyIdeMinVersion(boolean throwException);
856

857
  /**
858
   * @return the path for the variable COREPACK_HOME, or null if called outside an IDEasy installation.
859
   */
860
  default Path getCorePackHome() {
861
    if (getIdeHome() == null) {
×
862
      return null;
×
863
    }
864
    Corepack corepack = getCommandletManager().getCommandlet(Corepack.class);
×
865
    return corepack.getOrCreateCorepackHomeFolder();
×
866
  }
867

868
  /**
869
   * @return the path for the variable NPM_CONFIG_USERCONFIG, or null if called outside an IDEasy installation.
870
   */
871
  default Path getNpmConfigUserConfig() {
872
    if (getIdeHome() == null) {
3✔
873
      return null;
2✔
874
    }
875
    Npm npm = getCommandletManager().getCommandlet(Npm.class);
6✔
876
    return npm.getOrCreateNpmConfigUserConfig();
3✔
877
  }
878

879
}
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