Skip to content

Commit

Permalink
#673: fixed tomcat and improved logging (#725)
Browse files Browse the repository at this point in the history
  • Loading branch information
hohwille authored Oct 29, 2024
1 parent 54a8b47 commit 2137a23
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,6 @@ protected UrlDownloadFileMetadata getMetadata(String tool, String edition, Versi
public Collection<ToolDependency> 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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -251,7 +251,11 @@ public boolean installAsDependency(VersionRange version, EnvironmentContext envi

private void installToolDependencies(VersionIdentifier version, String edition, EnvironmentContext environmentContext, ToolRepository toolRepository) {
Collection<ToolDependency> 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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<VersionRange, List<ToolDependency>> dependencies;

private ToolDependencies(Map<VersionRange, List<ToolDependency>> dependencies) {
private final Path path;

private ToolDependencies(Map<VersionRange, List<ToolDependency>> 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<ToolDependency> findDependencies(VersionIdentifier version) {
public List<ToolDependency> findDependencies(VersionIdentifier version, IdeLogger logger) {

for (Map.Entry<VersionRange, List<ToolDependency>> map : this.dependencies.entrySet()) {
VersionRange versionRange = map.getKey();
for (Map.Entry<VersionRange, List<ToolDependency>> 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();
}

Expand All @@ -55,10 +63,10 @@ public static ToolDependencies of(Path file) {

if (Files.exists(file)) {
try (BufferedReader reader = Files.newBufferedReader(file)) {
TypeReference<HashMap<VersionRange, List<ToolDependency>>> typeRef = new TypeReference<>() {
TypeReference<TreeMap<VersionRange, List<ToolDependency>>> typeRef = new TypeReference<>() {
};
Map<VersionRange, List<ToolDependency>> 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);
}
Expand Down

0 comments on commit 2137a23

Please sign in to comment.