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

devonfw / IDEasy / 15142420580

20 May 2025 04:04PM UTC coverage: 67.846% (+0.2%) from 67.695%
15142420580

Pull #1318

github

web-flow
Merge 44f97aa8f into 0062654bb
Pull Request #1318: #1314: add IdeContext.runWithoutLogging to temporary disable logging

3114 of 4996 branches covered (62.33%)

Branch coverage included in aggregate %.

8012 of 11403 relevant lines covered (70.26%)

3.07 hits per line

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

67.27
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.os.SystemInfo;
21
import com.devonfw.tools.ide.os.WindowsPathSyntax;
22
import com.devonfw.tools.ide.process.ProcessContext;
23
import com.devonfw.tools.ide.step.Step;
24
import com.devonfw.tools.ide.tool.mvn.Mvn;
25
import com.devonfw.tools.ide.tool.repository.CustomToolRepository;
26
import com.devonfw.tools.ide.tool.repository.MavenRepository;
27
import com.devonfw.tools.ide.tool.repository.ToolRepository;
28
import com.devonfw.tools.ide.url.model.UrlMetadata;
29
import com.devonfw.tools.ide.variable.IdeVariables;
30
import com.devonfw.tools.ide.version.IdeVersion;
31
import com.devonfw.tools.ide.version.VersionIdentifier;
32

33
/**
34
 * Interface for interaction with the user allowing to input and output information.
35
 */
