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

devonfw / IDEasy / 13210157275

08 Feb 2025 12:10AM UTC coverage: 68.25% (-0.1%) from 68.379%
13210157275

Pull #1021

github

web-flow
Merge 93d542ee7 into 9c2006bd8
Pull Request #1021: #786: support ide upgrade to automatically update to the latest version of IDEasy

2910 of 4683 branches covered (62.14%)

Branch coverage included in aggregate %.

7563 of 10662 relevant lines covered (70.93%)

3.09 hits per line

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

67.31
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.merge.DirectoryMerger;
19
import com.devonfw.tools.ide.os.SystemInfo;
20
import com.devonfw.tools.ide.os.WindowsPathSyntax;
21
import com.devonfw.tools.ide.process.ProcessContext;
22
import com.devonfw.tools.ide.step.Step;
23
import com.devonfw.tools.ide.tool.mvn.Mvn;
24
import com.devonfw.tools.ide.tool.repository.CustomToolRepository;
25
import com.devonfw.tools.ide.tool.repository.MavenRepository;
26
import com.devonfw.tools.ide.tool.repository.ToolRepository;
27
import com.devonfw.tools.ide.url.model.UrlMetadata;
28
import com.devonfw.tools.ide.variable.IdeVariables;
29

30
/**
31
 * Interface for interaction with the user allowing to input and output information.
32
 */
