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

devonfw / IDEasy / 16117220313

07 Jul 2025 12:41PM UTC coverage: 68.446% (+0.5%) from 67.911%
16117220313

Pull #1375

github

web-flow
Merge 3afe73510 into ba246604e
Pull Request #1375: #742: Show warning when git repo name does not meet name convention.

3286 of 5202 branches covered (63.17%)

Branch coverage included in aggregate %.

8406 of 11880 relevant lines covered (70.76%)

3.13 hits per line

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

79.84
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.gradle.Gradle;
25
import com.devonfw.tools.ide.tool.mvn.Mvn;
26
import com.devonfw.tools.ide.tool.repository.CustomToolRepository;
27
import com.devonfw.tools.ide.tool.repository.MavenRepository;
28
import com.devonfw.tools.ide.tool.repository.ToolRepository;
29
import com.devonfw.tools.ide.url.model.UrlMetadata;
30
import com.devonfw.tools.ide.variable.IdeVariables;
31
import com.devonfw.tools.ide.version.IdeVersion;
32
import com.devonfw.tools.ide.version.VersionIdentifier;
33

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

192
  /**
193
   * The keyword for project name convention.
194
   */
195
  String SETTINGS_REPOSITORY_KEYWORD = "settings";
196

197
  /**
198
   * @return {@code true} if {@link #isOfflineMode() offline mode} is active or we are NOT {@link #isOnline() online}, {@code false} otherwise.
199
   */
200
  default boolean isOffline() {
201

202
    return isOfflineMode() || !isOnline();
10✔
203
  }
204

205
  /**
206
   * @return {@code true} if we are currently online (Internet access is available), {@code false} otherwise.
207
   */
208
  boolean isOnline();
209

210
  /**
211
   * Print the IDEasy {@link #LOGO logo}.
212
   */
213
  default void printLogo() {
214

215
    info(LOGO);
3✔
216
  }
1✔
217

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

227
  /**
228
   * Asks the user for a single string input.
229
   *
230
   * @param message The information message to display.
231
   * @return The string input from the user, or the default value if no input is provided.
232
   */
233
  String askForInput(String message);
234

235
  /**
236
   * @param question the question to ask.
237
   * @param args arguments for filling the templates
238
   * @return {@code true} if the user answered with "yes", {@code false} otherwise ("no").
239
   */
240
  default boolean question(String question, Object... args) {
241

242
    String yes = "yes";
2✔
243
    String option = question(new String[] { yes, "no" }, question, args);
16✔
244
    if (yes.equals(option)) {
4!
245
      return true;
2✔
246
    }
247
    return false;
×
248
  }
249

250
  /**
251
   * @param <O> type of the option. E.g. {@link String}.
252
   * @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.
253
   * @param question the question to ask.
254
   * @return the option selected by the user as answer.
255
   */
256
  @SuppressWarnings("unchecked")
257
  <O> O question(O[] options, String question, Object... args);
258

259
  /**
260
   * 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
261
   * exception is thrown to abort further processing.
262
   *
263
   * @param questionTemplate the yes/no question to {@link #question(String, Object...) ask}.
264
   * @param args the arguments to fill the placeholders in the question template.
265
   * @throws CliAbortException if the user answered with "no" and further processing shall be aborted.
266
   */
267
  default void askToContinue(String questionTemplate, Object... args) {
268
    boolean yesContinue = question(questionTemplate, args);
5✔
269
    if (!yesContinue) {
2!
270
      throw new CliAbortException();
×
271
    }
272
  }
1✔
273

274
  /**
275
   * @param purpose the purpose why Internet connection is required.
276
   * @param explicitOnlineCheck if {@code true}, perform an explicit {@link #isOffline()} check; if {@code false} use {@link #isOfflineMode()}.
277
   * @throws CliException if you are {@link #isOffline() offline}.
278
   */
279
  default void requireOnline(String purpose, boolean explicitOnlineCheck) {
280

281
    if (explicitOnlineCheck) {
2✔
282
      if (isOffline()) {
3✔
283
        throw CliOfflineException.ofPurpose(purpose);
3✔
284
      }
285
    } else {
286
      if (isOfflineMode()) {
3!
287
        throw CliOfflineException.ofPurpose(purpose);
3✔
288
      }
289
    }
290
  }
