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

devonfw / IDEasy / 13160073324

05 Feb 2025 02:52PM UTC coverage: 68.252% (-0.1%) from 68.379%
13160073324

Pull #1002

github

web-flow
Merge 61eb7829f into 62fa12bac
Pull Request #1002: #786: Upgrade commandlet

2901 of 4667 branches covered (62.16%)

Branch coverage included in aggregate %.

7504 of 10578 relevant lines covered (70.94%)

3.09 hits per line

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

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

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

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

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

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

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

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

53
  /**
54
   * The base folder name of the IDE inside IDE_ROOT. Intentionally starting with an underscore and not a dot (to prevent effects like OS hiding, maven
55
   * filtering, .gitignore, etc.).
56
   *
57
   * @see #getIdeInstallationPath()
58
   */
59
  String FOLDER_IDE_INSTALLATION = "_ide";
60

61
  /**
62
   * The name of the hidden folder for IDE configuration in the users home directory or status information in the IDE_HOME directory.
63
   *
64
   * @see #getUserHomeIde()
65
   */
66
  String FOLDER_DOT_IDE = ".ide";
67

68
  /** The name of the updates folder for temporary data and backup. */
69
  String FOLDER_UPDATES = "updates";
70

71
  /** The name of the volume folder for mounting archives like *.dmg. */
72
  String FOLDER_VOLUME = "volume";
73

74
  /** The name of the backups folder for backup. */
75
  String FOLDER_BACKUPS = "backups";
76

77
  /** The name of the downloads folder. */
78
  String FOLDER_DOWNLOADS = "Downloads";
79

80
  /** The name of the bin folder where executable files are found by default. */
81
  String FOLDER_BIN = "bin";
82

83
  /** The name of the repositories folder where properties files are stores for each repository */
84
  String FOLDER_REPOSITORIES = "repositories";
85

86
  /** The name of the repositories folder where properties files are stores for each repository */
87
  String FOLDER_LEGACY_REPOSITORIES = "projects";
88

89
  /** The name of the Contents folder inside a MacOS app. */
90
  String FOLDER_CONTENTS = "Contents";
91

92
  /** The name of the Resources folder inside a MacOS app. */
93
  String FOLDER_RESOURCES = "Resources";
94

95
  /** The name of the app folder inside a MacOS app. */
96
  String FOLDER_APP = "app";
97

98
  /** The name of the extra folder inside the software folder */
99
  String FOLDER_EXTRA = "extra";
100

101
  /**
102
   * The name of the {@link #getPluginsPath() plugins folder} and also the plugins folder inside the IDE folders of {@link #getSettingsPath() settings} (e.g.
103
   * settings/eclipse/plugins).
104
   */
105
  String FOLDER_PLUGINS = "plugins";
106

107
  /**
108
   * The name of the workspace folder inside the IDE specific {@link #FOLDER_SETTINGS settings} containing the configuration templates in #FOLDER_SETUP
109
   * #FOLDER_UPDATE.
110
   */
111
  String FOLDER_WORKSPACE = "workspace";
112

113
  /**
114
   * The name of the setup folder inside the {@link #FOLDER_WORKSPACE workspace} folder containing the templates for the configuration templates for the initial
115
   * setup of a workspace. This is closely related with the {@link #FOLDER_UPDATE update} folder.
116
   */
117
  String FOLDER_SETUP = "setup";
118

119
  /**
120
   * The name of the update folder inside the {@link #FOLDER_WORKSPACE workspace} folder containing the templates for the configuration templates for the update
121
   * 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
122
   * 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
123
   * for indentation and other code-formatting settings. If all developers in a project team use the same formatter settings, this will actively prevent
124
   * 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
125
   * 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
126
   * 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
127
   * user as needed.
128
   */
129
  String FOLDER_UPDATE = "update";
130

131
  /**
132
   * The name of the folder inside {@link #FOLDER_IDE_INSTALLATION _ide} folder containing internal resources and scripts of IDEasy.
133
   */
134
  String FOLDER_INTERNAL = "internal";