33
public interface IdeContext extends IdeStartContext {
34

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

42
  /** The name of the workspaces folder. */
43
  String FOLDER_WORKSPACES = "workspaces";
44

45
  /** The name of the settings folder. */
46
  String FOLDER_SETTINGS = "settings";
47

48
  /** The name of the software folder. */
49
  String FOLDER_SOFTWARE = "software";
50

51
  /** The name of the conf folder for project specific user configurations. */
52
  String FOLDER_CONF = "conf";
53

54
  /**
55
   * The nane of the folder inside IDE_ROOT reserved for IDEasy. Intentionally starting with an underscore and not a dot to prevent effects like OS hiding,
56
   * maven filtering, .gitignore and to distinguish from {@link #FOLDER_DOT_IDE}.
57
   *
58
   * @see #getIdePath()
59
   */
60
  String FOLDER_UNDERSCORE_IDE = "_ide";
61

62
  /**
63
   * The name of the folder inside {@link #FOLDER_UNDERSCORE_IDE} with the current IDEasy installation.
64
   *
65
   * @see #getIdeInstallationPath()
66
   */
67
  String FOLDER_INSTALLATION = "installation";
68

69
  /**
70
   * The name of the hidden folder for IDE configuration in the users home directory or status information in the IDE_HOME directory.
71
   *
72
   * @see #getUserHomeIde()
73
   */
74
  String FOLDER_DOT_IDE = ".ide";
75

76
  /** The name of the updates folder for temporary data and backup. */
77
  String FOLDER_UPDATES = "updates";
78

79
  /** The name of the volume folder for mounting archives like *.dmg. */
80
  String FOLDER_VOLUME = "volume";
81

82
  /** The name of the backups folder for backup. */
83
  String FOLDER_BACKUPS = "backups";
84

85
  /** The name of the downloads folder. */
86
  String FOLDER_DOWNLOADS = "Downloads";
87

88
  /** The name of the bin folder where executable files are found by default. */
89
  String FOLDER_BIN = "bin";
90

91
  /** The name of the repositories folder where properties files are stores for each repository */
92
  String FOLDER_REPOSITORIES = "repositories";
93

94
  /** The name of the repositories folder where properties files are stores for each repository */
95
  String FOLDER_LEGACY_REPOSITORIES = "projects";
96

97
  /** The name of the Contents folder inside a MacOS app. */
98
  String FOLDER_CONTENTS = "Contents";
99

100
  /** The name of the Resources folder inside a MacOS app. */
101
  String FOLDER_RESOURCES = "Resources";
102

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

106
  /** The name of the extra folder inside the software folder */
107
  String FOLDER_EXTRA = "extra";
108

109
  /**
110
   * The name of the {@link #getPluginsPath() plugins folder} and also the plugins folder inside the IDE folders of {@link #getSettingsPath() settings} (e.g.
111
   * settings/eclipse/plugins).
112
   */
113
  String FOLDER_PLUGINS = "plugins";
114

115
  /**
116
   * The name of the workspace folder inside the IDE specific {@link #FOLDER_SETTINGS settings} containing the configuration templates in #FOLDER_SETUP
117
   * #FOLDER_UPDATE.
118
   */
119
  String FOLDER_WORKSPACE = "workspace";
120

121
  /**
122
   * The name of the setup folder inside the {@link #FOLDER_WORKSPACE workspace} folder containing the templates for the configuration templates for the initial
123
   * setup of a workspace. This is closely related with the {@link #FOLDER_UPDATE update} folder.
124
   */
125
  String FOLDER_SETUP = "setup";
126

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

139
  /**
140
   * The name of the folder inside {@link #FOLDER_UNDERSCORE_IDE _ide} folder containing internal resources and scripts of IDEasy.
141
   */
142
  String FOLDER_INTERNAL = "internal";
143

144
  /** The file where the installed software version is written to as plain text. */
145
  String FILE_SOFTWARE_VERSION = ".ide.software.version";
146

147
  /** The file where the installed software version is written to as plain text. */
148
  String FILE_LEGACY_SOFTWARE_VERSION = ".devon.software.version";
149

150
  /** The file for the license agreement. */
151
  String FILE_LICENSE_AGREEMENT = ".license.agreement";
152

153
  /** The file extension for a {@link java.util.Properties} file. */
154
  String EXT_PROPERTIES = ".properties";
155

156
  /** The default for {@link #getWorkspaceName()}. */
157
  String WORKSPACE_MAIN = "main";
158

159
  /** The folder with the configuration template files from the settings. */
160
  String FOLDER_TEMPLATES = "templates";
161

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

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

168
  /**
169
   * file containing the current local commit hash of the settings repository.
170
   */
171
  String SETTINGS_COMMIT_ID = ".commit.id";
172

173
  /** The IDEasy ASCII logo. */
174
  String LOGO = """
4✔
175
      __       ___ ___  ___
176
      ╲ ╲     |_ _|   ╲| __|__ _ ____ _
177
       > >     | || |) | _|/ _` (_-< || |
178
      /_/ ___ |___|___/|___╲__,_/__/╲_, |
179
         |___|                       |__/
180
      """.replace('╲', '\\');
2✔
181

182
  /**
183
   * @return {@code true} if {@link #isOfflineMode() offline mode} is active or we are NOT {@link #isOnline() online}, {@code false} otherwise.
184
   */
185
  default boolean isOffline() {
186

187
    return isOfflineMode() || !isOnline();
10!
188
  }
189

190
  /**
191
   * @return {@code true} if we are currently online (Internet access is available), {@code false} otherwise.
192
   */
193
  boolean isOnline();
194

195
  /**
196
   * Print the IDEasy {@link #LOGO logo}.
197
   */
198
  default void printLogo() {
199

200
    info(LOGO);
3✔
201
  }
1✔
202

203
  /**
204
   * Asks the user for a single string input.
205
   *
206
   * @param message The information message to display.
207
   * @param defaultValue The default value to return when no input is provided.
208
   * @return The string input from the user, or the default value if no input is provided.
209
   */
210
  String askForInput(String message, String defaultValue);
211

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

220
  /**
221
   * @param question the question to ask.
222
   * @return {@code true} if the user answered with "yes", {@code false} otherwise ("no").
223
   */
224
  default boolean question(String question) {
225

226
    String yes = "yes";
×
227
    String option = question(question, yes, "no");
×
228
    if (yes.equals(option)) {
×
229
      return true;
×
230
    }
231
    return false;
×
232
  }
233

234
  /**
235
   * @param <O> type of the option. E.g. {@link String}.
236
   * @param question the question to ask.
237
   * @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.
238
   * @return the option selected by the user as answer.
239
   */
240
  @SuppressWarnings("unchecked")
241
  <O> O question(String question, O... options);
242

243
  /**
244
   * 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
245
   * exception is thrown to abort further processing.
246
   *
247
   * @param question the yes/no question to {@link #question(String) ask}.
248
   * @throws CliAbortException if the user answered with "no" and further processing shall be aborted.
249
   */
250
  default void askToContinue(String question) {
251

252
    boolean yesContinue = question(question);
×
253
    if (!yesContinue) {
×
254
      throw new CliAbortException();
×
255
    }
256
  }
×
257

258
  /**
259
   * @param purpose the purpose why Internet connection is required.
260
   * @throws CliException if you are {@link #isOffline() offline}.
261
   */
262
  default void requireOnline(String purpose) {
263

264
    if (isOfflineMode()) {
3!
265
      throw CliOfflineException.ofPurpose(purpose);
3✔
266
    }
267
  }
×
268

269
  /**
270
   * @return the {@link SystemInfo}.
271
   */
272
  SystemInfo getSystemInfo();
273

274
  /**
275
   * @return the {@link EnvironmentVariables} with full inheritance.
276
   */
277
  EnvironmentVariables getVariables();
278

279
  /**
280
   * @return the {@link FileAccess}.
281
   */
282
  FileAccess getFileAccess();
283

284
  /**
285
   * @return the {@link CommandletManager}.
286
   */
287
  CommandletManager getCommandletManager();
288

289
  /**
290
   * @return the default {@link ToolRepository}.
291
   */
292
  ToolRepository getDefaultToolRepository();
293

294
  /**
295
   * @return the {@link CustomToolRepository}.
296
   */
297
  CustomToolRepository getCustomToolRepository();
298

299
  /**
300
   * @return the {@link MavenRepository}.
301
   */
302
  MavenRepository getMavenToolRepository();
303

304
  /**
305
   * @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
306
   *     isolated projects.
307
   * @see com.devonfw.tools.ide.variable.IdeVariables#IDE_HOME
308
   */
309
  Path getIdeHome();
310

311
  /**
312
   * @return the name of the current project.
313
   * @see com.devonfw.tools.ide.variable.IdeVariables#PROJECT_NAME
314
   */
315
  String getProjectName();
316

317
  /**
318
   * @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
319
   *     sub-folder. There is a reserved ".ide" folder where central IDE data is stored such as the {@link #getUrlsPath() download metadata} and the central
320
   *     software repository.
321
   * @see com.devonfw.tools.ide.variable.IdeVariables#IDE_ROOT
322
   */
323
  Path getIdeRoot();
324

325
  /**
326
   * @return the {@link Path} to the {@link #FOLDER_UNDERSCORE_IDE}.
327
   * @see #getIdeRoot()
328
   * @see #FOLDER_UNDERSCORE_IDE
329
   */
330
  Path getIdePath();
331

332
  /**
333
   * @return the {@link Path} to the
334
   */
335
  default Path getIdeInstallationPath() {
336

337
    return getIdePath().resolve(FOLDER_INSTALLATION);
×
338
  }
339

340
  /**
341
   * @return the current working directory ("user.dir"). This is the directory where the user's shell was located when the IDE CLI was invoked.
342
   */
343
  Path getCwd();
344

345
  /**
346
   * @return the {@link Path} for the temporary directory to use. Will be different from the OS specific temporary directory (java.io.tmpDir).
347
   */
348
  Path getTempPath();
349

350
  /**
351
   * @return the {@link Path} for the temporary download directory to use.
352
   */
353
  Path getTempDownloadPath();
354

355
  /**
356
   * @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
357
   *     download tools.
358
   * @see com.devonfw.tools.ide.url.model.folder.UrlRepository
359
   */
360
  Path getUrlsPath();
361

362
  /**
363
   * @return the {@link UrlMetadata}. Will be lazily instantiated and thereby automatically be cloned or pulled (by default).
364
   */
365
  UrlMetadata getUrls();
366

367
  /**
368
   * @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
369
   *     the same artifact is requested again it will be taken from the cache to avoid downloading it again.
370
   */
371
  Path getDownloadPath();
372

373
  /**
374
   * @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
375
   *     {@link #getSoftwareRepositoryPath() software repository} as sub-folder named after the according tool.
376
   */
377
  Path getSoftwarePath();
378

379
  /**
380
   * @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
381
   *     here from the {@link #getSoftwareRepositoryPath() software repository} as sub-folder named after the according tool.
382
   */
383
  Path getSoftwareExtraPath();
384

385
  /**
386
   * @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
387
   *     are shared among all IDE instances (see {@link #getIdeHome() IDE_HOME}) via symbolic links (see {@link #getSoftwarePath()}). Therefore this repository
388
   *     follows the sub-folder structure {@code «repository»/«tool»/«edition»/«version»/}. So multiple versions of the same tool exist here as different
389
   *     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
390
   *     of the scope of this folders.
391
   */
392
  Path getSoftwareRepositoryPath();
393

394
  /**
395
   * @return the {@link Path} to the {@link #FOLDER_PLUGINS plugins folder} inside {@link #getIdeHome() IDE_HOME}. All plugins of the IDE instance will be
396
   *     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.
397
   */
398
  Path getPluginsPath();
399

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

409
  /**
410
   * @return the {@link Path} to the users home directory. Typically initialized via the {@link System#getProperty(String) system property} "user.home".
411
   * @see com.devonfw.tools.ide.variable.IdeVariables#HOME
412
   */
413
  Path getUserHome();
414

415
  /**
416
   * @return the {@link Path} to the ".ide" subfolder in the {@link #getUserHome() users home directory}.
417
   */
418
  Path getUserHomeIde();
419

420
  /**
421
   * @return the {@link Path} to the {@link #FOLDER_SETTINGS settings} folder with the cloned git repository containing the project configuration.
422
   */
423
  Path getSettingsPath();
424

425
  /**
426
   * @return the {@link Path} to the {@link #FOLDER_REPOSITORIES repositories} folder with legacy fallback if not present or {@code null} if not found.
427
   */
428
  default Path getRepositoriesPath() {
429

430
    Path settingsPath = getSettingsPath();
3✔
431
    if (settingsPath == null) {
2!
432
      return null;
×
433
    }
434
    Path repositoriesPath = settingsPath.resolve(IdeContext.FOLDER_REPOSITORIES);
4✔
435
    if (Files.isDirectory(repositoriesPath)) {
5✔
436
      return repositoriesPath;
2✔
437
    }
438
    Path legacyRepositoriesPath = settingsPath.resolve(IdeContext.FOLDER_LEGACY_REPOSITORIES);
4✔
439
    if (Files.isDirectory(legacyRepositoriesPath)) {
5!
440
      return legacyRepositoriesPath;
×
441
    }
442
    return null;
2✔
443
  }
444

445
  /**
446
   * @return the {@link Path} to the {@code settings} folder with the cloned git repository containing the project configuration only if the settings repository
447
   *     is in fact a git repository.
448
   */
449
  Path getSettingsGitRepository();
450

451
  /**
452
   * @return {@code true} if the settings repository is a symlink or a junction.
453
   */
454
  boolean isSettingsRepositorySymlinkOrJunction();
455

456
  /**
457
   * @return the {@link Path} to the file containing the last tracked commit Id of the settings repository.
458
   */
459
  Path getSettingsCommitIdPath();
460

461
  /**
462
   * @return the {@link Path} to the templates folder inside the {@link #getSettingsPath() settings}. The relative directory structure in this templates folder
463
   *     is to be applied to {@link #getIdeHome() IDE_HOME} when the project is set up.
464
   */
465
  default Path getSettingsTemplatePath() {
466
    Path settingsFolder = getSettingsPath();
3✔
467
    Path templatesFolder = settingsFolder.resolve(IdeContext.FOLDER_TEMPLATES);
4✔
468
    if (!Files.isDirectory(templatesFolder)) {
5✔
469
      Path templatesFolderLegacy = settingsFolder.resolve(IdeContext.FOLDER_LEGACY_TEMPLATES);
4✔
470
      if (Files.isDirectory(templatesFolderLegacy)) {
5!
471
        templatesFolder = templatesFolderLegacy;
×
472
      } else {
473
        warning("No templates found in settings git repo neither in {} nor in {} - configuration broken", templatesFolder, templatesFolderLegacy);
13✔
474
        return null;
2✔
475
      }
476
    }
477
    return templatesFolder;
2✔
478
  }
479

480
  /**
481
   * @return the {@link Path} to the {@code conf} folder with instance specific tool configurations and the
482
   *     {@link EnvironmentVariablesType#CONF user specific project configuration}.
483
   */
484
  Path getConfPath();
485

486
  /**
487
   * @return the {@link Path} to the workspace.
488
   * @see #getWorkspaceName()
489
   */
490
  Path getWorkspacePath();
491

492
  /**
493
   * @return the name of the workspace. Defaults to {@link #WORKSPACE_MAIN}.
494
   */
495
  String getWorkspaceName();
496

497
  /**
498
   * @return the value of the system {@link IdeVariables#PATH PATH} variable. It is automatically extended according to the tools available in
499
   *     {@link #getSoftwarePath() software path} unless {@link #getIdeHome() IDE_HOME} was not found.
500
   */
501
  SystemPath getPath();
502

503
  /**
504
   * @return a new {@link ProcessContext} to {@link ProcessContext#run() run} external commands.
505
   */
506
  ProcessContext newProcess();
507

508
  /**
509
   * @param title the {@link IdeProgressBar#getTitle() title}.
510
   * @param size the {@link IdeProgressBar#getMaxSize() expected maximum size}.
511
   * @param unitName the {@link IdeProgressBar#getUnitName() unit name}.
512
   * @param unitSize the {@link IdeProgressBar#getUnitSize() unit size}.
513
   * @return the new {@link IdeProgressBar} to use.
514
   */
515
  IdeProgressBar newProgressBar(String title, long size, String unitName, long unitSize);
516

517
  /**
518
   * @param title the {@link IdeProgressBar#getTitle() title}.
519
   * @param size the {@link IdeProgressBar#getMaxSize() expected maximum size} in bytes.
520
   * @return the new {@link IdeProgressBar} to use.
521
   */
522
  default IdeProgressBar newProgressBarInMib(String title, long size) {
523

524
    if ((size > 0) && (size < 1024)) {
8✔
525
      return new IdeProgressBarNone(title, size, IdeProgressBar.UNIT_NAME_MB, IdeProgressBar.UNIT_SIZE_MB);
8✔
526
    }
527
    return newProgressBar(title, size, IdeProgressBar.UNIT_NAME_MB, IdeProgressBar.UNIT_SIZE_MB);
7✔
528
  }
529

530
  /**
531
   * @param size the {@link IdeProgressBar#getMaxSize() expected maximum size} in bytes.
532
   * @return the new {@link IdeProgressBar} for copy.
533
   */
534
  default IdeProgressBar newProgressBarForDownload(long size) {
535

536
    return newProgressBarInMib(IdeProgressBar.TITLE_DOWNLOADING, size);
5✔
537
  }
538

539
  /**
540
   * @param size the {@link IdeProgressBar#getMaxSize() expected maximum size} in bytes.
541
   * @return the new {@link IdeProgressBar} for extracting.
542
   */
543
  default IdeProgressBar newProgressbarForExtracting(long size) {
544

545
    return newProgressBarInMib(IdeProgressBar.TITLE_EXTRACTING, size);
5✔
546
  }
547

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

554
    return newProgressBarInMib(IdeProgressBar.TITLE_COPYING, size);
5✔
555
  }