1✔
291

292
  /**
293
   * @return the {@link SystemInfo}.
294
   */
295
  SystemInfo getSystemInfo();
296

297
  /**
298
   * @return the {@link EnvironmentVariables} with full inheritance.
299
   */
300
  EnvironmentVariables getVariables();
301

302
  /**
303
   * @return the {@link FileAccess}.
304
   */
305
  FileAccess getFileAccess();
306

307
  /**
308
   * @return the {@link CommandletManager}.
309
   */
310
  CommandletManager getCommandletManager();
311

312
  /**
313
   * @return the default {@link ToolRepository}.
314
   */
315
  ToolRepository getDefaultToolRepository();
316

317
  /**
318
   * @return the {@link CustomToolRepository}.
319
   */
320
  CustomToolRepository getCustomToolRepository();
321

322
  /**
323
   * @return the {@link MavenRepository}.
324
   */
325
  MavenRepository getMavenToolRepository();
326

327
  /**
328
   * @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
329
   *     isolated projects.
330
   * @see com.devonfw.tools.ide.variable.IdeVariables#IDE_HOME
331
   */
332
  Path getIdeHome();
333

334
  /**
335
   * @return the name of the current project.
336
   * @see com.devonfw.tools.ide.variable.IdeVariables#PROJECT_NAME
337
   */
338
  String getProjectName();
339

340
  /**
341
   * @return the IDEasy version the {@link #getIdeHome() current project} was created with or migrated to.
342
   */
343
  VersionIdentifier getProjectVersion();
344

345
  /**
346
   * @param version the new value of {@link #getProjectVersion()}.
347
   */
348
  void setProjectVersion(VersionIdentifier version);
349

350
  /**
351
   * @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
352
   *     sub-folder. There is a reserved ".ide" folder where central IDE data is stored such as the {@link #getUrlsPath() download metadata} and the central
353
   *     software repository.
354
   * @see com.devonfw.tools.ide.variable.IdeVariables#IDE_ROOT
355
   */
356
  Path getIdeRoot();
357

358
  /**
359
   * @return the {@link Path} to the {@link #FOLDER_UNDERSCORE_IDE}.
360
   * @see #getIdeRoot()
361
   * @see #FOLDER_UNDERSCORE_IDE
362
   */
363
  Path getIdePath();
364

365
  /**
366
   * @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
367
   *     upgrade a new release is installed and the link is switched to the new release.
368
   */
369
  default Path getIdeInstallationPath() {
370

371
    return getIdePath().resolve(FOLDER_INSTALLATION);
×
372
  }
373

374
  /**
375
   * @return the current working directory ("user.dir"). This is the directory where the user's shell was located when the IDE CLI was invoked.
376
   */
377
  Path getCwd();
378

379
  /**
380
   * @return the {@link Path} for the temporary directory to use. Will be different from the OS specific temporary directory (java.io.tmpDir).
381
   */
382
  Path getTempPath();
383

384
  /**
385
   * @return the {@link Path} for the temporary download directory to use.
386
   */
387
  Path getTempDownloadPath();
388

389
  /**
390
   * @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
391
   *     download tools.
392
   * @see com.devonfw.tools.ide.url.model.folder.UrlRepository
393
   */
394
  Path getUrlsPath();
395

396
  /**
397
   * @return the {@link UrlMetadata}. Will be lazily instantiated and thereby automatically be cloned or pulled (by default).
398
   */
399
  UrlMetadata getUrls();
400

401
  /**
402
   * @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
403
   *     the same artifact is requested again it will be taken from the cache to avoid downloading it again.
404
   */
405
  Path getDownloadPath();
406

407
  /**
408
   * @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
409
   *     {@link #getSoftwareRepositoryPath() software repository} as sub-folder named after the according tool.
410
   */
411
  Path getSoftwarePath();
412

