Skip to content

Commit f150bd6

Browse files
committed
#1719: Add getDownloadedToolFile method
1 parent a17ce19 commit f150bd6

2 files changed

Lines changed: 20 additions & 10 deletions

File tree

cli/src/main/java/com/devonfw/tools/ide/tool/LocalToolCommandlet.java

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -227,14 +227,16 @@ public ToolInstallation installTool(ToolInstallRequest request) {
227227
*
228228
* @param request the {@link ToolInstallRequest}.
229229
* @param installationPath the target {@link Path} where the {@link #getName() tool} should be installed.
230-
* @see #doInstall(ToolInstallRequest, Path)
230+
* @see #doInstall(ToolInstallRequest, Path, Path)
231231
*/
232232
protected void performToolInstallation(ToolInstallRequest request, Path installationPath) {
233233

234234
installDependencies(request);
235235
FileAccess fileAccess = this.context.getFileAccess();
236236
ToolEditionAndVersion requested = request.getRequested();
237237
VersionIdentifier resolvedVersion = requested.getResolvedVersion();
238+
Path downloadedToolFile = getDownloadedToolFile(request);
239+
238240
if (Files.isDirectory(installationPath)) {
239241
if (this.tool.equals(IdeasyCommandlet.TOOL_NAME)) {
240242
LOG.warn("Your IDEasy installation is missing the version file.");
@@ -244,14 +246,25 @@ protected void performToolInstallation(ToolInstallRequest request, Path installa
244246
}
245247
fileAccess.mkdirs(installationPath.getParent());
246248

247-
doInstall(request, installationPath);
249+
doInstall(request, installationPath, downloadedToolFile);
248250

249251
this.context.writeVersionFile(resolvedVersion, installationPath);
250252
// fix macOS Gatekeeper blocking - must run after version file is written but before any executables are launched
251253
getMacOsHelper().removeQuarantineAttribute(installationPath);
252254
LOG.debug("Installed {} in version {} at {}", this.tool, resolvedVersion, installationPath);
253255
}
254256

257+
/**
258+
* @param request the {@link ToolInstallRequest}.
259+
* @return the {@link Path} to the downloaded tool file.
260+
*/
261+
protected Path getDownloadedToolFile(ToolInstallRequest request) {
262+
263+
ToolEditionAndVersion requested = request.getRequested();
264+
VersionIdentifier resolvedVersion = requested.getResolvedVersion();
265+
return downloadTool(requested.getEdition().edition(), resolvedVersion);
266+
}
267+
255268
/**
256269
* Hook to install dependencies of this tool.
257270
*
@@ -263,17 +276,15 @@ protected void installDependencies(ToolInstallRequest request) {
263276
}
264277

265278
/**
266-
* Hook for the actual installation of the {@link #getName() tool}. The default implementation performs a
267-
* {@link #downloadTool(String, VersionIdentifier) download} and {@link FileAccess#extract(Path, Path, java.util.function.Consumer, boolean) extraction}.
279+
* Hook for the actual installation of the {@link #getName() tool}. The default implementation performs an
280+
* {@link FileAccess#extract(Path, Path, java.util.function.Consumer, boolean) extraction}.
268281
*
269282
* @param request the {@link ToolInstallRequest}.
270283
* @param installationPath the target {@link Path} where the {@link #getName() tool} should be installed.
284+
* @param downloadedToolFile the {@link Path} to the downloaded tool file.
271285
*/
272-
protected void doInstall(ToolInstallRequest request, Path installationPath) {
286+
protected void doInstall(ToolInstallRequest request, Path installationPath, Path downloadedToolFile) {
273287

274-
ToolEditionAndVersion requested = request.getRequested();
275-
VersionIdentifier resolvedVersion = requested.getResolvedVersion();
276-
Path downloadedToolFile = downloadTool(requested.getEdition().edition(), resolvedVersion);
277288
boolean extract = isExtract();
278289
if (!extract) {
279290
LOG.trace("Extraction is disabled for '{}' hence just moving the downloaded file {}.", this.tool, downloadedToolFile);

cli/src/main/java/com/devonfw/tools/ide/tool/rust/Rust.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ private void installWindowsMsvcBuildTools() {
9595
}
9696

9797
@Override
98-
protected void doInstall(ToolInstallRequest request, Path installationPath) {
98+
protected void doInstall(ToolInstallRequest request, Path installationPath, Path installerScript) {
9999

100100
VersionIdentifier resolvedVersion = request.getRequested().getResolvedVersion();
101101
FileAccess fileAccess = this.context.getFileAccess();
@@ -107,7 +107,6 @@ protected void doInstall(ToolInstallRequest request, Path installationPath) {
107107
fileAccess.mkdirs(cargoHome);
108108
fileAccess.mkdirs(rustupHome);
109109

110-
Path installerScript = downloadTool(request.getRequested().getEdition().edition(), resolvedVersion);
111110
if (Files.isDirectory(installerScript)) {
112111
// ToolRepositoryMock may provide an unpacked folder instead of a single download file.
113112
installerScript = installerScript.resolve("content.sh");

0 commit comments

Comments
 (0)