556

557
  /**
558
   * @return the {@link DirectoryMerger} used to configure and merge the workspace for an {@link com.devonfw.tools.ide.tool.ide.IdeToolCommandlet IDE}.
559
   */
560
  DirectoryMerger getWorkspaceMerger();
561

562
  /**
563
   * @return the {@link Path} to the working directory from where the command is executed.
564
   */
565
  Path getDefaultExecutionDirectory();
566

567
  /**
568
   * @return the {@link IdeSystem} instance wrapping {@link System}.
569
   */
570
  IdeSystem getSystem();
571

572
  /**
573
   * @return the {@link GitContext} used to run several git commands.
574
   */
575
  GitContext getGitContext();
576

577
  /**
578
   * @return the String value for the variable MAVEN_ARGS, or null if called outside an IDEasy installation.
579
   */
580
  default String getMavenArgs() {
581

582
    if (getIdeHome() == null) {
3!
583
      return null;
×
584
    }
585
    Mvn mvn = getCommandletManager().getCommandlet(Mvn.class);
6✔
586
    return mvn.getMavenArgs();
3✔
587
  }
588

589
  /**
590
   * @return the {@link Path} pointing to the maven configuration directory (where "settings.xml" or "settings-security.xml" are located).
591
   */
592
  default Path getMavenConfigurationFolder() {
593

594
    if (getIdeHome() != null) {
3✔
595
      Path confPath = getConfPath();
3✔
596
      Path m2Folder = confPath.resolve(Mvn.MVN_CONFIG_FOLDER);
4✔
597
      if (!Files.isDirectory(m2Folder)) {
5✔
598
        Path m2LegacyFolder = confPath.resolve(Mvn.MVN_CONFIG_LEGACY_FOLDER);
4✔
599
        if (Files.isDirectory(m2LegacyFolder)) {
5!
600
          m2Folder = m2LegacyFolder;
×
601
        } else {
602
          // fallback to USER_HOME/.m2 folder
603
          m2Folder = getUserHome().resolve(Mvn.MVN_CONFIG_LEGACY_FOLDER);
5✔
604
        }
605
      }
606
      return m2Folder;
2✔
607
    }
608
    return null;
2✔
609
  }
