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

devonfw / IDEasy / 19751480105

28 Nov 2025 01:26AM UTC coverage: 69.441% (+0.3%) from 69.136%
19751480105

push

github

web-flow
#1613: fixed duplicated CVE check and refactored installation routine (#1614)

3696 of 5851 branches covered (63.17%)

Branch coverage included in aggregate %.

9620 of 13325 relevant lines covered (72.2%)

3.14 hits per line

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

81.27
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
      return installation;
2✔
100
    }
101
    FileAccess fileAccess = this.context.getFileAccess();
4✔
102
    boolean ignoreSoftwareRepo = isIgnoreSoftwareRepo();
3✔
103
    if (!ignoreSoftwareRepo) {
2✔
104
      Path toolPath = getToolPath();
3✔
105
      // we need to link the version or update the link.
106
      if (Files.exists(toolPath, LinkOption.NOFOLLOW_LINKS)) {
9✔
107
        fileAccess.backup(toolPath);
4✔
108
      }
109
      fileAccess.mkdirs(toolPath.getParent());
4✔
110
      fileAccess.symlink(installation.linkDir(), toolPath);
5✔
111
    }
112
    if (installation.binDir() != null) {
3!
113
      this.context.getPath().setPath(this.tool, installation.binDir());
8✔
114
    }
115
    postInstall(true, request.getProcessContext());
5✔
116
    ToolEditionAndVersion installed = request.getInstalled();
3✔
117
    GenericVersionRange installedVersion = null;
2✔
118
    if (installed != null) {
2!
119
      installedVersion = installed.getVersion();
3✔
120
    }
121
    ToolEditionAndVersion requested = request.getRequested();
3✔
122
    ToolEdition toolEdition = requested.getEdition();
3✔
123
    Step step = request.getStep();
3✔
124
    if (installedVersion == null) {
2✔
125
      asSuccess(step).log("Successfully installed {} in version {}", toolEdition, resolvedVersion);
17✔
126
    } else {
127
      asSuccess(step).log("Successfully installed {} in version {} replacing previous version {} of {}", toolEdition, resolvedVersion,
23✔
128
          installedVersion, installed.getEdition());
2✔
129
    }
130
    return installation;
2✔
131
  }
132

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

141
    return false;
2✔
142
  }
143

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

153
    completeRequest(request); // most likely already done, but if installTool was called directly and not from install
3✔
154
    ToolEditionAndVersion requested = request.getRequested();
3✔
155
    ToolEdition toolEdition = requested.getEdition();
3✔
156
    assert (toolEdition.tool().equals(this.tool)) : "Mismatch " + this.tool + " != " + toolEdition.tool();
7!
157
    String edition = toolEdition.edition();
3✔
158
    boolean skipSuggestions = false;
2✔
159
    VersionIdentifier resolvedVersion;
160
    if (this.context.isSkipUpdatesMode() && request.isAlreadyInstalled(true)) {
8✔
161
      requested.setResolvedVersion(request.getInstalled().getResolvedVersion());
5✔
162
      skipSuggestions = true;
2✔
163
    }
164
    resolvedVersion = cveCheck(request, skipSuggestions);
5✔
165
    ProcessContext processContext = request.getProcessContext();
3✔
166
    installToolDependencies(request);
3✔
167

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

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

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

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

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

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

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

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

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

303
  }
1✔
304

305
  @Override
306
  public VersionIdentifier getInstalledVersion() {
307

308
    return getInstalledVersion(getToolPath());
5✔
309
  }
310

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

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

334
  @Override
335
  public String getInstalledEdition() {
336

337
    return getInstalledEdition(getToolPath());
5✔
338
  }
339

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

369
  private String getEdition(Path toolRepoFolder, Path toolInstallFolder) {
370

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

385
  private Path getInstalledSoftwareRepoPath(Path toolPath) {
386
    if (isToolNotInstalled(toolPath)) {
4!
387
      return null;
×
388
    }
389
    Path installPath = this.context.getFileAccess().toRealPath(toolPath);
6✔
390
    // if the installPath changed, a link has been resolved
391
    if (installPath.equals(toolPath)) {
4!
392
      if (!isIgnoreSoftwareRepo()) {
×
393
        this.context.warning("Tool {} is not installed via software repository (maybe from devonfw-ide). Please consider reinstalling it.", this.tool);
×
394
      }
395
      // 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
396
      return null;
×
397
    }
398
    installPath = getValidInstalledSoftwareRepoPath(installPath, context.getSoftwareRepositoryPath());
7✔
399
    return installPath;
2✔
400
  }
401

402
  Path getValidInstalledSoftwareRepoPath(Path installPath, Path softwareRepoPath) {
403
    int softwareRepoNameCount = softwareRepoPath.getNameCount();
3✔
404
    int toolInstallNameCount = installPath.getNameCount();
3✔
405
    int targetToolInstallNameCount = softwareRepoNameCount + 4;
4✔
406

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

434
  private boolean isToolNotInstalled(Path toolPath) {
435

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

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

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

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

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

505
  /**
506
   * @return {@link VersionIdentifier} with latest version of the tool}.
507
   */
508
  public VersionIdentifier getLatestToolVersion() {
509

510
    return this.context.getDefaultToolRepository().resolveVersion(this.tool, getConfiguredEdition(), VersionIdentifier.LATEST, this);
×
511
  }
512

513

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

534

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