1
0
mirror of https://github.com/arduino/Arduino.git synced 2024-11-29 10:24:12 +01:00

Libraries in unknown categories get set as Uncategorized. Fixes #3732

This commit is contained in:
Federico Fissore 2015-09-08 15:30:34 +02:00
parent f84b58e96d
commit a4a7e3ec96
3 changed files with 7 additions and 17 deletions

View File

@ -65,6 +65,9 @@ public class Constants {
public static final String LIBRARY_INDEX_URL;
public static final String LIBRARY_INDEX_URL_GZ;
public static final List<String> LIBRARY_CATEGORIES = Arrays.asList("Display", "Communication", "Signal Input/Output", "Sensors", "Device Control", "Timing", "Data Storage", "Data Processing", "Other", "Uncategorized");
public static final List<String> LIBRARY_MANDATORY_PROPERTIES = Arrays.asList("name", "version", "author", "maintainer", "sentence", "paragraph", "url");
static {
String extenalPackageIndexUrl = System.getProperty("PACKAGE_INDEX_URL");
if (extenalPackageIndexUrl != null && !"".equals(extenalPackageIndexUrl)) {

View File

@ -29,6 +29,7 @@
package cc.arduino.contributions.libraries;
import cc.arduino.Constants;
import cc.arduino.contributions.libraries.filters.LibraryInstalledInsideCore;
import cc.arduino.contributions.libraries.filters.TypePredicate;
import cc.arduino.contributions.packages.ContributedPlatform;
@ -92,7 +93,7 @@ public class LibrariesIndexer {
index.getLibraries()
.stream()
.filter(library -> library.getCategory() == null || "".equals(library.getCategory()))
.filter(library -> library.getCategory() == null || "".equals(library.getCategory()) || !Constants.LIBRARY_CATEGORIES.contains(library.getCategory()))
.forEach(library -> library.setCategory("Uncategorized"));
} finally {
IOUtils.closeQuietly(indexIn);

View File

@ -39,7 +39,6 @@ import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
@ -59,15 +58,6 @@ public class UserLibrary extends ContributedLibrary {
private List<String> declaredTypes;
private boolean onGoingDevelopment;
private static final List<String> MANDATORY_PROPERTIES = Arrays
.asList("name", "version", "author", "maintainer",
"sentence", "paragraph", "url");
private static final List<String> CATEGORIES = Arrays.asList(
"Display", "Communication", "Signal Input/Output", "Sensors",
"Device Control", "Timing", "Data Storage", "Data Processing", "Other",
"Uncategorized");
public static UserLibrary create(File libFolder) throws IOException {
// Parse metadata
File propertiesFile = new File(libFolder, "library.properties");
@ -90,7 +80,7 @@ public class UserLibrary extends ContributedLibrary {
throw new IOException("'arch' folder is no longer supported! See http://goo.gl/gfFJzU for more information");
// Check mandatory properties
for (String p : MANDATORY_PROPERTIES)
for (String p : Constants.LIBRARY_MANDATORY_PROPERTIES)
if (!properties.containsKey(p))
throw new IOException("Missing '" + p + "' from library");
@ -135,7 +125,7 @@ public class UserLibrary extends ContributedLibrary {
String category = properties.get("category");
if (category == null)
category = "Uncategorized";
if (!CATEGORIES.contains(category)) {
if (!Constants.LIBRARY_CATEGORIES.contains(category)) {
System.out.println("WARNING: Category '" + category + "' in library " + properties.get("name") + " is not valid. Setting to 'Uncategorized'");
category = "Uncategorized";
}
@ -222,10 +212,6 @@ public class UserLibrary extends ContributedLibrary {
return license;
}
public static List<String> getCategories() {
return CATEGORIES;
}
@Override
public void setCategory(String category) {
this.category = category;