From 901d8c77fe3dca0aee1df8fb0f26fca26117e82d Mon Sep 17 00:00:00 2001 From: Cristian Maglie Date: Mon, 21 May 2018 12:04:01 +0200 Subject: [PATCH] Fixed UpdatableLibrarieyTest --- app/src/processing/app/Base.java | 1 + .../cc/arduino/contributions/UpdatableLibraryTest.java | 2 ++ .../arduino/contributions/libraries/LibrariesIndexer.java | 8 +++++--- arduino-core/src/processing/app/BaseNoGui.java | 2 ++ 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/app/src/processing/app/Base.java b/app/src/processing/app/Base.java index 743f839c6..cd68b05f7 100644 --- a/app/src/processing/app/Base.java +++ b/app/src/processing/app/Base.java @@ -339,6 +339,7 @@ public class Base { LibrariesIndexer indexer = new LibrariesIndexer(BaseNoGui.getSettingsFolder()); indexer.parseIndex(); indexer.setLibrariesFolders(BaseNoGui.getLibrariesFolders()); + indexer.rescanLibraries(); for (String library : parser.getLibraryToInstall().split(",")) { String[] libraryToInstallParts = library.split(":"); diff --git a/app/test/cc/arduino/contributions/UpdatableLibraryTest.java b/app/test/cc/arduino/contributions/UpdatableLibraryTest.java index 1145e9896..e06c12710 100644 --- a/app/test/cc/arduino/contributions/UpdatableLibraryTest.java +++ b/app/test/cc/arduino/contributions/UpdatableLibraryTest.java @@ -37,6 +37,7 @@ public class UpdatableLibraryTest { BaseNoGui.librariesIndexer = indexer; indexer.parseIndex(); indexer.setLibrariesFolders(folders); + indexer.rescanLibraries(); ContributedLibrary sdLib = indexer.getIndex().getInstalled("SD").get(); assertTrue("SD lib is installed", sdLib.isLibraryInstalled()); @@ -63,6 +64,7 @@ public class UpdatableLibraryTest { BaseNoGui.librariesIndexer = indexer; indexer.parseIndex(); indexer.setLibrariesFolders(folders); + indexer.rescanLibraries(); ContributedLibrary l = indexer.getIndex().getInstalled("Bridge").get(); assertTrue("Bridge lib is installed", l.isLibraryInstalled()); diff --git a/arduino-core/src/cc/arduino/contributions/libraries/LibrariesIndexer.java b/arduino-core/src/cc/arduino/contributions/libraries/LibrariesIndexer.java index fe0776e68..e088cca84 100644 --- a/arduino-core/src/cc/arduino/contributions/libraries/LibrariesIndexer.java +++ b/arduino-core/src/cc/arduino/contributions/libraries/LibrariesIndexer.java @@ -113,7 +113,7 @@ public class LibrariesIndexer { return librariesFolders; } - private UserLibraryPriorityComparator priorityComparator; + private UserLibraryPriorityComparator priorityComparator = new UserLibraryPriorityComparator(null); public void addToInstalledLibraries(UserLibrary lib) { UserLibrary toReplace = installedLibraries.getByName(lib.getName()); @@ -129,9 +129,11 @@ public class LibrariesIndexer { installedLibraries.add(lib); } - public void rescanLibraries() { - priorityComparator = new UserLibraryPriorityComparator(BaseNoGui.getTargetPlatform().getId()); + public void setArchitecturePriority(String arch) { + priorityComparator = new UserLibraryPriorityComparator(arch); + } + public void rescanLibraries() { // Clear all installed flags installedLibraries.clear(); diff --git a/arduino-core/src/processing/app/BaseNoGui.java b/arduino-core/src/processing/app/BaseNoGui.java index 01a8fcd25..1f2334ad8 100644 --- a/arduino-core/src/processing/app/BaseNoGui.java +++ b/arduino-core/src/processing/app/BaseNoGui.java @@ -675,6 +675,8 @@ public class BaseNoGui { // Libraries located in the latest folders on the list can override // other libraries with the same name. librariesIndexer.setLibrariesFolders(librariesFolders); + librariesIndexer.setArchitecturePriority(getTargetPlatform().getId()); + librariesIndexer.rescanLibraries(); populateImportToLibraryTable(); }