135

136
  /** The file where the installed software version is written to as plain text. */
137
  String FILE_SOFTWARE_VERSION = ".ide.software.version";
138

139
  /** The file where the installed software version is written to as plain text. */
140
  String FILE_LEGACY_SOFTWARE_VERSION = ".devon.software.version";
141

142
  /** The file for the license agreement. */
143
  String FILE_LICENSE_AGREEMENT = ".license.agreement";
144

145
  /** The file extension for a {@link java.util.Properties} file. */
146
  String EXT_PROPERTIES = ".properties";
147

148
  /** The default for {@link #getWorkspaceName()}. */
149
  String WORKSPACE_MAIN = "main";
150

151
  /** The folder with the configuration template files from the settings. */
152
  String FOLDER_TEMPLATES = "templates";
153

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

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

160
  /**
161
   * file containing the current local commit hash of the settings repository.
162
   */
163
  String SETTINGS_COMMIT_ID = ".commit.id";
164

165
  /** The IDEasy ASCII logo. */
166
  String LOGO = """
4✔
167
      __       ___ ___  ___
168
      ╲ ╲     |_ _|   ╲| __|__ _ ____ _
169
       > >     | || |) | _|/ _` (_-< || |
170
      /_/ ___ |___|___/|___╲__,_/__/╲_, |
171
         |___|                       |__/
172
      """.replace('╲', '\\');
2✔
173

174
  /**
175
   * @return {@code true} if {@link #isOfflineMode() offline mode} is active or we are NOT {@link #isOnline() online}, {@code false} otherwise.
176
   */
177
  default boolean isOffline() {
178

179
    return isOfflineMode() || !isOnline();
10!
180
  }
181

182
  /**
183
   * @return {@code true} if we are currently online (Internet access is available), {@code false} otherwise.
184
   */
185
  boolean isOnline();
186

187
  /**
188
   * Print the IDEasy {@link #LOGO logo}.
189
   */
190
  default void printLogo() {
191

192
    info(LOGO);
3✔
193
  }
1✔
194

195
  /**
196
   * Asks the user for a single string input.
197
   *
198
   * @param message The information message to display.
199
   * @param defaultValue The default value to return when no input is provided.
200
   * @return The string input from the user, or the default value if no input is provided.
201
   */
202
  String askForInput(String message, String defaultValue);
203

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

212
  /**
213
   * @param question the question to ask.
214
   * @return {@code true} if the user answered with "yes", {@code false} otherwise ("no").
215
   */
216
  default boolean question(String question) {
217

218
    String yes = "yes";
×
219
    String option = question(question, yes, "no");
×
220
    if (yes.equals(option)) {
×
221
      return true;
×
222
    }
223
    return false;
×
224
  }
225

226
  /**
227
   * @param <O> type of the option. E.g. {@link String}.
228
   * @param question the question to ask.
229
   * @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.
230
   * @return the option selected by the user as answer.
231
   */
232
  @SuppressWarnings("unchecked")
233
  <O> O question(String question, O... options);
234

235
  /**
236
   * 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
237
   * exception is thrown to abort further processing.
238
   *
239
   * @param question the yes/no question to {@link #question(String) ask}.
240
   * @throws CliAbortException if the user answered with "no" and further processing shall be aborted.
241
   */
242
  default void askToContinue(String question) {
243

244
    boolean yesContinue = question(question);
×
245
    if (!yesContinue) {
×
246
      throw new CliAbortException();
×
247
    }
248
  }
×
249

250
  /**
251
   * @param purpose the purpose why Internet connection is required.
252
   * @throws CliException if you are {@link #isOffline() offline}.
253
   */
254
  default void requireOnline(String purpose) {
255

256
    if (isOfflineMode()) {
3!
257
      throw CliOfflineException.ofPurpose(purpose);
3✔
258
    }
259
  }
×
260

261
  /**
262
   * @return the {@link SystemInfo}.
263
   */
264
  SystemInfo getSystemInfo();
265

266
  /**
267
   * @return the {@link EnvironmentVariables} with full inheritance.
268
   */
