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

devonfw / IDEasy / 13327588889

14 Feb 2025 10:44AM UTC coverage: 67.947% (-0.5%) from 68.469%
13327588889

Pull #1021

github

web-flow
Merge d03159bfe into 52609dacb
Pull Request #1021: #786: support ide upgrade to automatically update to the latest version of IDEasy

2964 of 4791 branches covered (61.87%)

Branch coverage included in aggregate %.

7688 of 10886 relevant lines covered (70.62%)

3.07 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
import com.devonfw.tools.ide.version.VersionIdentifier;
30

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

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

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

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

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

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

55
  /**
56
   * 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,
57
   * maven filtering, .gitignore and to distinguish from {@link #FOLDER_DOT_IDE}.
58
   *
59
   * @see #getIdePath()
60
   */
61
  String FOLDER_UNDERSCORE_IDE = "_ide";
62

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

318
  /**
319
   * @return the IDEasy version the {@link #getIdeHome() current project} was created with or migrated to.
320
   */
321
  VersionIdentifier getProjectVersion();
322

323
  /**
324
   * @param version the new value of {@link #getProjectVersion()}.
325
   */
326
  void setProjectVersion(VersionIdentifier version);
327

328
  /**
329
   * @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
330
   *     sub-folder. There is a reserved ".ide" folder where central IDE data is stored such as the {@link #getUrlsPath() download metadata} and the central
331
   *     software repository.
332
   * @see com.devonfw.tools.ide.variable.IdeVariables#IDE_ROOT
333
   */
334
  Path getIdeRoot();
335

336
  /**
337
   * @return the {@link Path} to the {@link #FOLDER_UNDERSCORE_IDE}.
338
   * @see #getIdeRoot()
339
   * @see #FOLDER_UNDERSCORE_IDE
340
   */
341
  Path getIdePath();
342

343
  /**
344
   * @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
345
   *     upgrade a new release is installed and the link is switched to the new release.
346
   */
347
  default Path getIdeInstallationPath() {
348

349
    return getIdePath().resolve(FOLDER_INSTALLATION);
×
350
  }
351

352
  /**
353
   * @return the current working directory ("user.dir"). This is the directory where the user's shell was located when the IDE CLI was invoked.
354
   */
355
  Path getCwd();
356

357
  /**
358
   * @return the {@link Path} for the temporary directory to use. Will be different from the OS specific temporary directory (java.io.tmpDir).
359
   */
360
  Path getTempPath();
361

362
  /**
363
   * @return the {@link Path} for the temporary download directory to use.
364
   */
365
  Path getTempDownloadPath();
366

367
  /**
368
   * @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
369
   *     download tools.
370
   * @see com.devonfw.tools.ide.url.model.folder.UrlRepository
371
   */
372
  Path getUrlsPath();
373

374
  /**
375
   * @return the {@link UrlMetadata}. Will be lazily instantiated and thereby automatically be cloned or pulled (by default).
376
   */
377
  UrlMetadata getUrls();
378

379
  /**
380
   * @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
381
   *     the same artifact is requested again it will be taken from the cache to avoid downloading it again.
382
   */
383
  Path getDownloadPath();
384

385
  /**
386
   * @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
387
   *     {@link #getSoftwareRepositoryPath() software repository} as sub-folder named after the according tool.
388
   */
389
  Path getSoftwarePath();
390

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

397
  /**
398
   * @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
399
   *     are shared among all IDE instances (see {@link #getIdeHome() IDE_HOME}) via symbolic links (see {@link #getSoftwarePath()}). Therefore this repository
400
   *     follows the sub-folder structure {@code «repository»/«tool»/«edition»/«version»/}. So multiple versions of the same tool exist here as different
401
   *     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
402
   *     of the scope of this folders.
403
   */
404
  Path getSoftwareRepositoryPath();
405

406
  /**
407
   * @return the {@link Path} to the {@link #FOLDER_PLUGINS plugins folder} inside {@link #getIdeHome() IDE_HOME}. All plugins of the IDE instance will be
408
   *     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.
409
   */
410
  Path getPluginsPath();
411

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

421
  /**
422
   * @return the {@link Path} to the users home directory. Typically initialized via the {@link System#getProperty(String) system property} "user.home".
423
   * @see com.devonfw.tools.ide.variable.IdeVariables#HOME
424
   */
425
  Path getUserHome();
426

427
  /**
428
   * @return the {@link Path} to the ".ide" subfolder in the {@link #getUserHome() users home directory}.
429
   */
430
  Path getUserHomeIde();
431

432
  /**
433
   * @return the {@link Path} to the {@link #FOLDER_SETTINGS settings} folder with the cloned git repository containing the project configuration.
434
   */
435
  Path getSettingsPath();
436

