55import cc .arduino .UploaderUtils ;
66import cc .arduino .contributions .GPGDetachedSignatureVerifier ;
77import cc .arduino .contributions .SignatureVerificationFailedException ;
8+ import cc .arduino .contributions .VersionComparator ;
89import cc .arduino .contributions .libraries .LibrariesIndexer ;
910import cc .arduino .contributions .packages .ContributedPlatform ;
1011import 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