269
  EnvironmentVariables getVariables();
270

271
  /**
272
   * @return the {@link FileAccess}.
273
   */
274
  FileAccess getFileAccess();
275

276
  /**
277
   * @return the {@link CommandletManager}.
278
   */
279
  CommandletManager getCommandletManager();
280

281
  /**
282
   * @return the default {@link ToolRepository}.
283
   */
284
  ToolRepository getDefaultToolRepository();
285

286
  /**
287
   * @return the {@link CustomToolRepository}.
288
   */
289
  CustomToolRepository getCustomToolRepository();
290

291
  /**
292
   * @return the {@link MavenRepository}.
293
   */
294
  MavenRepository getMavenToolRepository();
295

296
  /**
297
   * @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
298
   *     isolated projects.
299
   * @see com.devonfw.tools.ide.variable.IdeVariables#IDE_HOME
300
   */
301
  Path getIdeHome();
302

303
  /**
304
   * @return the name of the current project.
305
   * @see com.devonfw.tools.ide.variable.IdeVariables#PROJECT_NAME
306
   */
307
  String getProjectName();
308

309
  /**
310
   * @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
311
   *     sub-folder. There is a reserved ".ide" folder where central IDE data is stored such as the {@link #getUrlsPath() download metadata} and the central
312
   *     software repository.
313
   * @see com.devonfw.tools.ide.variable.IdeVariables#IDE_ROOT
314
   */
315
  Path getIdeRoot();
316

317
  /**
318
   * @return the {@link Path} to the {@link #FOLDER_IDE_INSTALLATION IDE installation}.
319
   * @see #getIdeRoot()
320
   * @see #FOLDER_IDE_INSTALLATION
321
   */
322
  Path getIdeInstallationPath();
323

324
  /**
325
   * @return the current working directory ("user.dir"). This is the directory where the user's shell was located when the IDE CLI was invoked.
326
   */
327
  Path getCwd();
328

329
  /**
330
   * @return the {@link Path} for the temporary directory to use. Will be different from the OS specific temporary directory (java.io.tmpDir).
331
   */
332
  Path getTempPath();
333

334
  /**
335
   * @return the {@link Path} for the temporary download directory to use.
336
   */
337
  Path getTempDownloadPath();
338

339
  /**
340
   * @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
341
   *     download tools.
342
   * @see com.devonfw.tools.ide.url.model.folder.UrlRepository
343
   */
344
  Path getUrlsPath();
345

346
  /**
347
   * @return the {@link UrlMetadata}. Will be lazily instantiated and thereby automatically be cloned or pulled (by default).
348
   */
349
  UrlMetadata getUrls();
350

351
  /**
352
   * @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
353
   *     the same artifact is requested again it will be taken from the cache to avoid downloading it again.
354
   */
355
  Path getDownloadPath();
356

357
  /**
358
   * @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
359
   *     {@link #getSoftwareRepositoryPath() software repository} as sub-folder named after the according tool.
360
   */
361
  Path getSoftwarePath();
362

363
  /**
364
   * @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
365
   *     here from the {@link #getSoftwareRepositoryPath() software repository} as sub-folder named after the according tool.
366
   */
367
  Path getSoftwareExtraPath();
368

369
  /**
370
   * @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
371
   *     are shared among all IDE instances (see {@link #getIdeHome() IDE_HOME}) via symbolic links (see {@link #getSoftwarePath()}). Therefore this repository
372
   *     follows the sub-folder structure {@code «repository»/«tool»/«edition»/«version»/}. So multiple versions of the same tool exist here as different
373
   *     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
374
   *     of the scope of this folders.
375
   */
376
  Path getSoftwareRepositoryPath();
377

378
  /**
379
   * @return the {@link Path} to the {@link #FOLDER_PLUGINS plugins folder} inside {@link #getIdeHome() IDE_HOME}. All plugins of the IDE instance will be
380
   *     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.
381
   */
382
  Path getPluginsPath();
383

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

