Skip to content

Commit

Permalink
devonfw#634: preparation: change DependencyInfo to record (devonfw#636)
Browse files Browse the repository at this point in the history
  • Loading branch information
hohwille authored Sep 19, 2024
1 parent b8f218c commit 8f668ea
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 38 deletions.
10 changes: 5 additions & 5 deletions cli/src/main/java/com/devonfw/tools/ide/tool/Dependency.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,12 @@ public List<DependencyInfo> readJson(VersionIdentifier version, String toolEditi
*/
public VersionIdentifier findDependencyVersionToInstall(DependencyInfo dependencyFound) {

String dependencyEdition = this.context.getVariables().getToolEdition(dependencyFound.getTool());

List<VersionIdentifier> versions = this.context.getUrls().getSortedVersions(dependencyFound.getTool(), dependencyEdition);

String dependencyTool = dependencyFound.tool();
String dependencyEdition = this.context.getVariables().getToolEdition(dependencyTool);
List<VersionIdentifier> versions = this.context.getUrls().getSortedVersions(dependencyTool, dependencyEdition);
VersionRange dependencyVersionRange = dependencyFound.versionRange();
for (VersionIdentifier vi : versions) {
if (dependencyFound.getVersionRange().contains(vi)) {
if (dependencyVersionRange.contains(vi)) {
return vi;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ private DependencyInfo readDependencies(VersionIdentifier toolVersion) {

private void installDependencies(DependencyInfo dependencyInfo, EnvironmentContext ec) {

String dependencyName = dependencyInfo.getTool();
String dependencyName = dependencyInfo.tool();
LocalToolCommandlet dependencyTool = (LocalToolCommandlet) this.context.getCommandletManager().getToolCommandlet(dependencyName);
VersionIdentifier dependencyVersionToInstall = this.dependency.findDependencyVersionToInstall(dependencyInfo);

Expand All @@ -399,7 +399,7 @@ private void installDependencies(DependencyInfo dependencyInfo, EnvironmentConte
installDependencyInRepo(dependencyName, dependencyTool, dependencyVersionToInstall, ec);
dependencyTool.setEnvironment(ec, dependencyRepository.resolve(dependencyVersionToInstall.toString()));
} else {
Path versionExistingInRepository = this.dependency.versionExistsInRepository(dependencyRepository, dependencyInfo.getVersionRange());
Path versionExistingInRepository = this.dependency.versionExistsInRepository(dependencyRepository, dependencyInfo.versionRange());
boolean versionExistingInRepositoryIsEmpty = versionExistingInRepository.equals(Path.of(""));

if (versionExistingInRepositoryIsEmpty) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,37 +3,8 @@
import com.devonfw.tools.ide.version.VersionRange;

/**
* Model to represent the Object of the dependencies inside the Json file.
* Model to represent a dependency of a tool (inside a "dependencies.json" file).
*/
public final class DependencyInfo {
public record DependencyInfo(String tool, VersionRange versionRange) {

private String tool;

private VersionRange versionRange;

/**
* @return the dependency name
*/
public String getTool() {

return this.tool;
}

void setTool(String tool) {

this.tool = tool;
}

/**
* @return the VersionRange of the dependency
*/
public VersionRange getVersionRange() {

return this.versionRange;
}

void setVersionRange(VersionRange versionRange) {

this.versionRange = versionRange;
}
}

0 comments on commit 8f668ea

Please sign in to comment.