413
  /**
414
   * @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
415
   *     here from the {@link #getSoftwareRepositoryPath() software repository} as sub-folder named after the according tool.
416
   */
417
  Path getSoftwareExtraPath();
418

419
  /**
420
   * @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
421
   *     are shared among all IDE instances (see {@link #getIdeHome() IDE_HOME}) via symbolic links (see {@link #getSoftwarePath()}). Therefore this repository
422
   *     follows the sub-folder structure {@code «repository»/«tool»/«edition»/«version»/}. So multiple versions of the same tool exist here as different
423
   *     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
424
   *     of the scope of this folders.
425
   */
426
  Path getSoftwareRepositoryPath();
427

428
  /**
429
   * @return the {@link Path} to the {@link #FOLDER_PLUGINS plugins folder} inside {@link #getIdeHome() IDE_HOME}. All plugins of the IDE instance will be
430
   *     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.
431
   */
432
  Path getPluginsPath();
433

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

443
  /**
444
   * @return the {@link Path} to the users home directory. Typically initialized via the {@link System#getProperty(String) system property} "user.home".
445
   * @see com.devonfw.tools.ide.variable.IdeVariables#HOME
446
   */
447
  Path getUserHome();
448

449
  /**
450
   * @return the {@link Path} to the ".ide" subfolder in the {@link #getUserHome() users home directory}.
451
   */
452
  Path getUserHomeIde();
453

454
  /**
455
   * @return the {@link Path} to the {@link #FOLDER_SETTINGS settings} folder with the cloned git repository containing the project configuration.
456
   */
457
  Path getSettingsPath();
458

459
  /**
460
   * @return the {@link Path} to the {@link #FOLDER_REPOSITORIES repositories} folder with legacy fallback if not present or {@code null} if not found.
461
   */
462
  default Path getRepositoriesPath() {
463

464
    Path settingsPath = getSettingsPath();
3✔
465
    if (settingsPath == null) {
2!
466
      return null;
×
467
    }
468
    Path repositoriesPath = settingsPath.resolve(IdeContext.FOLDER_REPOSITORIES);
4✔
469
    if (Files.isDirectory(repositoriesPath)) {
5✔
470
      return repositoriesPath;
2✔
471
    }
472
    Path legacyRepositoriesPath = settingsPath.resolve(IdeContext.FOLDER_LEGACY_REPOSITORIES);
4✔
473
    if (Files.isDirectory(legacyRepositoriesPath)) {
5!
474
      return legacyRepositoriesPath;
×
475
    }
476
    return null;
2✔
477
  }
478

479
  /**
480
   * @return the {@link Path} to the {@code settings} folder with the cloned git repository containing the project configuration only if the settings repository
481
   *     is in fact a git repository.
482
   */
483
  Path getSettingsGitRepository();
484

485
  /**
486
   * @return {@code true} if the settings repository is a symlink or a junction.
487
   */
488
  boolean isSettingsRepositorySymlinkOrJunction();
489

490
  /**
491
   * @return the {@link Path} to the file containing the last tracked commit Id of the settings repository.
492
   */
493
  Path getSettingsCommitIdPath();
494

495
  /**
496
   * @return the {@link Path} to the templates folder inside the {@link #getSettingsPath() settings}. The relative directory structure in this templates folder
497
   *     is to be applied to {@link #getIdeHome() IDE_HOME} when the project is set up.
498
   */
499
  default Path getSettingsTemplatePath() {
500
    Path settingsFolder = getSettingsPath();
3✔
501
    Path templatesFolder = settingsFolder.resolve(IdeContext.FOLDER_TEMPLATES);
4✔
502
    if (!Files.isDirectory(templatesFolder)) {
5✔
503
      Path templatesFolderLegacy = settingsFolder.resolve(IdeContext.FOLDER_LEGACY_TEMPLATES);
4✔
504
      if (Files.isDirectory(templatesFolderLegacy)) {
5!
505
        templatesFolder = templatesFolderLegacy;
×
506
      } else {
507
        warning("No templates found in settings git repo neither in {} nor in {} - configuration broken", templatesFolder, templatesFolderLegacy);
13✔
508
        return null;
2✔
509
      }
510
    }
511
    return templatesFolder;
2✔
512
  }