393
  /**
394
   * @return the {@link Path} to the users home directory. Typically initialized via the {@link System#getProperty(String) system property} "user.home".
395
   * @see com.devonfw.tools.ide.variable.IdeVariables#HOME
396
   */
397
  Path getUserHome();
398

399
  /**
400
   * @return the {@link Path} to the ".ide" subfolder in the {@link #getUserHome() users home directory}.
401
   */
402
  Path getUserHomeIde();
403

404
  /**
405
   * @return the {@link Path} to the {@link #FOLDER_SETTINGS settings} folder with the cloned git repository containing the project configuration.
406
   */
407
  Path getSettingsPath();
408

409
  /**
410
   * @return the {@link Path} to the {@link #FOLDER_REPOSITORIES repositories} folder with legacy fallback if not present or {@code null} if not found.
411
   */
412
  default Path getRepositoriesPath() {
413

414
    Path settingsPath = getSettingsPath();
3✔
415
    if (settingsPath == null) {
2!
416
      return null;
×
417
    }
418
    Path repositoriesPath = settingsPath.resolve(IdeContext.FOLDER_REPOSITORIES);
4✔
419
    if (Files.isDirectory(repositoriesPath)) {
5✔
420
      return repositoriesPath;
2✔
421
    }
422
    Path legacyRepositoriesPath = settingsPath.resolve(IdeContext.FOLDER_LEGACY_REPOSITORIES);
4✔
423
    if (Files.isDirectory(legacyRepositoriesPath)) {
5!
424
      return legacyRepositoriesPath;
×
425
    }
426
    return null;
2✔
427
  }
428

429
  /**
430
   * @return the {@link Path} to the {@code settings} folder with the cloned git repository containing the project configuration only if the settings repository
431
   *     is in fact a git repository.
432
   */
433
  Path getSettingsGitRepository();
434

435
  /**
436
   * @return {@code true} if the settings repository is a symlink or a junction.
437
   */
438
  boolean isSettingsRepositorySymlinkOrJunction();
439

440
  /**
441
   * @return the {@link Path} to the file containing the last tracked commit Id of the settings repository.
442
   */
443
  Path getSettingsCommitIdPath();
444

445
  /**
446
   * @return the {@link Path} to the templates folder inside the {@link #getSettingsPath() settings}. The relative directory structure in this templates folder
447
   *     is to be applied to {@link #getIdeHome() IDE_HOME} when the project is set up.
448
   */
449
  default Path getSettingsTemplatePath() {
450
    Path settingsFolder = getSettingsPath();
3✔
451
    Path templatesFolder = settingsFolder.resolve(IdeContext.FOLDER_TEMPLATES);
4✔
452
    if (!Files.isDirectory(templatesFolder)) {
5✔
453
      Path templatesFolderLegacy = settingsFolder.resolve(IdeContext.FOLDER_LEGACY_TEMPLATES);
4✔
454
      if (Files.isDirectory(templatesFolderLegacy)) {
5!
455
        templatesFolder = templatesFolderLegacy;
×
456
      } else {
457
        warning("No templates found in settings git repo neither in {} nor in {} - configuration broken", templatesFolder, templatesFolderLegacy);
13✔
458
        return null;
2✔
459
      }
460
    }
461
    return templatesFolder;
2✔
462
  }
463

464
  /**
465
   * @return the {@link Path} to the {@code conf} folder with instance specific tool configurations and the
466
   *     {@link EnvironmentVariablesType#CONF user specific project configuration}.
467
   */
468
  Path getConfPath();
469

470
  /**
471
   * @return the {@link Path} to the workspace.
472
   * @see #getWorkspaceName()
473
   */
474
  Path getWorkspacePath();
475

476
  /**
477
   * @return the name of the workspace. Defaults to {@link #WORKSPACE_MAIN}.
478
   */
479
  String getWorkspaceName();
480

481
  /**
482
   * @return the value of the system {@link IdeVariables#PATH PATH} variable. It is automatically extended according to the tools available in
483
   *     {@link #getSoftwarePath() software path} unless {@link #getIdeHome() IDE_HOME} was not found.
484
   */
