5
5
import cc .arduino .UploaderUtils ;
6
6
import cc .arduino .contributions .GPGDetachedSignatureVerifier ;
7
7
import cc .arduino .contributions .SignatureVerificationFailedException ;
8
+ import cc .arduino .contributions .VersionComparator ;
8
9
import cc .arduino .contributions .libraries .LibrariesIndexer ;
9
10
import cc .arduino .contributions .packages .ContributedPlatform ;
10
11
import cc .arduino .contributions .packages .ContributedTool ;
@@ -866,6 +867,8 @@ public static void createToolPreferences(Collection<ContributedTool> installedTo
866
867
PreferencesData .removeAllKeysWithPrefix (prefix );
867
868
}
868
869
870
+ Map <String , String > latestVersions = new HashMap <>();
871
+ VersionComparator comparator = new VersionComparator ();
869
872
for (ContributedTool tool : installedTools ) {
870
873
File installedFolder = tool .getDownloadableContribution (getPlatform ()).getInstalledFolder ();
871
874
String toolPath ;
@@ -874,10 +877,15 @@ public static void createToolPreferences(Collection<ContributedTool> installedTo
874
877
} else {
875
878
toolPath = Constants .PREF_REMOVE_PLACEHOLDER ;
876
879
}
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
+ }
881
889
}
882
890
}
883
891
0 commit comments