513

514
  /**
515
   * @return the {@link Path} to the {@code conf} folder with instance specific tool configurations and the
516
   *     {@link EnvironmentVariablesType#CONF user specific project configuration}.
517
   */
518
  Path getConfPath();
519

520
  /**
521
   * @return the {@link Path} to the workspace.
522
   * @see #getWorkspaceName()
523
   */
524
  Path getWorkspacePath();
525

526
  /**
527
   * @return the name of the workspace. Defaults to {@link #WORKSPACE_MAIN}.
528
   */
529
  String getWorkspaceName();
530

531
  /**
532
   * @return the value of the system {@link IdeVariables#PATH PATH} variable. It is automatically extended according to the tools available in
533
   *     {@link #getSoftwarePath() software path} unless {@link #getIdeHome() IDE_HOME} was not found.
534
   */
535
  SystemPath getPath();
536

537
  /**
538
   * @return a new {@link ProcessContext} to {@link ProcessContext#run() run} external commands.
539
   */
540
  ProcessContext newProcess();
541

542
  /**
543
   * @param title the {@link IdeProgressBar#getTitle() title}.
544
   * @param size the {@link IdeProgressBar#getMaxSize() expected maximum size}.
545
   * @param unitName the {@link IdeProgressBar#getUnitName() unit name}.
546
   * @param unitSize the {@link IdeProgressBar#getUnitSize() unit size}.
547
   * @return the new {@link IdeProgressBar} to use.
548
   */
549
  IdeProgressBar newProgressBar(String title, long size, String unitName, long unitSize);
550

551
  /**
552
   * @param title the {@link IdeProgressBar#getTitle() title}.
553
   * @param size the {@link IdeProgressBar#getMaxSize() expected maximum size} in bytes.
554
   * @return the new {@link IdeProgressBar} to use.
555
   */
556
  default IdeProgressBar newProgressBarInMib(String title, long size) {
557

558
    if ((size > 0) && (size < 1024)) {
8✔
559
      return new IdeProgressBarNone(title, size, IdeProgressBar.UNIT_NAME_MB, IdeProgressBar.UNIT_SIZE_MB);
8✔
560
    }
561
    return newProgressBar(title, size, IdeProgressBar.UNIT_NAME_MB, IdeProgressBar.UNIT_SIZE_MB);
7✔
562
  }
563

564
  /**
565
   * @param size the {@link IdeProgressBar#getMaxSize() expected maximum size} in bytes.
566
   * @return the new {@link IdeProgressBar} for copy.
567
   */
568
  default IdeProgressBar newProgressBarForDownload(long size) {
569

570
    return newProgressBarInMib(IdeProgressBar.TITLE_DOWNLOADING, size);
5✔
571
  }
572

573
  /**
574
   * @param size the {@link IdeProgressBar#getMaxSize() expected maximum size} in bytes.
575
   * @return the new {@link IdeProgressBar} for extracting.
576
   */
577
  default IdeProgressBar newProgressbarForExtracting(long size) {
578

579
    return newProgressBarInMib(IdeProgressBar.TITLE_EXTRACTING, size);
5✔
580
  }
581

582
  /**
583
   * @param size the {@link IdeProgressBar#getMaxSize() expected maximum size} in bytes.
584
   * @return the new {@link IdeProgressBar} for copy.
585
   */
586
  default IdeProgressBar newProgressbarForCopying(long size) {
587

588
    return newProgressBarInMib(IdeProgressBar.TITLE_COPYING, size);
5✔
589
  }
590

591
  /**
592
   * @param size the {@link IdeProgressBar#getMaxSize() expected maximum} plugin count.
593
   * @return the new {@link IdeProgressBar} to use.
594
   */
595
  default IdeProgressBar newProgressBarForPlugins(long size) {
596
    return newProgressBar(IdeProgressBar.TITLE_INSTALL_PLUGIN, size, IdeProgressBar.UNIT_NAME_PLUGIN, IdeProgressBar.UNIT_SIZE_PLUGIN);
7✔
597
  }
