8000 Removed no more needed UserLibrary constructor/parser · arduino-collections/Arduino-1@ce05a68 · GitHub
[go: up one dir, main page]

Skip to content

Commit ce05a68

Browse files
committed
Removed no more needed UserLibrary constructor/parser
1 parent 5295e10 commit ce05a68

File tree

2 files changed

+11
-122
lines changed

2 files changed

+11
-122
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package cc.arduino.legacy;
2+
3+
import static processing.app.I18n.tr;
4+
5+
public class OldI18nMessages {
6+
7+
static {
8+
tr("Invalid version '{0}' for library in: {1}");
9+
}
10+
11+
}

arduino-core/src/processing/app/packages/UserLibrary.java

Lines changed: 0 additions & 122 deletions
Original file line numberDiff line numberDiff line change
@@ -28,25 +28,12 @@
2828
*/
2929
package processing.app.packages;
3030

31-
import static processing.app.I18n.format;
32-
import static processing.app.I18n.tr;
33-
3431
import java.io.File;
35-
import java.io.IOException;
36-
import java.nio.file.Files;
37-
import java.nio.file.Paths;
3832
import java.util.ArrayList;
3933
import java.util.Collection;
40-
import java.util.LinkedList;
4134
import java.util.List;
42-
import java.util.Optional;
43-
44-
import com.github.zafarkhaja.semver.Version;
4535

46-
import cc.arduino.Constants;
47-
import cc.arduino.contributions.VersionHelper;
4836
import cc.arduino.contributions.libraries.ContributedLibraryDependency;
49-
import processing.app.helpers.PreferencesMap;
5037

5138
public class UserLibrary {
5239

@@ -72,115 +59,6 @@ public class UserLibrary {
7259
public static final String LOCATION_REF_CORE = "ref-platform";
7360
protected String location;
7461

75-
public static UserLibrary create(File libFolder, String location) throws IOException {
76-
// Parse metadata
77-
File propertiesFile = new File(libFolder, "library.properties");
78-
PreferencesMap properties = new PreferencesMap();
79-
properties.load(propertiesFile);
80-
81-
// Library sanity checks
82-
// ---------------------
83-
84-
// Compatibility with 1.5 rev.1 libraries:
85-
// "email" field changed to "maintainer"
86-
if (!properties.containsKey("maintainer") && properties.containsKey("email")) {
87-
properties.put("maintainer", properties.get("email"));
88-
}
89-
90-
// Compatibility with 1.5 rev.1 libraries:
91-
// "arch" folder no longer supported
92-
File archFolder = new File(libFolder, "arch");
93-
if (archFolder.isDirectory())
94-
throw new IOException("'arch' folder is no longer supported! See http://goo.gl/gfFJzU for more information");
95-
96-
// Check mandatory properties
97-
for (String p : Constants.LIBRARY_MANDATORY_PROPERTIES)
98-
if (!properties.containsKey(p))
99-
throw new IOException("Missing '" + p + "' from library");
100-
101-
// Check layout
102-
String layout;
103-
File srcFolder = new File(libFolder, "src");
104-
105-
if (srcFolder.exists() && srcFolder.isDirectory()) {
106-
// Layout with a single "src" folder and recursive compilation
107-
layout = "recursive";
108-
} else {
109-
// Layout with source code on library's root and "utility" folders
110-
layout = "flat";
111-
}
112-
113-
// Warn if root folder contains development leftovers
114-
File[] files = libFolder.listFiles();
115-
if (files == null) {
116-
throw new IOException("Unable to list files of library in " + libFolder);
117-
}
118-
119-
// Extract metadata info
120-
String architectures = properties.get("architectures");
121-
if (architectures == null)
122-
architectures = "*"; // defaults to "any"
123-
List<String> archs = new ArrayList<>();
124-
for (String arch : architectures.split(","))
125-
archs.add(arch.trim());
126-
127-
String category = properties.get("category");
128-
if (category == null) {
129-
category = "Uncategorized";
130-
}
131-
if (!Constants.LIBRARY_CATEGORIES.contains(category)) {
132-
category = "Uncategorized";
133-
}
134-
135-
String license = properties.get("license");
136-
if (license == null) {
137-
license = "Unspecified";
138-
}
139-
140-
String types = properties.get("types");
141-
if (types == null) {
142-
types = "Contributed";
143-
}
144-
List<String> typesList = new LinkedList<>();
145-
for (String type : types.split(",")) {
146-
typesList.add(type.trim());
147-
}
148-
149-
List<String> includes = null;
150-
if (properties.containsKey("includes") && !properties.get("includes").trim().isEmpty()) {
151-
includes = new ArrayList<>();
152-
for (String i : properties.get("includes").split(","))
153-
includes.add(i.trim());
154-
}
155-
156-
String declaredVersion = properties.get("version").trim();
157-
Optional<Version> version = VersionHelper.valueOf(declaredVersion);
158-
if (!version.isPresent()) {
159-
System.out.println(
160-
format(tr("Invalid version '{0}' for library in: {1}"), declaredVersion, libFolder.getAbsolutePath()));
161-
}
162-
163-
UserLibrary res = new UserLibrary( //
164-
libFolder, //
165-
properties.get("name").trim(), //
166-
version.isPresent() ? version.get().toString() : declaredVersion, //
167-
properties.get("author").trim(), //
168-
properties.get("maintainer").trim(), //
169-
properties.get("sentence").trim(), //
170-
properties.get("paragraph").trim(), //
171-
properties.get("url").trim(), //
172-
category.trim(), //
173-
license.trim(), //
174-
archs, //
175-
layout, //
176-
typesList, //
177-
Files.exists(Paths.get(libFolder.getAbsolutePath(), Constants.LIBRARY_DEVELOPMENT_FLAG_FILE)), //
178-
includes, //
179-
location //
180-
);
181-
return res;
182-
}
183-
18462
public UserLibrary(File installedFolder, String name, String version,
18563
String author, String maintainer, String sentence,
18664
String paraghraph, String website, String category,

0 commit comments

Comments
 (0)
0