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

devonfw / IDEasy / 19750767554

28 Nov 2025 12:35AM UTC coverage: 69.441% (+0.3%) from 69.136%
19750767554

Pull #1614

github

web-flow
Merge aa8109e1d into 6f933cdda
Pull Request #1614: #1613: fixed duplicated CVE check and refactored installation routine

3694 of 5847 branches covered (63.18%)

Branch coverage included in aggregate %.

9615 of 13319 relevant lines covered (72.19%)

3.14 hits per line

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

81.32
cli/src/main/java/com/devonfw/tools/ide/tool/LocalToolCommandlet.java
1
package com.devonfw.tools.ide.tool;
2

3
import java.nio.file.Files;
4
import java.nio.file.LinkOption;
5
import java.nio.file.Path;
6
import java.util.Collection;
7
import java.util.Set;
8
import java.util.function.Predicate;
9

10
import com.devonfw.tools.ide.common.Tag;
11
import com.devonfw.tools.ide.context.IdeContext;
12
import com.devonfw.tools.ide.io.FileAccess;
13
import com.devonfw.tools.ide.process.ProcessContext;
14
import com.devonfw.tools.ide.step.Step;
15
import com.devonfw.tools.ide.tool.repository.ToolRepository;
16
import com.devonfw.tools.ide.url.model.file.json.ToolDependency;
17
import com.devonfw.tools.ide.version.GenericVersionRange;
18
import com.devonfw.tools.ide.version.VersionIdentifier;
19
import com.devonfw.tools.ide.version.VersionRange;
20

21
/**
22
 * {@link ToolCommandlet} that is installed locally into the IDEasy.
23
 */