598

599
  /**
600
   * @return the {@link DirectoryMerger} used to configure and merge the workspace for an {@link com.devonfw.tools.ide.tool.ide.IdeToolCommandlet IDE}.
601
   */
602
  DirectoryMerger getWorkspaceMerger();
603

604
  /**
605
   * @return the {@link Path} to the working directory from where the command is executed.
606
   */
607
  Path getDefaultExecutionDirectory();
608

609
  /**
610
   * @return the {@link IdeSystem} instance wrapping {@link System}.
611
   */
612
  IdeSystem getSystem();
613

614
  /**
615
   * @return the {@link GitContext} used to run several git commands.
616
   */
617
  GitContext getGitContext();
618

619
  /**
620
   * @return the String value for the variable MAVEN_ARGS, or null if called outside an IDEasy installation.
621
   */
622
  default String getMavenArgs() {
623

624
    if (getIdeHome() == null) {
3!
625
      return null;
×
626
    }
627
    Mvn mvn = getCommandletManager().getCommandlet(Mvn.class);
6✔
628
    return mvn.getMavenArgs();
3✔
629
  }
630

631
  /**
632
   * @return the path for the variable GRADLE_USER_HOME, or null if called outside an IDEasy installation.
633
   */
634
  default Path getGradleUserHome() {
635

636
    if (getIdeHome() == null) {
3!
637
      return null;
×
638
    }
639
    Gradle gradle = getCommandletManager().getCommandlet(Gradle.class);
6✔
640
    return gradle.getOrCreateGradleConfFolder();
3✔
641
  }
642

643
  /**
644
   * @return the {@link Path} pointing to the maven configuration directory (where "settings.xml" or "settings-security.xml" are located).
645
   */
646
  default Path getMavenConfigurationFolder() {
647

648
    Path confPath = getConfPath();
3✔
649
    Path mvnConfFolder = null;
2✔
650
    if (confPath != null) {
2✔
651
      mvnConfFolder = confPath.resolve(Mvn.MVN_CONFIG_FOLDER);
4✔
652
      if (!Files.isDirectory(mvnConfFolder)) {
5✔
653
        Path m2LegacyFolder = confPath.resolve(Mvn.MVN_CONFIG_LEGACY_FOLDER);
4✔
654
        if (Files.isDirectory(m2LegacyFolder)) {
5!
655
          mvnConfFolder = m2LegacyFolder;
×
656
        } else {
657
          mvnConfFolder = null; // see fallback below
2✔
658
        }
659
      }
660
    }
661
    if (mvnConfFolder == null) {
2✔
662
      // fallback to USER_HOME/.m2 folder
663
      mvnConfFolder = getUserHome().resolve(Mvn.MVN_CONFIG_LEGACY_FOLDER);
5✔
664
    }
665
    return mvnConfFolder;
2✔
666
  }
667

668
  /**
669
   * Updates the current working directory (CWD) and configures the environment paths according to the specified parameters. This method is central to changing
670
   * the IDE's notion of where it operates, affecting where configurations, workspaces, settings, and other resources are located or loaded from.
671
   *
672
   * @return the current {@link Step} of processing.
673
   */
674
  Step getCurrentStep();
675

676
  /**
677
   * @param name the {@link Step#getName() name} of the new {@link Step}.
678
   * @return the new {@link Step} that has been created and started.
679
   */
680
  default Step newStep(String name) {
681

682
    return newStep(name, Step.NO_PARAMS);
5✔
683
  }
684

685
  /**
686
   * @param name the {@link Step#getName() name} of the new {@link Step}.
687
   * @param parameters the {@link Step#getParameter(int) parameters} of the {@link Step}.
688
   * @return the new {@link Step} that has been created and started.
689
   */
690
  default Step newStep(String name, Object... parameters) {
691

692
    return newStep(false, name, parameters);
6✔
693
  }
694

695
  /**
696
   * @param silent the {@link Step#isSilent() silent flag}.
697
   * @param name the {@link Step#getName() name} of the new {@link Step}.
698
   * @param parameters the {@link Step#getParameter(int) parameters} of the {@link Step}.
699
   * @return the new {@link Step} that has been created and started.
700
   */