485
  SystemPath getPath();
486

487
  /**
488
   * @return a new {@link ProcessContext} to {@link ProcessContext#run() run} external commands.
489
   */
490
  ProcessContext newProcess();
491

492
  /**
493
   * @param title the {@link IdeProgressBar#getTitle() title}.
494
   * @param size the {@link IdeProgressBar#getMaxSize() expected maximum size}.
495
   * @param unitName the {@link IdeProgressBar#getUnitName() unit name}.
496
   * @param unitSize the {@link IdeProgressBar#getUnitSize() unit size}.
497
   * @return the new {@link IdeProgressBar} to use.
498
   */
499
  IdeProgressBar newProgressBar(String title, long size, String unitName, long unitSize);
500

501
  /**
502
   * @param title the {@link IdeProgressBar#getTitle() title}.
503
   * @param size the {@link IdeProgressBar#getMaxSize() expected maximum size} in bytes.
504
   * @return the new {@link IdeProgressBar} to use.
505
   */
506
  default IdeProgressBar newProgressBarInMib(String title, long size) {
507

508
    return newProgressBar(title, size, "MiB", 1048576);
7✔
509
  }
510

511
  /**
512
   * @param size the {@link IdeProgressBar#getMaxSize() expected maximum size} in bytes.
513
   * @return the new {@link IdeProgressBar} for copy.
514
   */
515
  default IdeProgressBar newProgressBarForDownload(long size) {
516

517
    return newProgressBarInMib(IdeProgressBar.TITLE_DOWNLOADING, size);
5✔
518
  }
519

520
  /**
521
   * @param size the {@link IdeProgressBar#getMaxSize() expected maximum size} in bytes.
522
   * @return the new {@link IdeProgressBar} for extracting.
523
   */
524
  default IdeProgressBar newProgressbarForExtracting(long size) {
525

526
    return newProgressBarInMib(IdeProgressBar.TITLE_EXTRACTING, size);
5✔
527
  }
528

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

535
    return newProgressBarInMib(IdeProgressBar.TITLE_COPYING, size);
5✔
536
  }
537

538
  /**
539
   * @return the {@link DirectoryMerger} used to configure and merge the workspace for an {@link com.devonfw.tools.ide.tool.ide.IdeToolCommandlet IDE}.
540
   */
541
  DirectoryMerger getWorkspaceMerger();
542

543
  /**
544
   * @return the {@link Path} to the working directory from where the command is executed.
545
   */
546
  Path getDefaultExecutionDirectory();
547

548
  /**
549
   * @return the {@link IdeSystem} instance wrapping {@link System}.
550
   */
551
  IdeSystem getSystem();
552

553
  /**
554
   * @return the {@link GitContext} used to run several git commands.
555
   */
556
  GitContext getGitContext();
557

558
  /**
559
   * @return the String value for the variable MAVEN_ARGS, or null if called outside an IDEasy installation.
560
   */
561
  default String getMavenArgs() {
562

563
    if (getIdeHome() == null) {
3!
564
      return null;
×
565
    }
566
    Mvn mvn = getCommandletManager().getCommandlet(Mvn.class);
6✔
567
    return mvn.getMavenArgs();
3✔
568
  }
569

570
  /**
571
   * @return the {@link Path} pointing to the maven configuration directory (where "settings.xml" or "settings-security.xml" are located).
572
   */
573
  default Path getMavenConfigurationFolder() {
574

575
    if (getIdeHome() != null) {
3!
576
      Path confPath = getConfPath();
3✔
577
      Path m2Folder = confPath.resolve(Mvn.MVN_CONFIG_FOLDER);
4✔
578
      if (!Files.isDirectory(m2Folder)) {
5✔
579
        Path m2LegacyFolder = confPath.resolve(Mvn.MVN_CONFIG_LEGACY_FOLDER);
4✔
580
        if (Files.isDirectory(m2LegacyFolder)) {
5!
581
          m2Folder = m2LegacyFolder;
×
582
        } else {
583
          // fallback to USER_HOME/.m2 folder
584
          m2Folder = getUserHome().resolve(Mvn.MVN_CONFIG_LEGACY_FOLDER);
5✔
585
        }
586
      }
587
      return m2Folder;
2✔
588
    }
589
    return null;
×
590
  }
