Skip to content

Commit 3b57462

Browse files
committed
Use latest tools version for generic tool.paths properties
1 parent 6f24fa6 commit 3b57462

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

arduino-core/src/processing/app/BaseNoGui.java

+12-4
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import cc.arduino.UploaderUtils;
66
import cc.arduino.contributions.GPGDetachedSignatureVerifier;
77
import cc.arduino.contributions.SignatureVerificationFailedException;
8+
import cc.arduino.contributions.VersionComparator;
89
import cc.arduino.contributions.libraries.LibrariesIndexer;
910
import cc.arduino.contributions.packages.ContributedPlatform;
1011
import cc.arduino.contributions.packages.ContributedTool;
@@ -866,6 +867,8 @@ public static void createToolPreferences(Collection<ContributedTool> installedTo
866867
PreferencesData.removeAllKeysWithPrefix(prefix);
867868
}
868869

870+
Map<String, String> latestVersions = new HashMap<>();
871+
VersionComparator comparator = new VersionComparator();
869872
for (ContributedTool tool : installedTools) {
870873
File installedFolder = tool.getDownloadableContribution(getPlatform()).getInstalledFolder();
871874
String toolPath;
@@ -874,10 +877,15 @@ public static void createToolPreferences(Collection<ContributedTool> installedTo
874877
} else {
875878
toolPath = Constants.PREF_REMOVE_PLACEHOLDER;
876879
}
877-
PreferencesData.set(prefix + tool.getName() + ".path", toolPath);
878-
PreferencesData.set(prefix + tool.getName() + "-" + tool.getVersion() + ".path", toolPath);
879-
PreferencesData.set(prefix + tool.getPackager() + "-" + tool.getName() + "-" + tool.getVersion() + ".path",
880-
toolPath);
880+
String toolName = tool.getName();
881+
String toolVersion = tool.getVersion();
882+
PreferencesData.set(prefix + toolName + "-" + toolVersion + ".path", toolPath);
883+
PreferencesData.set(prefix + tool.getPackager() + "-" + toolName + "-" + toolVersion + ".path", toolPath);
884+
// In the generic tool property put the path of the latest version if more are available
885+
if (!latestVersions.containsKey(toolName) || comparator.greaterThan(toolVersion, latestVersions.get(toolName))) {
886+
latestVersions.put(toolName, toolVersion);
887+
PreferencesData.set(prefix + toolName + ".path", toolPath);
888+
}
881889
}
882890
}
883891

0 commit comments

Comments
 (0)