24
public abstract class LocalToolCommandlet extends ToolCommandlet {
1✔
25

26
  /**
27
   * The constructor.
28
   *
29
   * @param context the {@link IdeContext}.
30
   * @param tool the {@link #getName() tool name}.
31
   * @param tags the {@link #getTags() tags} classifying the tool. Should be created via {@link Set#of(Object) Set.of} method.
32
   */
33
  public LocalToolCommandlet(IdeContext context, String tool, Set<Tag> tags) {
34

35
    super(context, tool, tags);
5✔
36
  }
1✔
37

38
  /**
39
   * @return the {@link Path} where the tool is located (installed).
40
   */
41
  public Path getToolPath() {
42
    if (this.context.getSoftwarePath() == null) {
4!
43
      return null;
×
44
    }
45
    return this.context.getSoftwarePath().resolve(getName());
7✔
46
  }
47

48
  /**
49
   * @return the {@link Path} where the executables of the tool can be found. Typically, a "bin" folder inside {@link #getToolPath() tool path}.
50
   */
51
  public Path getToolBinPath() {
52

53
    Path toolPath = getToolPath();
3✔
54
    Path binPath = this.context.getFileAccess().findFirst(toolPath, path -> path.getFileName().toString().equals("bin"), false);
14✔
55
    if ((binPath != null) && Files.isDirectory(binPath)) {
7!
56
      return binPath;
2✔
57
    }
58
    return toolPath;
2✔
59
  }
60

61
  /**
62
   * @return {@code true} to ignore a missing {@link IdeContext#FILE_SOFTWARE_VERSION software version file} in an installation, {@code false} delete the broken
63
   *     installation (default).
64
   */
65
  protected boolean isIgnoreMissingSoftwareVersionFile() {
66

67
    return false;
×
68
  }
69

70
  /**
71
   * @deprecated will be removed once all "dependencies.json" are created in ide-urls.
72
   */
73
  @Deprecated
74
  protected void installDependencies() {
75

76
  }
1✔
77

78
  @Override
79
  protected ToolInstallation doInstall(ToolInstallRequest request) {
80

81
    installDependencies();
2✔
82
    Step step = request.getStep();
3✔
83
    if (step == null) {
2!
84
      return doInstallStep(request);
4✔
85
    } else {
86
      return step.call(() -> doInstallStep(request),
×
87
          () -> createExistingToolInstallation(request));
×
88
    }
89
  }
90

91
  private ToolInstallation doInstallStep(ToolInstallRequest request) {
92

93
    // install configured version of our tool in the software repository if not already installed
94
    ToolInstallation installation = installTool(request);
4✔
95

96
    // check if we already have this version installed (linked) locally in IDE_HOME/software
97
    VersionIdentifier resolvedVersion = installation.resolvedVersion();
3✔
98
    if (request.isAlreadyInstalled(this.context.isSkipUpdatesMode())) {
6✔
99
      // TODO: are we logging this multiple times?
100
      logToolAlreadyInstalled(request);
3✔
101
      return installation;
2✔
102
    }
103
    FileAccess fileAccess = this.context.getFileAccess();
4✔
104
    boolean ignoreSoftwareRepo = isIgnoreSoftwareRepo();
3✔
105
    if (!ignoreSoftwareRepo) {
2✔
106
      Path toolPath = getToolPath();
3✔
107
      // we need to link the version or update the link.
108
      if (Files.exists(toolPath, LinkOption.NOFOLLOW_LINKS)) {
9✔
109
        fileAccess.backup(toolPath);
4✔
110
      }
111
      fileAccess.mkdirs(toolPath.getParent());
4✔
112
      fileAccess.symlink(installation.linkDir(), toolPath);
5✔
113
    }
114
    if (installation.binDir() != null) {
3!
115
      this.context.getPath().setPath(this.tool, installation.binDir());
8✔
116
    }
117
    postInstall(true, request.getProcessContext());
5✔
118
    ToolEditionAndVersion installed = request.getInstalled();
3✔
119
    GenericVersionRange installedVersion = null;
2✔
120
    if (installed != null) {
2!
121
      installedVersion = installed.getVersion();
3✔
122
    }
123
    ToolEditionAndVersion requested = request.getRequested();
3✔
124
    ToolEdition toolEdition = requested.getEdition();
3✔
125
    Step step = request.getStep();
3✔
126
    if (installedVersion == null) {
2✔
127
      asSuccess(step).log("Successfully installed {} in version {}", toolEdition, resolvedVersion);
17✔
128
    } else {
129
      asSuccess(step).log("Successfully installed {} in version {} replacing previous version {} of {}", toolEdition, resolvedVersion,
23✔
130
          installedVersion, installed.getEdition());
2✔
131
    }
132
    return installation;
2✔
133
  }
134

135
  /**
136
   * Determines whether this tool should be installed directly in the software folder or in the software repository.
137
   *
138
   * @return {@code true} if the tool should be installed directly in the software folder, ignoring the central software repository; {@code false} if the tool
139
   *     should be installed in the central software repository (default behavior).
140
   */
141
  protected boolean isIgnoreSoftwareRepo() {
142

143
    return false;
2✔
144
  }
145

146
  /**
147
   * Performs the installation of the {@link #getName() tool} together with the environment context  managed by this
148
   * {@link com.devonfw.tools.ide.commandlet.Commandlet}.
149
   *
150
   * @param request the {@link ToolInstallRequest}.
151
   * @return the resulting {@link ToolInstallation}.
152
   */
153
  public ToolInstallation installTool(ToolInstallRequest request) {
154

155
    // TODO
156
    completeRequest(request);
3✔
157
    ToolEditionAndVersion requested = request.getRequested();
3✔
158
    ToolEdition toolEdition = requested.getEdition();
3✔
159
    assert (toolEdition.tool().equals(this.tool)) : "Mismatch " + this.tool + " != " + toolEdition.tool();
7!
160
    String edition = toolEdition.edition();
3✔
161
    boolean skipSuggestions = false;
2✔
162
    VersionIdentifier resolvedVersion;
163
    if (this.context.isSkipUpdatesMode() && request.isAlreadyInstalled(true)) {
8✔
164
      requested.setResolvedVersion(request.getInstalled().getResolvedVersion());
5✔
165
      skipSuggestions = true;
2✔
166
    }
167
    resolvedVersion = cveCheck(request, skipSuggestions);
5✔
168
    ProcessContext processContext = request.getProcessContext();
3✔
169
    installToolDependencies(request);
3✔
170

171
    // cveCheck might have changed resolvedVersion so let us re-check...
172
    if (request.isAlreadyInstalled(this.context.isSkipUpdatesMode())) {
6✔
173
      return toolAlreadyInstalled(request);
4✔
174
    }
175
    Path installationPath = getInstallationPath(edition, resolvedVersion);
5✔
176

177
    boolean additionalInstallation = request.isAdditionalInstallation();
3✔
178
    boolean ignoreSoftwareRepo = isIgnoreSoftwareRepo();
3✔
179
    Path toolVersionFile = installationPath.resolve(IdeContext.FILE_SOFTWARE_VERSION);
4✔
180
    FileAccess fileAccess = this.context.getFileAccess();
4✔
181
    if (Files.isDirectory(installationPath)) {
5✔
182
      if (Files.exists(toolVersionFile)) {
5!
183
        if (!ignoreSoftwareRepo) {
2✔
184
          assert resolvedVersion.equals(getInstalledVersion(installationPath)) :
7!
185
              "Found version " + getInstalledVersion(installationPath) + " in " + toolVersionFile + " but expected " + resolvedVersion;
×
186
          this.context.debug("Version {} of tool {} is already installed at {}", resolvedVersion, toolEdition, installationPath);
18✔
187
          return createToolInstallation(installationPath, resolvedVersion, false, processContext, additionalInstallation);
8✔
188
        }
189
      } else {
190
        // Makes sure that IDEasy will not delete itself
191
        if (this.tool.equals(IdeasyCommandlet.TOOL_NAME)) {
×
192
          this.context.warning("Your IDEasy installation is missing the version file at {}", toolVersionFile);
×
193
          return createToolInstallation(installationPath, resolvedVersion, false, processContext, additionalInstallation);
×
194
        } else if (!isIgnoreMissingSoftwareVersionFile()) {
×
195
          this.context.warning("Deleting corrupted installation at {}", installationPath);
×
196
          fileAccess.delete(installationPath);
×
197
        }
198
      }
199
    }
200
    performToolInstallation(request, installationPath);
4✔
201
    return createToolInstallation(installationPath, resolvedVersion, true, processContext, additionalInstallation);
8✔
202
  }
203

204
  /**
205
   * Performs the actual installation of the {@link #getName() tool} by downloading its binary, optionally extracting it, backing up any existing installation,
206
   * and writing the version file.
207
   * <p>
208
   * This method assumes that the version has already been resolved and dependencies installed. It handles the final steps of placing the tool into the
209
   * appropriate installation directory.
210
   *
211
   * @param request the {@link ToolInstallRequest}.
212
   * @param installationPath the target {@link Path} where the {@link #getName() tool} should be installed.
213
   */
214
  protected void performToolInstallation(ToolInstallRequest request, Path installationPath) {
215

216
    FileAccess fileAccess = this.context.getFileAccess();
4✔
217
    ToolEditionAndVersion requested = request.getRequested();
3✔
218
    VersionIdentifier resolvedVersion = requested.getResolvedVersion();
3✔
219
    Path downloadedToolFile = downloadTool(requested.getEdition().edition(), resolvedVersion);
7✔
220
    boolean extract = isExtract();
3✔
221
    if (!extract) {
2✔
222
      this.context.trace("Extraction is disabled for '{}' hence just moving the downloaded file {}.", this.tool, downloadedToolFile);
15✔
223
    }
224
    if (Files.isDirectory(installationPath)) {
5!
225
      if (this.tool.equals(IdeasyCommandlet.TOOL_NAME)) {
×
226
        this.context.warning("Your IDEasy installation is missing the version file.");
×
227
      } else {
228
        fileAccess.backup(installationPath);
×
229
      }
230
    }
231
    fileAccess.mkdirs(installationPath.getParent());
4✔
232
    fileAccess.extract(downloadedToolFile, installationPath, this::postExtract, extract);
7✔
233
    this.context.writeVersionFile(resolvedVersion, installationPath);
5✔
234
    this.context.debug("Installed {} in version {} at {}", this.tool, resolvedVersion, installationPath);
19✔
235
  }
1✔
236

237
  /**
238
   * @param edition the {@link #getConfiguredEdition() tool edition} to download.
239
   * @param resolvedVersion the resolved {@link VersionIdentifier version} to download.
240
   * @return the {@link Path} to the downloaded release file.
241
   */
242
  protected Path downloadTool(String edition, VersionIdentifier resolvedVersion) {
243
    return getToolRepository().download(this.tool, edition, resolvedVersion, this);
9✔
244
  }
245

246
  /**
247
   * Install this tool as dependency of another tool.
248
   *
249
   * @param versionRange the required {@link VersionRange}. See {@link ToolDependency#versionRange()}.
250
   * @param parentRequest the {@link ToolInstallRequest} of the tool causing this dependency.
251
   * @return the corresponding {@link ToolInstallation}.
252
   */
253
  public ToolInstallation installAsDependency(VersionRange versionRange, ToolInstallRequest parentRequest) {
254
    ToolInstallRequest request = new ToolInstallRequest(parentRequest);
5✔
255
    ToolEditionAndVersion requested = new ToolEditionAndVersion(getToolWithConfiguredEdition());
6✔
256
    request.setRequested(requested);
3✔
257
    VersionIdentifier configuredVersion = getConfiguredVersion();
3✔
258
    if (versionRange.contains(configuredVersion)) {
4✔
259
      // prefer configured version if contained in version range
260
      requested.setVersion(configuredVersion);
3✔
261
      // return install(true, configuredVersion, processContext, null);
262
      return install(request);
4✔
263
    } else {
264
      if (isIgnoreSoftwareRepo()) {
3!
265
        throw new IllegalStateException(
×
266
            "Cannot satisfy dependency to " + this.tool + " in version " + versionRange + " since it is conflicting with configured version "
267
                + configuredVersion
268
                + " and this tool does not support the software repository.");
269
      }
270
      this.context.info(
9✔
271
          "The tool {} requires {} in the version range {}, but your project uses version {}, which does not match."
272
              + " Therefore, we install a compatible version in that range.",
273
          parentRequest.getRequested().getEdition(), this.tool, versionRange, configuredVersion);
16✔
274
      requested.setVersion(versionRange);
3✔
275
      return installTool(request);
4✔
276
    }
277
  }
278

279
  /**
280
   * Installs the tool dependencies for the current tool.
281
   *
282
   * @param request the {@link ToolInstallRequest}.
283
   */
284
  protected void installToolDependencies(ToolInstallRequest request) {
285

286
    ToolEditionAndVersion requested = request.getRequested();
3✔
287
    VersionIdentifier version = requested.getResolvedVersion();
3✔
288
    ToolEdition toolEdition = requested.getEdition();
3✔
289
    Collection<ToolDependency> dependencies = getToolRepository().findDependencies(this.tool, toolEdition.edition(), version);
9✔
290
    int size = dependencies.size();
3✔
291
    this.context.debug("Tool {} has {} other tool(s) as dependency", toolEdition, size);
15✔
292
    for (ToolDependency dependency : dependencies) {
10✔
293
      this.context.trace("Ensuring dependency {} for tool {}", dependency.tool(), toolEdition);
15✔
294
      LocalToolCommandlet dependencyTool = this.context.getCommandletManager().getRequiredLocalToolCommandlet(dependency.tool());
7✔
295
      dependencyTool.installAsDependency(dependency.versionRange(), request);
6✔
296
    }
1✔
297
  }
1✔
298

299
  /**
300
   * Post-extraction hook that can be overridden to add custom processing after unpacking and before moving to the final destination folder.
301
   *
302
   * @param extractedDir the {@link Path} to the folder with the unpacked tool.
303
   */
304
  protected void postExtract(Path extractedDir) {
305

306
  }
1✔
307

308
  @Override
309
  public VersionIdentifier getInstalledVersion() {
310

311
    return getInstalledVersion(getToolPath());
5✔
312
  }
313

314
  /**
315
   * @param toolPath the installation {@link Path} where to find the version file.
316
   * @return the currently installed {@link VersionIdentifier version} of this tool or {@code null} if not installed.
317
   */
318
  protected VersionIdentifier getInstalledVersion(Path toolPath) {
319

320
    if (isToolNotInstalled(toolPath)) {
4✔
321
      return null;
2✔
322
    }
323
    Path toolVersionFile = toolPath.resolve(IdeContext.FILE_SOFTWARE_VERSION);
4✔
324
    if (!Files.exists(toolVersionFile)) {
5✔
325
      Path legacyToolVersionFile = toolPath.resolve(IdeContext.FILE_LEGACY_SOFTWARE_VERSION);
4✔
326
      if (Files.exists(legacyToolVersionFile)) {
5!
327
        toolVersionFile = legacyToolVersionFile;
3✔
328
      } else {
329
        this.context.warning("Tool {} is missing version file in {}", getName(), toolVersionFile);
×
330
        return null;
×
331
      }
332
    }
333
    String version = this.context.getFileAccess().readFileContent(toolVersionFile).trim();
7✔
334
    return VersionIdentifier.of(version);
3✔
335
  }
336

337
  @Override
338
  public String getInstalledEdition() {
339

340
    return getInstalledEdition(getToolPath());
5✔
341
  }
342

343
  /**
344
   * @param toolPath the installation {@link Path} where to find currently installed tool. The name of the parent directory of the real path corresponding
345
   *     to the passed {@link Path path} must be the name of the edition.
346
   * @return the installed edition of this tool or {@code null} if not installed.
347
   */
348
  private String getInstalledEdition(Path toolPath) {
349
    if (isToolNotInstalled(toolPath)) {
4✔
350
      return null;
2✔
351
    }
352
    Path realPath = this.context.getFileAccess().toRealPath(toolPath);
6✔
353
    // if the realPath changed, a link has been resolved
354
    if (realPath.equals(toolPath)) {
4✔
355
      if (!isIgnoreSoftwareRepo()) {
3!
356
        this.context.warning("Tool {} is not installed via software repository (maybe from devonfw-ide). Please consider reinstalling it.", this.tool);
11✔
357
      }
358
      // I do not see any reliable way how we could determine the edition of a tool that does not use software repo or that was installed by devonfw-ide
359
      return getConfiguredEdition();
3✔
360
    }
361
    Path toolRepoFolder = context.getSoftwareRepositoryPath().resolve(ToolRepository.ID_DEFAULT).resolve(this.tool);
9✔
362
    String edition = getEdition(toolRepoFolder, realPath);
5✔
363
    if (edition == null) {
2!
364
      edition = this.tool;
×
365
    }
366
    if (!getToolRepository().getSortedEditions(this.tool).contains(edition)) {
8✔
367
      this.context.warning("Undefined edition {} of tool {}", edition, this.tool);
15✔
368
    }
369
    return edition;
2✔
370
  }
371

372
  private String getEdition(Path toolRepoFolder, Path toolInstallFolder) {
373

374
    int toolRepoNameCount = toolRepoFolder.getNameCount();
3✔
375
    int toolInstallNameCount = toolInstallFolder.getNameCount();
3✔
376
    if (toolRepoNameCount < toolInstallNameCount) {
3!
377
      // ensure toolInstallFolder starts with $IDE_ROOT/_ide/software/default/«tool»
378
      for (int i = 0; i < toolRepoNameCount; i++) {
7✔
379
        if (!toolRepoFolder.getName(i).toString().equals(toolInstallFolder.getName(i).toString())) {
10!
380
          return null;
×
381
        }
382
      }
383
      return toolInstallFolder.getName(toolRepoNameCount).toString();
5✔
384
    }
385
    return null;
×
386
  }
387

388
  private Path getInstalledSoftwareRepoPath(Path toolPath) {
389
    if (isToolNotInstalled(toolPath)) {
4!
390
      return null;
×
391
    }
392
    Path installPath = this.context.getFileAccess().toRealPath(toolPath);
6✔
393
    // if the installPath changed, a link has been resolved
394
    if (installPath.equals(toolPath)) {
4!
395
      if (!isIgnoreSoftwareRepo()) {
×
396
        this.context.warning("Tool {} is not installed via software repository (maybe from devonfw-ide). Please consider reinstalling it.", this.tool);
×
397
      }
398
      // I do not see any reliable way how we could determine the edition of a tool that does not use software repo or that was installed by devonfw-ide
399
      return null;
×
400
    }
401
    installPath = getValidInstalledSoftwareRepoPath(installPath, context.getSoftwareRepositoryPath());
7✔
402
    return installPath;
2✔
403
  }
404

405
  Path getValidInstalledSoftwareRepoPath(Path installPath, Path softwareRepoPath) {
406
    int softwareRepoNameCount = softwareRepoPath.getNameCount();
3✔
407
    int toolInstallNameCount = installPath.getNameCount();
3✔
408
    int targetToolInstallNameCount = softwareRepoNameCount + 4;
4✔
409

410
    // installPath can't be shorter than softwareRepoPath
411
    if (toolInstallNameCount < softwareRepoNameCount) {
3!
412
      this.context.warning("The installation path is not located within the software repository {}.", installPath);
×
413
      return null;
×
414
    }
415
    // ensure installPath starts with $IDE_ROOT/_ide/software/
416
    for (int i = 0; i < softwareRepoNameCount; i++) {
7✔
417
      if (!softwareRepoPath.getName(i).toString().equals(installPath.getName(i).toString())) {
10✔
418
        this.context.warning("The installation path is not located within the software repository {}.", installPath);
10✔
419
        return null;
2✔
420
      }
421
    }
422
    // return $IDE_ROOT/_ide/software/«id»/«tool»/«edition»/«version»
423
    if (toolInstallNameCount == targetToolInstallNameCount) {
3✔
424
      return installPath;
2✔
425
    } else if (toolInstallNameCount > targetToolInstallNameCount) {
3✔
426
      Path validInstallPath = installPath;
2✔
427
      for (int i = 0; i < toolInstallNameCount - targetToolInstallNameCount; i++) {
9✔
428
        validInstallPath = validInstallPath.getParent();
3✔
429
      }
430
      return validInstallPath;
2✔
431
    } else {
432
      this.context.warning("The installation path is faulty {}.", installPath);
10✔
433
      return null;
2✔
434
    }
435
  }
436

437
  private boolean isToolNotInstalled(Path toolPath) {
438

439
    if ((toolPath == null) || !Files.isDirectory(toolPath)) {
7!
440
      this.context.debug("Tool {} not installed in {}", this.tool, toolPath);
15✔
441
      return true;
2✔
442
    }
443
    return false;
2✔
444
  }
445

446
  @Override
447
  public void uninstall() {
448
    try {
449
      Path toolPath = getToolPath();
3✔
450
      if (!Files.exists(toolPath)) {
5!
451
        this.context.warning("An installed version of {} does not exist.", this.tool);
×
452
        return;
×
453
      }
454
      if (this.context.isForceMode() && !isIgnoreSoftwareRepo()) {
7!
455
        this.context.warning(
14✔
456
            "You triggered an uninstall of {} in version {} with force mode!\n"
457
                + "This will physically delete the currently installed version from the machine.\n"
458
                + "This may cause issues with other projects, that use the same version of that tool."
459
            , this.tool, getInstalledVersion());
2✔
460
        uninstallFromSoftwareRepository(toolPath);
3✔
461
      }
462
      performUninstall(toolPath);
3✔
463
      this.context.success("Successfully uninstalled {}", this.tool);
11✔
464
    } catch (Exception e) {
×
465
      this.context.error(e, "Failed to uninstall {}", this.tool);
×
466
    }
1✔
467
  }
1✔
468

469
  /**
470
   * Performs the actual uninstallation of this tool.
471
   *
472
   * @param toolPath the current {@link #getToolPath() tool path}.
473
   */
474
  protected void performUninstall(Path toolPath) {
475
    this.context.getFileAccess().delete(toolPath);
5✔
476
  }
1✔
477

478
  /**
479
   * Deletes the installed version of the tool from the shared software repository.
480
   */
481
  private void uninstallFromSoftwareRepository(Path toolPath) {
482
    Path repoPath = getInstalledSoftwareRepoPath(toolPath);
4✔
483
    if ((repoPath == null) || !Files.exists(repoPath)) {
7!
484
      this.context.warning("An installed version of {} does not exist in software repository.", this.tool);
×
485
      return;
×
486
    }
487
    this.context.info("Physically deleting {} as requested by the user via force mode.", repoPath);
10✔
488
    this.context.getFileAccess().delete(repoPath);
5✔
489
    this.context.success("Successfully deleted {} from your computer.", repoPath);
10✔
490
  }
1✔
491

492
  @Override
493
  protected Path getInstallationPath(String edition, VersionIdentifier resolvedVersion) {
494
    Path installationPath;
495
    if (isIgnoreSoftwareRepo()) {
3✔
496
      installationPath = getToolPath();
4✔
497
    } else {
498
      Path softwareRepositoryPath = this.context.getSoftwareRepositoryPath();
4✔
499
      if (softwareRepositoryPath == null) {
2✔
500
        return null;
2✔
501
      }
502
      Path softwareRepoPath = softwareRepositoryPath.resolve(getToolRepository().getId()).resolve(this.tool).resolve(edition);
11✔
503
      installationPath = softwareRepoPath.resolve(resolvedVersion.toString());
5✔
504
    }
505
    return installationPath;
2✔
506
  }
507

508
  /**
509
   * @return {@link VersionIdentifier} with latest version of the tool}.
510
   */
511
  public VersionIdentifier getLatestToolVersion() {
512

513
    return this.context.getDefaultToolRepository().resolveVersion(this.tool, getConfiguredEdition(), VersionIdentifier.LATEST, this);
×
514
  }
515

516

517
  /**
518
   * Searches for a wrapper file in valid projects (containing a build file f.e. build.gradle or pom.xml) and returns its path.
519
   *
520
   * @param wrapperFileName the name of the wrapper file
521
   * @param filter the {@link Predicate} to match
522
   * @return Path of the wrapper file or {@code null} if none was found.
523
   */
524
  protected Path findWrapper(String wrapperFileName, Predicate<Path> filter) {
525
    Path dir = context.getCwd();
4✔
526
    // traverse the cwd directory containing a build file up till a wrapper file was found
527
    while ((dir != null) && filter.test(dir)) {
6!
528
      if (Files.exists(dir.resolve(wrapperFileName))) {
7✔
529
        context.debug("Using wrapper file at: {}", dir);
10✔
530
        return dir.resolve(wrapperFileName);
4✔
531
      }
532
      dir = dir.getParent();
4✔
533
    }
534
    return null;
2✔
535
  }
536

537

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