36
public interface IdeContext extends IdeStartContext {
37

38
  /**
39
   * The default settings URL.
40
   *
41
   * @see com.devonfw.tools.ide.commandlet.AbstractUpdateCommandlet
42
   */
43
  String DEFAULT_SETTINGS_REPO_URL = "https://github.com/devonfw/ide-settings.git";
44

45
  /** The name of the workspaces folder. */
46
  String FOLDER_WORKSPACES = "workspaces";
47

48
  /** The name of the {@link #getSettingsPath() settings} folder. */
49
  String FOLDER_SETTINGS = "settings";
50

51
  /** The name of the {@link #getSoftwarePath() software} folder. */
52
  String FOLDER_SOFTWARE = "software";
53

54
  /** The name of the {@link #getUrlsPath() urls} folder. */
55
  String FOLDER_URLS = "urls";
56

57
  /** The name of the conf folder for project specific user configurations. */
58
  String FOLDER_CONF = "conf";
59

60
  /**
61
   * 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,
62
   * maven filtering, .gitignore and to distinguish from {@link #FOLDER_DOT_IDE}.
63
   *
64
   * @see #getIdePath()
65
   */
66
  String FOLDER_UNDERSCORE_IDE = "_ide";
67

68
  /**
69
   * The name of the folder inside {@link #FOLDER_UNDERSCORE_IDE} with the current IDEasy installation.
70
   *
71
   * @see #getIdeInstallationPath()
72
   */
73
  String FOLDER_INSTALLATION = "installation";
74

75
  /**
76
   * The name of the hidden folder for IDE configuration in the users home directory or status information in the IDE_HOME directory.
77
   *
78
   * @see #getUserHomeIde()
79
   */
80
  String FOLDER_DOT_IDE = ".ide";
81

82
  /** The name of the updates folder for temporary data and backup. */
83
  String FOLDER_UPDATES = "updates";
84

85
  /** The name of the volume folder for mounting archives like *.dmg. */
86
  String FOLDER_VOLUME = "volume";
87

88
  /** The name of the backups folder for backup. */
89
  String FOLDER_BACKUPS = "backups";
90

91
  /** The name of the downloads folder. */
92
  String FOLDER_DOWNLOADS = "Downloads";
93

94
  /** The name of the bin folder where executable files are found by default. */
95
  String FOLDER_BIN = "bin";
96

97
  /** The name of the repositories folder where properties files are stores for each repository */
98
  String FOLDER_REPOSITORIES = "repositories";
99

100
  /** The name of the repositories folder where properties files are stores for each repository */
101
  String FOLDER_LEGACY_REPOSITORIES = "projects";
102

103
  /** The name of the Contents folder inside a MacOS app. */
104
  String FOLDER_CONTENTS = "Contents";
105

106
  /** The name of the Resources folder inside a MacOS app. */
107
  String FOLDER_RESOURCES = "Resources";
108

109
  /** The name of the app folder inside a MacOS app. */
110
  String FOLDER_APP = "app";
111

112
  /** The name of the extra folder inside the software folder */
113
  String FOLDER_EXTRA = "extra";
114

115
  /**
116
   * The name of the {@link #getPluginsPath() plugins folder} and also the plugins folder inside the IDE folders of {@link #getSettingsPath() settings} (e.g.
117
   * settings/eclipse/plugins).
118
   */
119
  String FOLDER_PLUGINS = "plugins";
120

121
  /**
122
   * The name of the workspace folder inside the IDE specific {@link #FOLDER_SETTINGS settings} containing the configuration templates in #FOLDER_SETUP
123
   * #FOLDER_UPDATE.
124
   */
125
  String FOLDER_WORKSPACE = "workspace";
126

127
  /**
128
   * The name of the setup folder inside the {@link #FOLDER_WORKSPACE workspace} folder containing the templates for the configuration templates for the initial
129
   * setup of a workspace. This is closely related with the {@link #FOLDER_UPDATE update} folder.
130
   */
131
  String FOLDER_SETUP = "setup";
132

133
  /**
134
   * The name of the update folder inside the {@link #FOLDER_WORKSPACE workspace} folder containing the templates for the configuration templates for the update
135
   * 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
136
   * 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
137
   * for indentation and other code-formatting settings. If all developers in a project team use the same formatter settings, this will actively prevent
138
   * 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
139
   * 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
140
   * 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
141
   * user as needed.
142
   */
143
  String FOLDER_UPDATE = "update";
144

145
  /**
146
   * The name of the folder inside {@link #FOLDER_UNDERSCORE_IDE _ide} folder containing internal resources and scripts of IDEasy.
147
   */
148
  String FOLDER_INTERNAL = "internal";
149

150
  /** The file where the installed software version is written to as plain text. */
151
  String FILE_SOFTWARE_VERSION = ".ide.software.version";
152

153
  /** The file where the installed software version is written to as plain text. */
154
  String FILE_LEGACY_SOFTWARE_VERSION = ".devon.software.version";
155

156
  /** The file for the license agreement. */
157
  String FILE_LICENSE_AGREEMENT = ".license.agreement";
158

159
  /** The file extension for a {@link java.util.Properties} file. */
160
  String EXT_PROPERTIES = ".properties";
161

162
  /** The default for {@link #getWorkspaceName()}. */
163
  String WORKSPACE_MAIN = "main";
164

165
  /** The folder with the configuration template files from the settings. */
166
  String FOLDER_TEMPLATES = "templates";
167

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

171
  /** The default folder name for {@link #getIdeRoot() IDE_ROOT}. */
172
  String FOLDER_PROJECTS = "projects";
173

174
  /** The filename of the configuration file in the settings for this {@link CustomToolRepository}. */
175
  String FILE_CUSTOM_TOOLS = "ide-custom-tools.json";
176

177
  /**
178
   * file containing the current local commit hash of the settings repository.
179
   */
180
  String SETTINGS_COMMIT_ID = ".commit.id";
181

182
  /** The IDEasy ASCII logo. */
183
  String LOGO = """
4✔
184
      __       ___ ___  ___
185
      ╲ ╲     |_ _|   ╲| __|__ _ ____ _
186
       > >     | || |) | _|/ _` (_-< || |
187
      /_/ ___ |___|___/|___╲__,_/__/╲_, |
188
         |___|                       |__/
189
      """.replace('╲', '\\');
2✔
190

191
  /**
192
   * @return {@code true} if {@link #isOfflineMode() offline mode} is active or we are NOT {@link #isOnline() online}, {@code false} otherwise.
193
   */
194
  default boolean isOffline() {
195

196
    return isOfflineMode() || !isOnline();
10!
197
  }
198

199
  /**
200
   * @return {@code true} if we are currently online (Internet access is available), {@code false} otherwise.
201
   */
202
  boolean isOnline();
203

204
  /**
205
   * Print the IDEasy {@link #LOGO logo}.
206
   */
207
  default void printLogo() {
208

209
    info(LOGO);
3✔
210
  }
1✔
211

212
  /**
213
   * Asks the user for a single string input.
214
   *
215
   * @param message The information message to display.
216
   * @param defaultValue The default value to return when no input is provided.
217
   * @return The string input from the user, or the default value if no input is provided.
218
   */
219
  String askForInput(String message, String defaultValue);
220

221
  /**
222
   * Asks the user for a single string input.
223
   *
224
   * @param message The information message to display.
225
   * @return The string input from the user, or the default value if no input is provided.
226
   */
227
  String askForInput(String message);
228

229
  /**
230
   * @param question the question to ask.
231
   * @return {@code true} if the user answered with "yes", {@code false} otherwise ("no").
232
   */
233
  default boolean question(String question) {
234

235
    String yes = "yes";
×
236
    String option = question(question, yes, "no");
×
237
    if (yes.equals(option)) {
×
238
      return true;
×
239
    }
240
    return false;
×
241
  }
242

243
  /**
244
   * @param <O> type of the option. E.g. {@link String}.
245
   * @param question the question to ask.
246
   * @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.
247
   * @return the option selected by the user as answer.
248
   */
249
  @SuppressWarnings("unchecked")
250
  <O> O question(String question, O... options);
251

252
  /**
253
   * 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
254
   * exception is thrown to abort further processing.
255
   *
256
   * @param question the yes/no question to {@link #question(String) ask}.
257
   * @throws CliAbortException if the user answered with "no" and further processing shall be aborted.
258
   */
259
  default void askToContinue(String question) {
260

261
    boolean yesContinue = question(question);
×
262
    if (!yesContinue) {
×
263
      throw new CliAbortException();
×
264
    }
265
  }
×
266

267
  /**
268
   * @param purpose the purpose why Internet connection is required.
269
   * @throws CliException if you are {@link #isOffline() offline}.
270
   */
271
  default void requireOnline(String purpose) {
272

273
    if (isOfflineMode()) {
3!
274
      throw CliOfflineException.ofPurpose(purpose);
3✔
275
    }
276
  }
×
277

278
  /**
279
   * @return the {@link SystemInfo}.
280
   */
281
  SystemInfo getSystemInfo();
282

283
  /**
284
   * @return the {@link EnvironmentVariables} with full inheritance.
285
   */
286
  EnvironmentVariables getVariables();
287

288
  /**
289
   * @return the {@link FileAccess}.
290
   */
291
  FileAccess getFileAccess();
292

293
  /**
294
   * @return the {@link CommandletManager}.
295
   */
296
  CommandletManager getCommandletManager();
297

298
  /**
299
   * @return the default {@link ToolRepository}.
300
   */
301
  ToolRepository getDefaultToolRepository();
302

303
  /**
304
   * @return the {@link CustomToolRepository}.
305
   */
306
  CustomToolRepository getCustomToolRepository();
307

308
  /**
309
   * @return the {@link MavenRepository}.
310
   */
311
  MavenRepository getMavenToolRepository();
312

313
  /**
314
   * @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
315
   *     isolated projects.
316
   * @see com.devonfw.tools.ide.variable.IdeVariables#IDE_HOME
317
   */
318
  Path getIdeHome();
319

320
  /**
321
   * @return the name of the current project.
322
   * @see com.devonfw.tools.ide.variable.IdeVariables#PROJECT_NAME
323
   */
324
  String getProjectName();
325

326
  /**
327
   * @return the IDEasy version the {@link #getIdeHome() current project} was created with or migrated to.
328
   */
329
  VersionIdentifier getProjectVersion();
330

331
  /**
332
   * @param version the new value of {@link #getProjectVersion()}.
333
   */
334
  void setProjectVersion(VersionIdentifier version);
335

336
  /**
337
   * @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
338
   *     sub-folder. There is a reserved ".ide" folder where central IDE data is stored such as the {@link #getUrlsPath() download metadata} and the central
339
   *     software repository.
340
   * @see com.devonfw.tools.ide.variable.IdeVariables#IDE_ROOT
341
   */
342
  Path getIdeRoot();
343

344
  /**
345
   * @return the {@link Path} to the {@link #FOLDER_UNDERSCORE_IDE}.
346
   * @see #getIdeRoot()
347
   * @see #FOLDER_UNDERSCORE_IDE
348
   */
349
  Path getIdePath();
350

351
  /**
352
   * @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
353
   *     upgrade a new release is installed and the link is switched to the new release.
354
   */
355
  default Path getIdeInstallationPath() {
356

357
    return getIdePath().resolve(FOLDER_INSTALLATION);
×
358
  }
359

360
  /**
361
   * @return the current working directory ("user.dir"). This is the directory where the user's shell was located when the IDE CLI was invoked.
362
   */
363
  Path getCwd();
364

365
  /**
366
   * @return the {@link Path} for the temporary directory to use. Will be different from the OS specific temporary directory (java.io.tmpDir).
367
   */
368
  Path getTempPath();
369

370
  /**
371
   * @return the {@link Path} for the temporary download directory to use.
372
   */
373
  Path getTempDownloadPath();
374

375
  /**
376
   * @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
377
   *     download tools.
378
   * @see com.devonfw.tools.ide.url.model.folder.UrlRepository
379
   */
380
  Path getUrlsPath();
381

382
  /**
383
   * @return the {@link UrlMetadata}. Will be lazily instantiated and thereby automatically be cloned or pulled (by default).
384
   */
385
  UrlMetadata getUrls();
386

387
  /**
388
   * @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
389
   *     the same artifact is requested again it will be taken from the cache to avoid downloading it again.
390
   */
391
  Path getDownloadPath();
392

393
  /**
394
   * @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
395
   *     {@link #getSoftwareRepositoryPath() software repository} as sub-folder named after the according tool.
396
   */
397
  Path getSoftwarePath();
398

399
  /**
400
   * @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
401
   *     here from the {@link #getSoftwareRepositoryPath() software repository} as sub-folder named after the according tool.
402
   */
403
  Path getSoftwareExtraPath();
404

405
  /**
406
   * @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
407
   *     are shared among all IDE instances (see {@link #getIdeHome() IDE_HOME}) via symbolic links (see {@link #getSoftwarePath()}). Therefore this repository
408
   *     follows the sub-folder structure {@code «repository»/«tool»/«edition»/«version»/}. So multiple versions of the same tool exist here as different
409
   *     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
410
   *     of the scope of this folders.
411
   */
412
  Path getSoftwareRepositoryPath();
413

414
  /**
415
   * @return the {@link Path} to the {@link #FOLDER_PLUGINS plugins folder} inside {@link #getIdeHome() IDE_HOME}. All plugins of the IDE instance will be
416
   *     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.
417
   */
418
  Path getPluginsPath();
419

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

429
  /**
430
   * @return the {@link Path} to the users home directory. Typically initialized via the {@link System#getProperty(String) system property} "user.home".
431
   * @see com.devonfw.tools.ide.variable.IdeVariables#HOME
432
   */
433
  Path getUserHome();
434

435
  /**
436
   * @return the {@link Path} to the ".ide" subfolder in the {@link #getUserHome() users home directory}.
437
   */
438
  Path getUserHomeIde();
439

440
  /**
441
   * @return the {@link Path} to the {@link #FOLDER_SETTINGS settings} folder with the cloned git repository containing the project configuration.
442
   */
443
  Path getSettingsPath();
444

445
  /**
446
   * @return the {@link Path} to the {@link #FOLDER_REPOSITORIES repositories} folder with legacy fallback if not present or {@code null} if not found.
447
   */
448
  default Path getRepositoriesPath() {
449

450
    Path settingsPath = getSettingsPath();
3✔
451
    if (settingsPath == null) {
2!
452
      return null;
×
453
    }
454
    Path repositoriesPath = settingsPath.resolve(IdeContext.FOLDER_REPOSITORIES);
4✔
455
    if (Files.isDirectory(repositoriesPath)) {
5✔
456
      return repositoriesPath;
2✔
457
    }
458
    Path legacyRepositoriesPath = settingsPath.resolve(IdeContext.FOLDER_LEGACY_REPOSITORIES);
4✔
459
    if (Files.isDirectory(legacyRepositoriesPath)) {
5!
460
      return legacyRepositoriesPath;
×
461
    }
462
    return null;
2✔
463
  }
464

465
  /**
466
   * @return the {@link Path} to the {@code settings} folder with the cloned git repository containing the project configuration only if the settings repository
467
   *     is in fact a git repository.
468
   */
469
  Path getSettingsGitRepository();
470

471
  /**
472
   * @return {@code true} if the settings repository is a symlink or a junction.
473
   */
474
  boolean isSettingsRepositorySymlinkOrJunction();
475

476
  /**
477
   * @return the {@link Path} to the file containing the last tracked commit Id of the settings repository.
478
   */
479
  Path getSettingsCommitIdPath();
480

481
  /**
482
   * @return the {@link Path} to the templates folder inside the {@link #getSettingsPath() settings}. The relative directory structure in this templates folder
483
   *     is to be applied to {@link #getIdeHome() IDE_HOME} when the project is set up.
484
   */
485
  default Path getSettingsTemplatePath() {
486
    Path settingsFolder = getSettingsPath();
3✔
487
    Path templatesFolder = settingsFolder.resolve(IdeContext.FOLDER_TEMPLATES);
4✔
488
    if (!Files.isDirectory(templatesFolder)) {
5✔
489
      Path templatesFolderLegacy = settingsFolder.resolve(IdeContext.FOLDER_LEGACY_TEMPLATES);
4✔
490
      if (Files.isDirectory(templatesFolderLegacy)) {
5!
491
        templatesFolder = templatesFolderLegacy;
×
492
      } else {
493
        warning("No templates found in settings git repo neither in {} nor in {} - configuration broken", templatesFolder, templatesFolderLegacy);
13✔
494
        return null;
2✔
495
      }
496
    }
497
    return templatesFolder;
2✔
498
  }
499

500
  /**
501
   * @return the {@link Path} to the {@code conf} folder with instance specific tool configurations and the
502
   *     {@link EnvironmentVariablesType#CONF user specific project configuration}.
503
   */
504
  Path getConfPath();
505

506
  /**
507
   * @return the {@link Path} to the workspace.
508
   * @see #getWorkspaceName()
509
   */
510
  Path getWorkspacePath();
511

512
  /**
513
   * @return the name of the workspace. Defaults to {@link #WORKSPACE_MAIN}.
514
   */
515
  String getWorkspaceName();
516

517
  /**
518
   * @return the value of the system {@link IdeVariables#PATH PATH} variable. It is automatically extended according to the tools available in
519
   *     {@link #getSoftwarePath() software path} unless {@link #getIdeHome() IDE_HOME} was not found.
520
   */
521
  SystemPath getPath();
522

523
  /**
524
   * @return a new {@link ProcessContext} to {@link ProcessContext#run() run} external commands.
525
   */
526
  ProcessContext newProcess();
527

528
  /**
529
   * @param title the {@link IdeProgressBar#getTitle() title}.
530
   * @param size the {@link IdeProgressBar#getMaxSize() expected maximum size}.
531
   * @param unitName the {@link IdeProgressBar#getUnitName() unit name}.
532
   * @param unitSize the {@link IdeProgressBar#getUnitSize() unit size}.
533
   * @return the new {@link IdeProgressBar} to use.
534
   */
535
  IdeProgressBar newProgressBar(String title, long size, String unitName, long unitSize);
536

537
  /**
538
   * @param title the {@link IdeProgressBar#getTitle() title}.
539
   * @param size the {@link IdeProgressBar#getMaxSize() expected maximum size} in bytes.
540
   * @return the new {@link IdeProgressBar} to use.
541
   */
542
  default IdeProgressBar newProgressBarInMib(String title, long size) {
543

544
    if ((size > 0) && (size < 1024)) {
8✔
545
      return new IdeProgressBarNone(title, size, IdeProgressBar.UNIT_NAME_MB, IdeProgressBar.UNIT_SIZE_MB);
8✔
546
    }
547
    return newProgressBar(title, size, IdeProgressBar.UNIT_NAME_MB, IdeProgressBar.UNIT_SIZE_MB);
7✔
548
  }
549

550
  /**
551
   * @param size the {@link IdeProgressBar#getMaxSize() expected maximum size} in bytes.
552
   * @return the new {@link IdeProgressBar} for copy.
553
   */
554
  default IdeProgressBar newProgressBarForDownload(long size) {
555

556
    return newProgressBarInMib(IdeProgressBar.TITLE_DOWNLOADING, size);
5✔
557
  }
558

559
  /**
560
   * @param size the {@link IdeProgressBar#getMaxSize() expected maximum size} in bytes.
561
   * @return the new {@link IdeProgressBar} for extracting.
562
   */
563
  default IdeProgressBar newProgressbarForExtracting(long size) {
564

565
    return newProgressBarInMib(IdeProgressBar.TITLE_EXTRACTING, size);
5✔
566
  }
567

568
  /**
569
   * @param size the {@link IdeProgressBar#getMaxSize() expected maximum size} in bytes.
570
   * @return the new {@link IdeProgressBar} for copy.
571
   */
572
  default IdeProgressBar newProgressbarForCopying(long size) {
573

574
    return newProgressBarInMib(IdeProgressBar.TITLE_COPYING, size);
5✔
575
  }
576

577
  /**
578
   * @return the {@link DirectoryMerger} used to configure and merge the workspace for an {@link com.devonfw.tools.ide.tool.ide.IdeToolCommandlet IDE}.
579
   */
580
  DirectoryMerger getWorkspaceMerger();
581

582
  /**
583
   * @return the {@link Path} to the working directory from where the command is executed.
584
   */
585
  Path getDefaultExecutionDirectory();
586

587
  /**
588
   * @return the {@link IdeSystem} instance wrapping {@link System}.
589
   */
590
  IdeSystem getSystem();
591

592
  /**
593
   * @return the {@link GitContext} used to run several git commands.
594
   */
595
  GitContext getGitContext();
596

597
  /**
598
   * @return the String value for the variable MAVEN_ARGS, or null if called outside an IDEasy installation.
599
   */
600
  default String getMavenArgs() {
601

602
    if (getIdeHome() == null) {
3!
603
      return null;
×
604
    }
605
    Mvn mvn = getCommandletManager().getCommandlet(Mvn.class);
6✔
606
    return mvn.getMavenArgs();
3✔
607
  }
608

609
  /**
610
   * @return the {@link Path} pointing to the maven configuration directory (where "settings.xml" or "settings-security.xml" are located).
611
   */
612
  default Path getMavenConfigurationFolder() {
613

614
    Path confPath = getConfPath();
3✔
615
    Path mvnConfFolder = null;
2✔
616
    if (confPath != null) {
2✔
617
      mvnConfFolder = confPath.resolve(Mvn.MVN_CONFIG_FOLDER);
4✔
618
      if (!Files.isDirectory(mvnConfFolder)) {
5✔
619
        Path m2LegacyFolder = confPath.resolve(Mvn.MVN_CONFIG_LEGACY_FOLDER);
4✔
620
        if (Files.isDirectory(m2LegacyFolder)) {
5!
621
          mvnConfFolder = m2LegacyFolder;
×
622
        } else {
623
          mvnConfFolder = null; // see fallback below
2✔
624
        }
625
      }
626
    }
627
    if (mvnConfFolder == null) {
2✔
628
      // fallback to USER_HOME/.m2 folder
629
      mvnConfFolder = getUserHome().resolve(Mvn.MVN_CONFIG_LEGACY_FOLDER);
5✔
630
    }
631
    return mvnConfFolder;
2✔
632
  }
633

634
  /**
635
   * Updates the current working directory (CWD) and configures the environment paths according to the specified parameters. This method is central to changing
636
   * the IDE's notion of where it operates, affecting where configurations, workspaces, settings, and other resources are located or loaded from.
637
   *
638
   * @return the current {@link Step} of processing.
639
   */
640
  Step getCurrentStep();
641

642
  /**
643
   * @param name the {@link Step#getName() name} of the new {@link Step}.
644
   * @return the new {@link Step} that has been created and started.
645
   */
646
  default Step newStep(String name) {
647

648
    return newStep(name, Step.NO_PARAMS);
5✔
649
  }
650

651
  /**
652
   * @param name the {@link Step#getName() name} of the new {@link Step}.
653
   * @param parameters the {@link Step#getParameter(int) parameters} of the {@link Step}.
654
   * @return the new {@link Step} that has been created and started.
655
   */
656
  default Step newStep(String name, Object... parameters) {
657

658
    return newStep(false, name, parameters);
6✔
659
  }
660

661
  /**
662
   * @param silent the {@link Step#isSilent() silent flag}.
663
   * @param name the {@link Step#getName() name} of the new {@link Step}.
664
   * @param parameters the {@link Step#getParameter(int) parameters} of the {@link Step}.
665
   * @return the new {@link Step} that has been created and started.
666
   */
667
  Step newStep(boolean silent, String name, Object... parameters);
668

669
  /**
670
   * @param lambda the {@link Runnable} to {@link Runnable#run() run} while the {@link com.devonfw.tools.ide.log.IdeLogger logging} is entirely disabled.
671
   *     After this the logging will be enabled again. Collected log messages will then be logged at the end.
672
   */
673
  default void runWithoutLogging(Runnable lambda) {
674

675
    runWithoutLogging(lambda, IdeLogLevel.TRACE);
×
676
  }
×
677

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

687
  /**
688
   * Updates the current working directory (CWD) and configures the environment paths according to the specified parameters. This method is central to changing
689
   * the IDE's notion of where it operates, affecting where configurations, workspaces, settings, and other resources are located or loaded from.
690
   *
691
   * @param ideHome The path to the IDE home directory.
692
   */
693
  default void setIdeHome(Path ideHome) {
694

695
    setCwd(ideHome, WORKSPACE_MAIN, ideHome);
5✔
696
  }
1✔
697

698
  /**
699
   * Updates the current working directory (CWD) and configures the environment paths according to the specified parameters. This method is central to changing
700
   * the IDE's notion of where it operates, affecting where configurations, workspaces, settings, and other resources are located or loaded from.
701
   *
702
   * @param userDir The path to set as the current working directory.
703
   * @param workspace The name of the workspace within the IDE's environment.
704
   * @param ideHome The path to the IDE home directory.
705
   */
706
  void setCwd(Path userDir, String workspace, Path ideHome);
707

708
  /**
709
   * Finds the path to the Bash executable.
710
   *
711
   * @return the {@link String} to the Bash executable, or {@code null} if Bash is not found
712
   */
713
  String findBash();
714

715
  /**
716
   * Finds the path to the Bash executable.
717
   *
718
   * @return the {@link String} to the Bash executable. Throws an {@link IllegalStateException} if no bash was found.
719
   */
720
  default String findBashRequired() {
721
    String bash = findBash();
3✔
722
    if (bash == null) {
2!
723
      String message = "Could not find bash what is a prerequisite of IDEasy.";
×
724
      if (getSystemInfo().isWindows()) {
×
725
        message = message + "\nPlease install Git for Windows and rerun.";
×
726
      }
727
      throw new IllegalStateException(message);
×
728
    }
729
    return bash;
2✔
730
  }
731

732
  /**
733
   * @return the {@link WindowsPathSyntax} used for {@link Path} conversion or {@code null} for no such conversion (typically if not on Windows).
734
   */
735
  WindowsPathSyntax getPathSyntax();
736

737
  /**
738
   * logs the status of {@link #getIdeHome() IDE_HOME} and {@link #getIdeRoot() IDE_ROOT}.
739
   */
740
  void logIdeHomeAndRootStatus();
741

742
  /**
743
   * @param version the {@link VersionIdentifier} to write.
744
   * @param installationPath the {@link Path directory} where to write the version to a {@link #FILE_SOFTWARE_VERSION version file}.
745
   */
746
  void writeVersionFile(VersionIdentifier version, Path installationPath);
747

748
  /**
749
   * Verifies that current {@link IdeVersion} satisfies {@link IdeVariables#IDE_MIN_VERSION}.
750
   *
751
   * @param throwException whether to throw a {@link CliException} or just log a warning.
752
   */
753
  void verifyIdeMinVersion(boolean throwException);
754

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