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

devonfw / IDEasy / 21013659204

14 Jan 2026 11:29PM UTC coverage: 70.365% (+0.5%) from 69.904%
21013659204

Pull #1675

github

web-flow
Merge 7a3aa598b into fcadaae82
Pull Request #1675: #1298: support ide-extra-tools.json #1658: prevent Jackson reflection

4015 of 6292 branches covered (63.81%)

Branch coverage included in aggregate %.

10440 of 14251 relevant lines covered (73.26%)

3.17 hits per line

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

80.23
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

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

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

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

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

37
  /**
38
   * @return the {@link Path} where the tool is located (installed).
39
   */
40
  @Override
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
    if (toolPath == null) {
2!
55
      return null;
×
56
    }
57
    Path binPath = toolPath.resolve(IdeContext.FOLDER_BIN);
4✔
58
    if (Files.isDirectory(binPath)) {
5✔
59
      return binPath;
2✔
60
    }
61
    return toolPath;
2✔
62
  }
63

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

70
    return false;
×
71
  }
72

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

79
  }
1✔
80

81
  @Override
82
  protected ToolInstallation doInstall(ToolInstallRequest request) {
83

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

94
  private ToolInstallation doInstallStep(ToolInstallRequest request) {
95

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

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

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

146
    return false;
2✔
147
  }
148

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

158
    completeRequest(request); // most likely already done, but if installTool was called directly and not from install
3✔
159
    if (request.isInstallLoop(this.context)) {
5!
160
      return toolAlreadyInstalled(request);
×
161
    }
162
    ToolEditionAndVersion requested = request.getRequested();
3✔
163
    ToolEdition toolEdition = requested.getEdition();
3✔
164
    assert (toolEdition.tool().equals(this.tool)) : "Mismatch " + this.tool + " != " + toolEdition.tool();
7!
165
    String edition = toolEdition.edition();
3✔
166
    VersionIdentifier resolvedVersion = cveCheck(request);
4✔
167
    installToolDependencies(request);
3✔
168

169
    // cveCheck might have changed resolvedVersion so let us re-check...
170
    if (request.isAlreadyInstalled()) {
3✔
171
      return toolAlreadyInstalled(request);
4✔
172
    } else {
173
      ToolEditionAndVersion installed = request.getInstalled();
3✔
174
      this.context.debug("Installation from {} to {}.", installed, requested);
14✔
175
    }
176
    Path installationPath = getInstallationPath(edition, resolvedVersion);
5✔
177

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

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

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

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

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

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

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

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

309
  }
1✔
310

311
  @Override
312
  public VersionIdentifier getInstalledVersion() {
313

314
    return getInstalledVersion(getToolPath());
5✔
315
  }
316

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

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

340
  @Override
341
  public String getInstalledEdition() {
342

343
    return getInstalledEdition(getToolPath());
5✔
344
  }
345

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

375
  private String getEdition(Path toolRepoFolder, Path toolInstallFolder) {
376

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

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

408
  Path getValidInstalledSoftwareRepoPath(Path installPath, Path softwareRepoPath) {
409
    int softwareRepoNameCount = softwareRepoPath.getNameCount();
3✔
410
    int toolInstallNameCount = installPath.getNameCount();
3✔
411
    int targetToolInstallNameCount = softwareRepoNameCount + 4;
4✔
412

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

440
  private boolean isToolNotInstalled(Path toolPath) {
441

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

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

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

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

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

511
  /**
512
   * @return {@link VersionIdentifier} with latest version of the tool}.
513
   */
514
  public VersionIdentifier getLatestToolVersion() {
515

516
    return this.context.getDefaultToolRepository().resolveVersion(this.tool, getConfiguredEdition(), VersionIdentifier.LATEST, this);
×
517
  }
518

519

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

540
  /**
541
   * @param directory the {@link Path} to the build directory.
542
   * @return the build configuration file for this tool or {@code null} if not found (or this is not a build tool).
543
   */
544
  public Path findBuildDescriptor(Path directory) {
545
    return null;
2✔
546
  }
547
}
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