610

611
  /**
612
   * Updates the current working directory (CWD) and configures the environment paths according to the specified parameters. This method is central to changing
613
   * the IDE's notion of where it operates, affecting where configurations, workspaces, settings, and other resources are located or loaded from.
614
   *
615
   * @return the current {@link Step} of processing.
616
   */
617
  Step getCurrentStep();
618

619
  /**
620
   * @param name the {@link Step#getName() name} of the new {@link Step}.
621
   * @return the new {@link Step} that has been created and started.
622
   */
623
  default Step newStep(String name) {
624

625
    return newStep(name, Step.NO_PARAMS);
5✔
626
  }
627

628
  /**
629
   * @param name the {@link Step#getName() name} of the new {@link Step}.
630
   * @param parameters the {@link Step#getParameter(int) parameters} of the {@link Step}.
631
   * @return the new {@link Step} that has been created and started.
632
   */
633
  default Step newStep(String name, Object... parameters) {
634

635
    return newStep(false, name, parameters);
6✔
636
  }
637

638
  /**
639
   * @param silent the {@link Step#isSilent() silent flag}.
640
   * @param name the {@link Step#getName() name} of the new {@link Step}.
641
   * @param parameters the {@link Step#getParameter(int) parameters} of the {@link Step}.
642
   * @return the new {@link Step} that has been created and started.
643
   */