591

592
  /**
593
   * Updates the current working directory (CWD) and configures the environment paths according to the specified parameters. This method is central to changing
594
   * the IDE's notion of where it operates, affecting where configurations, workspaces, settings, and other resources are located or loaded from.
595
   *
596
   * @return the current {@link Step} of processing.
597
   */
598
  Step getCurrentStep();
599

600
  /**
601
   * @param name the {@link Step#getName() name} of the new {@link Step}.
602
   * @return the new {@link Step} that has been created and started.
603
   */
604
  default Step newStep(String name) {
605

606
    return newStep(name, Step.NO_PARAMS);
5✔
607
  }
608

609
  /**
610
   * @param name the {@link Step#getName() name} of the new {@link Step}.
611
   * @param parameters the {@link Step#getParameter(int) parameters} of the {@link Step}.
612
   * @return the new {@link Step} that has been created and started.
613
   */
614
  default Step newStep(String name, Object... parameters) {
615

616
    return newStep(false, name, parameters);
6✔
617
  }
618

619
  /**
620
   * @param silent the {@link Step#isSilent() silent flag}.
621
   * @param name the {@link Step#getName() name} of the new {@link Step}.
622
   * @param parameters the {@link Step#getParameter(int) parameters} of the {@link Step}.
623
   * @return the new {@link Step} that has been created and started.
624
   */
625
  Step newStep(boolean silent, String name, Object... parameters);
626

627
  /**
628
   * Updates the current working directory (CWD) and configures the environment paths according to the specified parameters. This method is central to changing
629
   * the IDE's notion of where it operates, affecting where configurations, workspaces, settings, and other resources are located or loaded from.
630
   *
631
   * @param ideHome The path to the IDE home directory.
632
   */
633
  default void setIdeHome(Path ideHome) {
634

635
    setCwd(ideHome, WORKSPACE_MAIN, ideHome);
5✔
636
  }
1✔
637

638
  /**
639
   * Updates the current working directory (CWD) and configures the environment paths according to the specified parameters. This method is central to changing
640
   * the IDE's notion of where it operates, affecting where configurations, workspaces, settings, and other resources are located or loaded from.
641
   *
642
   * @param userDir The path to set as the current working directory.
643
   * @param workspace The name of the workspace within the IDE's environment.
644
   * @param ideHome The path to the IDE home directory.
645
   */
646
  void setCwd(Path userDir, String workspace, Path ideHome);
647

648
  /**
649
   * Finds the path to the Bash executable.
650
   *
651
   * @return the {@link String} to the Bash executable, or {@code null} if Bash is not found
652
   */
653
  String findBash();
654

655
  /**
656
   * Finds the path to the Bash executable.
657
   *
658
   * @return the {@link String} to the Bash executable. Throws an {@link IllegalStateException} if no bash was found.
659
   */
660
  default String findBashRequired() {
661
    String bash = findBash();
3✔
662
    if (bash == null) {
2!
663
      String message = "Could not find bash what is a prerequisite of IDEasy.";
×
664
      if (getSystemInfo().isWindows()) {
×
665
        message = message + "\nPlease install Git for Windows and rerun.";
×
666
      }
667
      throw new IllegalStateException(message);
×
668
    }
669
    return bash;
2✔
670
  }
671

672
  /**
673
   * @return the {@link WindowsPathSyntax} used for {@link Path} conversion or {@code null} for no such conversion (typically if not on Windows).
674
   */
675
  WindowsPathSyntax getPathSyntax();
676

677
  /**
678
   * logs the status of {@link #getIdeHome() IDE_HOME} and {@link #getIdeRoot() IDE_ROOT}.
679
   */
680
  void logIdeHomeAndRootStatus();
681

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