437
  /**
438
   * @return the {@link Path} to the {@link #FOLDER_REPOSITORIES repositories} folder with legacy fallback if not present or {@code null} if not found.
439
   */
440
  default Path getRepositoriesPath() {
441

442
    Path settingsPath = getSettingsPath();
3✔
443
    if (settingsPath == null) {
2!
444
      return null;
×
445
    }
446
    Path repositoriesPath = settingsPath.resolve(IdeContext.FOLDER_REPOSITORIES);
4✔
447
    if (Files.isDirectory(repositoriesPath)) {
5✔
448
      return repositoriesPath;
2✔
449
    }
450
    Path legacyRepositoriesPath = settingsPath.resolve(IdeContext.FOLDER_LEGACY_REPOSITORIES);
4✔
451
    if (Files.isDirectory(legacyRepositoriesPath)) {
5!
452
      return legacyRepositoriesPath;
×
453
    }
454
    return null;
2✔
455
  }
456

457
  /**
458
   * @return the {@link Path} to the {@code settings} folder with the cloned git repository containing the project configuration only if the settings repository
459
   *     is in fact a git repository.
460
   */
461
  Path getSettingsGitRepository();
462

463
  /**
464
   * @return {@code true} if the settings repository is a symlink or a junction.
465
   */
466
  boolean isSettingsRepositorySymlinkOrJunction();
467

468
  /**
469
   * @return the {@link Path} to the file containing the last tracked commit Id of the settings repository.
470
   */
471
  Path getSettingsCommitIdPath();
472

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

492
  /**
493
   * @return the {@link Path} to the {@code conf} folder with instance specific tool configurations and the
494
   *     {@link EnvironmentVariablesType#CONF user specific project configuration}.
495
   */
496
  Path getConfPath();
497

498
  /**
499
   * @return the {@link Path} to the workspace.
500
   * @see #getWorkspaceName()
501
   */
502
  Path getWorkspacePath();
503

504
  /**
505
   * @return the name of the workspace. Defaults to {@link #WORKSPACE_MAIN}.
506
   */
507
  String getWorkspaceName();
508

509
  /**
510
   * @return the value of the system {@link IdeVariables#PATH PATH} variable. It is automatically extended according to the tools available in
511
   *     {@link #getSoftwarePath() software path} unless {@link #getIdeHome() IDE_HOME} was not found.
512
   */
513
  SystemPath getPath();
514

515
  /**
516
   * @return a new {@link ProcessContext} to {@link ProcessContext#run() run} external commands.
517
   */
518
  ProcessContext newProcess();
519

520
  /**
521
   * @param title the {@link IdeProgressBar#getTitle() title}.
522
   * @param size the {@link IdeProgressBar#getMaxSize() expected maximum size}.
523
   * @param unitName the {@link IdeProgressBar#getUnitName() unit name}.
524
   * @param unitSize the {@link IdeProgressBar#getUnitSize() unit size}.
525
   * @return the new {@link IdeProgressBar} to use.
526
   */
527
  IdeProgressBar newProgressBar(String title, long size, String unitName, long unitSize);
528

529
  /**
530
   * @param title the {@link IdeProgressBar#getTitle() title}.
531
   * @param size the {@link IdeProgressBar#getMaxSize() expected maximum size} in bytes.
532
   * @return the new {@link IdeProgressBar} to use.
533
   */
534
  default IdeProgressBar newProgressBarInMib(String title, long size) {
535

536
    if ((size > 0) && (size < 1024)) {
8✔
537
      return new IdeProgressBarNone(title, size, IdeProgressBar.UNIT_NAME_MB, IdeProgressBar.UNIT_SIZE_MB);
8✔
538
    }
539
    return newProgressBar(title, size, IdeProgressBar.UNIT_NAME_MB, IdeProgressBar.UNIT_SIZE_MB);
7✔
540
  }
541

542
  /**
543
   * @param size the {@link IdeProgressBar#getMaxSize() expected maximum size} in bytes.
544
   * @return the new {@link IdeProgressBar} for copy.
545
   */
546
  default IdeProgressBar newProgressBarForDownload(long size) {
547

548
    return newProgressBarInMib(IdeProgressBar.TITLE_DOWNLOADING, size);
5✔
549
  }
550

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

557
    return newProgressBarInMib(IdeProgressBar.TITLE_EXTRACTING, size);
5✔
558
  }
559

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

566
    return newProgressBarInMib(IdeProgressBar.TITLE_COPYING, size);
5✔
567
  }
568

569
  /**
570
   * @return the {@link DirectoryMerger} used to configure and merge the workspace for an {@link com.devonfw.tools.ide.tool.ide.IdeToolCommandlet IDE}.
571
   */
572
  DirectoryMerger getWorkspaceMerger();
573

