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

devonfw / IDEasy / 19751001190

28 Nov 2025 12:52AM UTC coverage: 69.453% (+0.3%) from 69.136%
19751001190

Pull #1614

github

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

3697 of 5851 branches covered (63.19%)

Branch coverage included in aggregate %.

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

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

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

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

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

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

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

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

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

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

304
  }
1✔
305

306
  @Override
307
  public VersionIdentifier getInstalledVersion() {
308

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

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

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

335
  @Override
336
  public String getInstalledEdition() {
337

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

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

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

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

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

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

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

435
  private boolean isToolNotInstalled(Path toolPath) {
436

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

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

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

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

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

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

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

514

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

535

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