644
  Step newStep(boolean silent, String name, Object... parameters);
645

646
  /**
647
   * Updates the current working directory (CWD) and configures the environment paths according to the specified parameters. This method is central to changing
648
   * the IDE's notion of where it operates, affecting where configurations, workspaces, settings, and other resources are located or loaded from.
649
   *
650
   * @param ideHome The path to the IDE home directory.
651
   */
652
  default void setIdeHome(Path ideHome) {
653

654
    setCwd(ideHome, WORKSPACE_MAIN, ideHome);
5✔
655
  }
1✔
656

657
  /**
658
   * Updates the current working directory (CWD) and configures the environment paths according to the specified parameters. This method is central to changing
659
   * the IDE's notion of where it operates, affecting where configurations, workspaces, settings, and other resources are located or loaded from.
660
   *
661
   * @param userDir The path to set as the current working directory.
662
   * @param workspace The name of the workspace within the IDE's environment.
663
   * @param ideHome The path to the IDE home directory.
664
   */
665
  void setCwd(Path userDir, String workspace, Path ideHome);
666

667
  /**
668
   * Finds the path to the Bash executable.
669
   *
670
   * @return the {@link String} to the Bash executable, or {@code null} if Bash is not found
671
   */
672
  String findBash();
673

674
  /**
675
   * Finds the path to the Bash executable.
676
   *
677
   * @return the {@link String} to the Bash executable. Throws an {@link IllegalStateException} if no bash was found.
678
   */
679
  default String findBashRequired() {
680
    String bash = findBash();
3✔
681
    if (bash == null) {
2!
682
      String message = "Could not find bash what is a prerequisite of IDEasy.";
×
683
      if (getSystemInfo().isWindows()) {
×
684
        message = message + "\nPlease install Git for Windows and rerun.";
×
685
      }
686
      throw new IllegalStateException(message);
×
687
    }
688
    return bash;
2✔
689
  }
690

691
  /**
692
   * @return the {@link WindowsPathSyntax} used for {@link Path} conversion or {@code null} for no such conversion (typically if not on Windows).
693
   */
694
  WindowsPathSyntax getPathSyntax();
695

696
  /**
697
   * logs the status of {@link #getIdeHome() IDE_HOME} and {@link #getIdeRoot() IDE_ROOT}.
698
   */
699
  void logIdeHomeAndRootStatus();
700

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