574
  /**
575
   * @return the {@link Path} to the working directory from where the command is executed.
576
   */
577
  Path getDefaultExecutionDirectory();
578

579
  /**
580
   * @return the {@link IdeSystem} instance wrapping {@link System}.
581
   */
582
  IdeSystem getSystem();
583

584
  /**
585
   * @return the {@link GitContext} used to run several git commands.
586
   */
587
  GitContext getGitContext();
588

589
  /**
590
   * @return the String value for the variable MAVEN_ARGS, or null if called outside an IDEasy installation.
591
   */
592
  default String getMavenArgs() {
593

594
    if (getIdeHome() == null) {
3!
595
      return null;
×
596
    }
597
    Mvn mvn = getCommandletManager().getCommandlet(Mvn.class);
6✔
598
    return mvn.getMavenArgs();
3✔
599
  }
600

601
  /**
602
   * @return the {@link Path} pointing to the maven configuration directory (where "settings.xml" or "settings-security.xml" are located).
603
   */
604
  default Path getMavenConfigurationFolder() {
605

606
    if (getIdeHome() != null) {
3✔
607
      Path confPath = getConfPath();
3✔
608
      Path m2Folder = confPath.resolve(Mvn.MVN_CONFIG_FOLDER);
4✔
609
      if (!Files.isDirectory(m2Folder)) {
5✔
610
        Path m2LegacyFolder = confPath.resolve(Mvn.MVN_CONFIG_LEGACY_FOLDER);
4✔
611
        if (Files.isDirectory(m2LegacyFolder)) {
5!
612
          m2Folder = m2LegacyFolder;
×
613
        } else {
614
          // fallback to USER_HOME/.m2 folder
615
          m2Folder = getUserHome().resolve(Mvn.MVN_CONFIG_LEGACY_FOLDER);
5✔
616
        }
617
      }
618
      return m2Folder;
2✔
619
    }
620
    return null;
2✔
621
  }
622

623
  /**
624
   * Updates the current working directory (CWD) and configures the environment paths according to the specified parameters. This method is central to changing
625
   * the IDE's notion of where it operates, affecting where configurations, workspaces, settings, and other resources are located or loaded from.
626
   *
627
   * @return the current {@link Step} of processing.
628
   */
629
  Step getCurrentStep();
630

631
  /**
632
   * @param name the {@link Step#getName() name} of the new {@link Step}.
633
   * @return the new {@link Step} that has been created and started.
634
   */
635
  default Step newStep(String name) {
636

637
    return newStep(name, Step.NO_PARAMS);
5✔
638
  }
639

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

647
    return newStep(false, name, parameters);
6✔
648
  }
649

650
  /**
651
   * @param silent the {@link Step#isSilent() silent flag}.
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
  Step newStep(boolean silent, String name, Object... parameters);
657

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

666
    setCwd(ideHome, WORKSPACE_MAIN, ideHome);
5✔
667
  }
1✔
668

669
  /**
670
   * Updates the current working directory (CWD) and configures the environment paths according to the specified parameters. This method is central to changing
671
   * the IDE's notion of where it operates, affecting where configurations, workspaces, settings, and other resources are located or loaded from.
672
   *
673
   * @param userDir The path to set as the current working directory.
674
   * @param workspace The name of the workspace within the IDE's environment.
675
   * @param ideHome The path to the IDE home directory.
676
   */
677
  void setCwd(Path userDir, String workspace, Path ideHome);
678

679
  /**
680
   * Finds the path to the Bash executable.
681
   *
682
   * @return the {@link String} to the Bash executable, or {@code null} if Bash is not found
683
   */
684
  String findBash();
685

686
  /**
687
   * Finds the path to the Bash executable.
688
   *
689
   * @return the {@link String} to the Bash executable. Throws an {@link IllegalStateException} if no bash was found.
690
   */
691
  default String findBashRequired() {
692
    String bash = findBash();
3✔
693
    if (bash == null) {
2!
694
      String message = "Could not find bash what is a prerequisite of IDEasy.";
×
695
      if (getSystemInfo().isWindows()) {
×
696
        message = message + "\nPlease install Git for Windows and rerun.";
×
697
      }
698
      throw new IllegalStateException(message);
×
699
    }
700
    return bash;
2✔
701
  }
702

703
  /**
704
   * @return the {@link WindowsPathSyntax} used for {@link Path} conversion or {@code null} for no such conversion (typically if not on Windows).
705
   */
706
  WindowsPathSyntax getPathSyntax();
707

708
  /**
709
   * logs the status of {@link #getIdeHome() IDE_HOME} and {@link #getIdeRoot() IDE_ROOT}.
710
   */
711
  void logIdeHomeAndRootStatus();
712

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

© 2025 Coveralls, Inc