From 2137a236ec4854978f8b0ccf755ec67a54d60127 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Hohwiller?= Date: Tue, 29 Oct 2024 17:54:47 +0100 Subject: [PATCH] #673: fixed tomcat and improved logging (#725) --- .../tools/ide/commandlet/Commandlet.java | 2 ++ .../tools/ide/repo/DefaultToolRepository.java | 2 +- .../tools/ide/tool/LocalToolCommandlet.java | 6 ++++- .../tools/ide/tool/graalvm/GraalVm.java | 1 - .../url/model/file/json/ToolDependencies.java | 26 ++++++++++++------- 5 files changed, 25 insertions(+), 12 deletions(-) diff --git a/cli/src/main/java/com/devonfw/tools/ide/commandlet/Commandlet.java b/cli/src/main/java/com/devonfw/tools/ide/commandlet/Commandlet.java index 4ef895f42..3001da170 100644 --- a/cli/src/main/java/com/devonfw/tools/ide/commandlet/Commandlet.java +++ b/cli/src/main/java/com/devonfw/tools/ide/commandlet/Commandlet.java @@ -231,6 +231,8 @@ public ValidationResult validate() { /** * Provide additional usage help of this {@link Commandlet} to the user. + * + * @param bundle the {@link NlsBundle} to get I18N messages from. */ public void printHelp(NlsBundle bundle) { diff --git a/cli/src/main/java/com/devonfw/tools/ide/repo/DefaultToolRepository.java b/cli/src/main/java/com/devonfw/tools/ide/repo/DefaultToolRepository.java index fc6f6de98..c26c1fdef 100644 --- a/cli/src/main/java/com/devonfw/tools/ide/repo/DefaultToolRepository.java +++ b/cli/src/main/java/com/devonfw/tools/ide/repo/DefaultToolRepository.java @@ -56,6 +56,6 @@ protected UrlDownloadFileMetadata getMetadata(String tool, String edition, Versi public Collection findDependencies(String tool, String edition, VersionIdentifier version) { UrlDependencyFile dependencyFile = this.context.getUrls().getEdition(tool, edition).getDependencyFile(); - return dependencyFile.getDependencies().findDependencies(version); + return dependencyFile.getDependencies().findDependencies(version, this.context); } } diff --git a/cli/src/main/java/com/devonfw/tools/ide/tool/LocalToolCommandlet.java b/cli/src/main/java/com/devonfw/tools/ide/tool/LocalToolCommandlet.java index 2cd43ed3c..99f0b842d 100644 --- a/cli/src/main/java/com/devonfw/tools/ide/tool/LocalToolCommandlet.java +++ b/cli/src/main/java/com/devonfw/tools/ide/tool/LocalToolCommandlet.java @@ -234,7 +234,7 @@ public boolean installAsDependency(VersionRange version, EnvironmentContext envi VersionIdentifier configuredVersion = getConfiguredVersion(); if (version.contains(configuredVersion)) { // prefer configured version if contained in version range - return install(); + return install(false, environmentContext); } else { if (isIgnoreSoftwareRepo()) { throw new IllegalStateException( @@ -251,7 +251,11 @@ public boolean installAsDependency(VersionRange version, EnvironmentContext envi private void installToolDependencies(VersionIdentifier version, String edition, EnvironmentContext environmentContext, ToolRepository toolRepository) { Collection dependencies = toolRepository.findDependencies(this.tool, edition, version); + String toolWithEdition = getToolWithEdition(this.tool, edition); + int size = dependencies.size(); + this.context.debug("Tool {} has {} other tool(s) as dependency", toolWithEdition, size); for (ToolDependency dependency : dependencies) { + this.context.trace("Ensuring dependency {} for tool {}", dependency.tool(), toolWithEdition); LocalToolCommandlet dependencyTool = this.context.getCommandletManager().getRequiredLocalToolCommandlet(dependency.tool()); dependencyTool.installAsDependency(dependency.versionRange(), environmentContext); } diff --git a/cli/src/main/java/com/devonfw/tools/ide/tool/graalvm/GraalVm.java b/cli/src/main/java/com/devonfw/tools/ide/tool/graalvm/GraalVm.java index 5a77fbcae..6a79593c4 100644 --- a/cli/src/main/java/com/devonfw/tools/ide/tool/graalvm/GraalVm.java +++ b/cli/src/main/java/com/devonfw/tools/ide/tool/graalvm/GraalVm.java @@ -7,7 +7,6 @@ import com.devonfw.tools.ide.context.IdeContext; import com.devonfw.tools.ide.environment.EnvironmentVariables; import com.devonfw.tools.ide.environment.EnvironmentVariablesType; -import com.devonfw.tools.ide.process.ProcessContext; import com.devonfw.tools.ide.process.ProcessErrorHandling; import com.devonfw.tools.ide.process.ProcessMode; import com.devonfw.tools.ide.step.Step; diff --git a/cli/src/main/java/com/devonfw/tools/ide/url/model/file/json/ToolDependencies.java b/cli/src/main/java/com/devonfw/tools/ide/url/model/file/json/ToolDependencies.java index 31937835d..0b22ae6d1 100644 --- a/cli/src/main/java/com/devonfw/tools/ide/url/model/file/json/ToolDependencies.java +++ b/cli/src/main/java/com/devonfw/tools/ide/url/model/file/json/ToolDependencies.java @@ -4,11 +4,12 @@ import java.nio.file.Files; import java.nio.file.Path; import java.util.Collections; -import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.TreeMap; import com.devonfw.tools.ide.json.JsonMapping; +import com.devonfw.tools.ide.log.IdeLogger; import com.devonfw.tools.ide.version.VersionIdentifier; import com.devonfw.tools.ide.version.VersionRange; import com.fasterxml.jackson.core.type.TypeReference; @@ -23,27 +24,34 @@ public class ToolDependencies { private static final ObjectMapper MAPPER = JsonMapping.create(); - private static final ToolDependencies EMPTY = new ToolDependencies(Collections.emptyMap()); + private static final ToolDependencies EMPTY = new ToolDependencies(Collections.emptyMap(), Path.of("empty")); private final Map> dependencies; - private ToolDependencies(Map> dependencies) { + private final Path path; + + private ToolDependencies(Map> dependencies, Path path) { super(); this.dependencies = dependencies; + this.path = path; } /** * @param version the {@link VersionIdentifier} of the tool to install. * @return The {@link List} of {@link ToolDependency}s for the given tool version. */ - public List findDependencies(VersionIdentifier version) { + public List findDependencies(VersionIdentifier version, IdeLogger logger) { - for (Map.Entry> map : this.dependencies.entrySet()) { - VersionRange versionRange = map.getKey(); + for (Map.Entry> entry : this.dependencies.entrySet()) { + VersionRange versionRange = entry.getKey(); if (versionRange.contains(version)) { - return map.getValue(); + return entry.getValue(); } } + int size = dependencies.size(); + if (size > 0) { + logger.warning("No match for version {} while {} version ranges are configured in {} - configuration error?!", version, size, this.path); + } return Collections.emptyList(); } @@ -55,10 +63,10 @@ public static ToolDependencies of(Path file) { if (Files.exists(file)) { try (BufferedReader reader = Files.newBufferedReader(file)) { - TypeReference>> typeRef = new TypeReference<>() { + TypeReference>> typeRef = new TypeReference<>() { }; Map> dependencies = MAPPER.readValue(reader, typeRef); - return new ToolDependencies(dependencies); + return new ToolDependencies(dependencies, file); } catch (Exception e) { throw new IllegalStateException("Failed to load " + file, e); }