701
  Step newStep(boolean silent, String name, Object... parameters);
702

703
  /**
704
   * @param lambda the {@link Runnable} to {@link Runnable#run() run} while the {@link com.devonfw.tools.ide.log.IdeLogger logging} is entirely disabled.
705
   *     After this the logging will be enabled again. Collected log messages will then be logged at the end.
706
   */
707
  default void runWithoutLogging(Runnable lambda) {
708

709
    runWithoutLogging(lambda, IdeLogLevel.TRACE);
4✔
710
  }
1✔
711

712
  /**
713
   * @param lambda the {@link Runnable} to {@link Runnable#run() run} while the {@link com.devonfw.tools.ide.log.IdeLogger logging} is entirely disabled.
714
   *     After this the logging will be enabled again. Collected log messages will then be logged at the end.
715
   * @param threshold the {@link IdeLogLevel} to use as threshold for filtering logs while logging is disabled and log messages are collected. Use
716
   *     {@link IdeLogLevel#TRACE} to collect all logs and ensure nothing gets lost (will still not log anything that is generally not active in regular
717
   *     logging) and e.g. use {@link IdeLogLevel#ERROR} to discard all logs except errors.
718
   */
719
  void runWithoutLogging(Runnable lambda, IdeLogLevel threshold);
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
   * @param ideHome The path to the IDE home directory.
726
   */
727
  default void setIdeHome(Path ideHome) {
728

729
    setCwd(ideHome, WORKSPACE_MAIN, ideHome);
5✔
730
  }
1✔
731

732
  /**
733
   * Updates the current working directory (CWD) and configures the environment paths according to the specified parameters. This method is central to changing
734
   * the IDE's notion of where it operates, affecting where configurations, workspaces, settings, and other resources are located or loaded from.
735
   *
736
   * @param userDir The path to set as the current working directory.
737
   * @param workspace The name of the workspace within the IDE's environment.
738
   * @param ideHome The path to the IDE home directory.
739
   */
740
  void setCwd(Path userDir, String workspace, Path ideHome);
741

742
  /**
743
   * Finds the path to the Bash executable.
744
   *
745
   * @return the {@link String} to the Bash executable, or {@code null} if Bash is not found
746
   */
747
  String findBash();
748

749
  /**
750
   * Finds the path to the Bash executable.
751
   *
752
   * @return the {@link String} to the Bash executable. Throws an {@link IllegalStateException} if no bash was found.
753
   */
754
  default String findBashRequired() {
755
    String bash = findBash();
3✔
756
    if (bash == null) {
2!
757
      String message = "Could not find bash what is a prerequisite of IDEasy.";
×
758
      if (getSystemInfo().isWindows()) {
×
759
        message = message + "\nPlease install Git for Windows and rerun.";
×
760
      }
761
      throw new IllegalStateException(message);
×
762
    }
763
    return bash;
2✔
764
  }
765

766
  /**
767
   * @return the {@link WindowsPathSyntax} used for {@link Path} conversion or {@code null} for no such conversion (typically if not on Windows).
768
   */
769
  WindowsPathSyntax getPathSyntax();
770

771
  /**
772
   * logs the status of {@link #getIdeHome() IDE_HOME} and {@link #getIdeRoot() IDE_ROOT}.
773
   */
774
  void logIdeHomeAndRootStatus();
775

776
  /**
777
   * @param version the {@link VersionIdentifier} to write.
778
   * @param installationPath the {@link Path directory} where to write the version to a {@link #FILE_SOFTWARE_VERSION version file}.
779
   */
780
  void writeVersionFile(VersionIdentifier version, Path installationPath);
781

782
  /**
783
   * Verifies that current {@link IdeVersion} satisfies {@link IdeVariables#IDE_MIN_VERSION}.
784
   *
785
   * @param throwException whether to throw a {@link CliException} or just log a warning.
786
   */
787
  void verifyIdeMinVersion(boolean throwException);
788

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