1
0
mirror of https://github.com/arduino/Arduino.git synced 2025-03-15 12:29:26 +01:00

UserLibrary doesn't extend ContributedLibrary anymore

ContributedLibrary is used to decode library_index.json and it's
intended to keep data coming only from the index.

Now, when the library_index is synced with the filesystem, the
metadata about installed libraries are kept in a separate list
to not mess up with the main index.
This commit is contained in:
Cristian Maglie 2017-12-17 20:02:58 +01:00
parent 3ec6748dc4
commit e896595214
20 changed files with 83 additions and 94 deletions

View File

@ -31,7 +31,9 @@ package cc.arduino.contributions.libraries;
import java.util.Comparator; import java.util.Comparator;
public class LibraryByTypeComparator implements Comparator<ContributedLibrary> { import processing.app.packages.UserLibrary;
public class LibraryByTypeComparator implements Comparator<UserLibrary> {
private final LibraryTypeComparator libraryTypeComparator; private final LibraryTypeComparator libraryTypeComparator;
@ -44,7 +46,7 @@ public class LibraryByTypeComparator implements Comparator<ContributedLibrary> {
} }
@Override @Override
public int compare(ContributedLibrary o1, ContributedLibrary o2) { public int compare(UserLibrary o1, UserLibrary o2) {
if (o1.getTypes() == null) { if (o1.getTypes() == null) {
return 1; return 1;
} }

View File

@ -31,10 +31,12 @@ package cc.arduino.contributions.libraries;
import java.util.Comparator; import java.util.Comparator;
public class LibraryOfSameTypeComparator implements Comparator<ContributedLibrary> { import processing.app.packages.UserLibrary;
public class LibraryOfSameTypeComparator implements Comparator<UserLibrary> {
@Override @Override
public int compare(ContributedLibrary o1, ContributedLibrary o2) { public int compare(UserLibrary o1, UserLibrary o2) {
if (o1.getTypes() == null) { if (o1.getTypes() == null) {
return 1; return 1;
} }

View File

@ -29,7 +29,6 @@
package cc.arduino.contributions.libraries.filters; package cc.arduino.contributions.libraries.filters;
import cc.arduino.contributions.filters.InstalledPredicate;
import cc.arduino.contributions.libraries.ContributedLibrary; import cc.arduino.contributions.libraries.ContributedLibrary;
import processing.app.BaseNoGui; import processing.app.BaseNoGui;
@ -40,14 +39,14 @@ public class InstalledLibraryPredicate implements Predicate<ContributedLibrary>
@Override @Override
public boolean test(ContributedLibrary input) { public boolean test(ContributedLibrary input) {
if (input.isInstalled()) { if (input.isLibraryInstalled()) {
return true; return true;
} }
List<ContributedLibrary> libraries = BaseNoGui.librariesIndexer.getIndex().find(input.getName()); List<ContributedLibrary> libraries = BaseNoGui.librariesIndexer.getIndex().find(input.getName());
return libraries.stream() return libraries.stream()
.filter(new InstalledPredicate()) .filter(l -> l.isLibraryInstalled())
.count() > 0; .count() > 0;
} }

View File

@ -29,15 +29,14 @@
package cc.arduino.contributions.libraries.filters; package cc.arduino.contributions.libraries.filters;
import cc.arduino.contributions.libraries.ContributedLibrary;
import processing.app.packages.UserLibrary; import processing.app.packages.UserLibrary;
import java.util.function.Predicate; import java.util.function.Predicate;
public class OnlyUpstreamReleasePredicate implements Predicate<ContributedLibrary> { public class OnlyUpstreamReleasePredicate implements Predicate<Object> {
@Override @Override
public boolean test(ContributedLibrary input) { public boolean test(Object input) {
return !(input instanceof UserLibrary); return !(input instanceof UserLibrary);
} }

View File

@ -35,20 +35,21 @@ import processing.app.BaseNoGui;
import processing.app.packages.UserLibrary; import processing.app.packages.UserLibrary;
import java.util.List; import java.util.List;
import java.util.Optional;
import java.util.function.Predicate; import java.util.function.Predicate;
public class UpdatableLibraryPredicate implements Predicate<ContributedLibrary> { public class UpdatableLibraryPredicate implements Predicate<ContributedLibrary> {
@Override @Override
public boolean test(ContributedLibrary contributedLibrary) { public boolean test(ContributedLibrary lib) {
String libraryName = contributedLibrary.getName(); Optional<UserLibrary> installed = lib.getInstalledLibrary();
UserLibrary installed = BaseNoGui.librariesIndexer.getInstalledLibraries().getByName(libraryName); if (!installed.isPresent()) {
if (installed == null) {
return false; return false;
} }
String installedVersion = installed.get().getVersion();
String libraryName = lib.getName();
List<ContributedLibrary> libraries = BaseNoGui.librariesIndexer.getIndex().find(libraryName); List<ContributedLibrary> libraries = BaseNoGui.librariesIndexer.getIndex().find(libraryName);
return libraries.stream() return libraries.stream()
.filter(library -> VersionComparator.greaterThan(library.getParsedVersion(), installed.getParsedVersion())) .anyMatch(library -> VersionComparator.greaterThan(library.getParsedVersion(), installedVersion));
.count() > 0;
} }
} }

View File

@ -30,7 +30,6 @@
package cc.arduino.contributions.libraries.ui; package cc.arduino.contributions.libraries.ui;
import cc.arduino.contributions.DownloadableContributionBuiltInAtTheBottomComparator; import cc.arduino.contributions.DownloadableContributionBuiltInAtTheBottomComparator;
import cc.arduino.contributions.filters.InstalledPredicate;
import cc.arduino.contributions.libraries.ContributedLibrary; import cc.arduino.contributions.libraries.ContributedLibrary;
import cc.arduino.contributions.ui.FilteredAbstractTableModel; import cc.arduino.contributions.ui.FilteredAbstractTableModel;
@ -78,13 +77,11 @@ public class ContributedLibraryReleases {
} }
public Optional<ContributedLibrary> getInstalled() { public Optional<ContributedLibrary> getInstalled() {
List<ContributedLibrary> installedReleases = releases.stream().filter(new InstalledPredicate()).collect(Collectors.toList()); List<ContributedLibrary> installedReleases = releases.stream().filter(l -> l.isLibraryInstalled()).collect(Collectors.toList());
Collections.sort(installedReleases, new DownloadableContributionBuiltInAtTheBottomComparator());
if (installedReleases.isEmpty()) { if (installedReleases.isEmpty()) {
return Optional.empty(); return Optional.empty();
} }
Collections.sort(installedReleases, new DownloadableContributionBuiltInAtTheBottomComparator());
return Optional.of(installedReleases.get(0)); return Optional.of(installedReleases.get(0));
} }

View File

@ -45,7 +45,6 @@ import javax.swing.JTable;
import cc.arduino.contributions.DownloadableContributionVersionComparator; import cc.arduino.contributions.DownloadableContributionVersionComparator;
import cc.arduino.contributions.VersionComparator; import cc.arduino.contributions.VersionComparator;
import cc.arduino.contributions.filters.BuiltInPredicate; import cc.arduino.contributions.filters.BuiltInPredicate;
import cc.arduino.contributions.filters.InstalledPredicate;
import cc.arduino.contributions.libraries.ContributedLibrary; import cc.arduino.contributions.libraries.ContributedLibrary;
import cc.arduino.contributions.libraries.filters.OnlyUpstreamReleasePredicate; import cc.arduino.contributions.libraries.filters.OnlyUpstreamReleasePredicate;
import cc.arduino.contributions.ui.InstallerTableCell; import cc.arduino.contributions.ui.InstallerTableCell;
@ -92,10 +91,10 @@ public class ContributedLibraryTableCellEditor extends InstallerTableCell {
.filter(new OnlyUpstreamReleasePredicate()) .filter(new OnlyUpstreamReleasePredicate())
.collect(Collectors.toList()); .collect(Collectors.toList());
List<ContributedLibrary> uninstalledReleases = releases.stream() List<ContributedLibrary> uninstalledReleases = releases.stream()
.filter(new InstalledPredicate().negate()).collect(Collectors.toList()); .filter(l -> !l.isLibraryInstalled()).collect(Collectors.toList());
List<ContributedLibrary> installedBuiltIn = releases.stream() List<ContributedLibrary> installedBuiltIn = releases.stream()
.filter(new InstalledPredicate()).filter(new BuiltInPredicate()) .filter(l -> !l.isLibraryInstalled()).filter(new BuiltInPredicate())
.collect(Collectors.toList()); .collect(Collectors.toList());
if (mayInstalled.isPresent() && !installedBuiltIn.contains(mayInstalled.get())) { if (mayInstalled.isPresent() && !installedBuiltIn.contains(mayInstalled.get())) {

View File

@ -38,6 +38,7 @@ import java.awt.event.ActionListener;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List;
import java.util.Optional; import java.util.Optional;
import java.util.function.Predicate; import java.util.function.Predicate;
@ -134,7 +135,6 @@ public class LibraryManagerUI extends InstallerJDialog<ContributedLibraryRelease
categoryChooser.removeActionListener(categoryChooserActionListener); categoryChooser.removeActionListener(categoryChooserActionListener);
typeChooser.removeActionListener(typeChooserActionListener); typeChooser.removeActionListener(typeChooserActionListener);
// Load categories // Load categories
categoryFilter = x -> true; categoryFilter = x -> true;
categoryChooser.removeAllItems(); categoryChooser.removeAllItems();
@ -158,7 +158,7 @@ public class LibraryManagerUI extends InstallerJDialog<ContributedLibraryRelease
typeChooser.addItem(new DropdownAllLibraries()); typeChooser.addItem(new DropdownAllLibraries());
typeChooser.addItem(new DropdownUpdatableLibrariesItem()); typeChooser.addItem(new DropdownUpdatableLibrariesItem());
typeChooser.addItem(new DropdownInstalledLibraryItem()); typeChooser.addItem(new DropdownInstalledLibraryItem());
java.util.List<String> types = new LinkedList<>(BaseNoGui.librariesIndexer.getIndex().getTypes()); List<String> types = new LinkedList<>(BaseNoGui.librariesIndexer.getIndex().getTypes());
Collections.sort(types, new LibraryTypeComparator()); Collections.sort(types, new LibraryTypeComparator());
for (String type : types) { for (String type : types) {
typeChooser.addItem(new DropdownLibraryOfTypeItem(type)); typeChooser.addItem(new DropdownLibraryOfTypeItem(type));

View File

@ -1059,8 +1059,8 @@ public class Base {
} }
} }
private List<ContributedLibrary> getSortedLibraries() { private LibraryList getSortedLibraries() {
List<ContributedLibrary> installedLibraries = new LinkedList<>(BaseNoGui.librariesIndexer.getInstalledLibraries()); LibraryList installedLibraries = BaseNoGui.librariesIndexer.getInstalledLibraries();
Collections.sort(installedLibraries, new LibraryByTypeComparator()); Collections.sort(installedLibraries, new LibraryByTypeComparator());
Collections.sort(installedLibraries, new LibraryOfSameTypeComparator()); Collections.sort(installedLibraries, new LibraryOfSameTypeComparator());
return installedLibraries; return installedLibraries;
@ -1097,9 +1097,9 @@ public class Base {
TargetPlatform targetPlatform = BaseNoGui.getTargetPlatform(); TargetPlatform targetPlatform = BaseNoGui.getTargetPlatform();
if (targetPlatform != null) { if (targetPlatform != null) {
List<ContributedLibrary> libs = getSortedLibraries(); LibraryList libs = getSortedLibraries();
String lastLibType = null; String lastLibType = null;
for (ContributedLibrary lib : libs) { for (UserLibrary lib : libs) {
String libType = lib.getTypes().get(0); String libType = lib.getTypes().get(0);
if (!libType.equals(lastLibType)) { if (!libType.equals(lastLibType)) {
if (lastLibType != null) { if (lastLibType != null) {

View File

@ -24,12 +24,12 @@
package processing.app.syntax; package processing.app.syntax;
import cc.arduino.contributions.libraries.ContributedLibrary;
import org.apache.commons.compress.utils.IOUtils; import org.apache.commons.compress.utils.IOUtils;
import org.fife.ui.rsyntaxtextarea.TokenMap; import org.fife.ui.rsyntaxtextarea.TokenMap;
import org.fife.ui.rsyntaxtextarea.TokenTypes; import org.fife.ui.rsyntaxtextarea.TokenTypes;
import processing.app.Base; import processing.app.Base;
import processing.app.BaseNoGui; import processing.app.BaseNoGui;
import processing.app.packages.UserLibrary;
import processing.app.debug.TargetPlatform; import processing.app.debug.TargetPlatform;
import java.io.BufferedReader; import java.io.BufferedReader;
@ -89,7 +89,7 @@ public class PdeKeywords {
File platformKeywords = new File(tp.getFolder(), "keywords.txt"); File platformKeywords = new File(tp.getFolder(), "keywords.txt");
if (platformKeywords.exists()) parseKeywordsTxt(platformKeywords); if (platformKeywords.exists()) parseKeywordsTxt(platformKeywords);
} }
for (ContributedLibrary lib : BaseNoGui.librariesIndexer.getInstalledLibraries()) { for (UserLibrary lib : BaseNoGui.librariesIndexer.getInstalledLibraries()) {
File keywords = new File(lib.getInstalledFolder(), "keywords.txt"); File keywords = new File(lib.getInstalledFolder(), "keywords.txt");
if (keywords.exists()) { if (keywords.exists()) {
parseKeywordsTxt(keywords); parseKeywordsTxt(keywords);

View File

@ -35,6 +35,7 @@ import java.io.File;
public abstract class DownloadableContribution { public abstract class DownloadableContribution {
// XXX: maybe installed fields should not be here but in UserLibrary and ContributedPlatform?
private boolean installed; private boolean installed;
private File installedFolder; private File installedFolder;

View File

@ -31,9 +31,11 @@ package cc.arduino.contributions.libraries;
import cc.arduino.contributions.DownloadableContribution; import cc.arduino.contributions.DownloadableContribution;
import processing.app.I18n; import processing.app.I18n;
import processing.app.packages.UserLibrary;
import java.util.Comparator; import java.util.Comparator;
import java.util.List; import java.util.List;
import java.util.Optional;
import static processing.app.I18n.tr; import static processing.app.I18n.tr;
@ -65,6 +67,24 @@ public abstract class ContributedLibrary extends DownloadableContribution {
public static final Comparator<ContributedLibrary> CASE_INSENSITIVE_ORDER = (o1, o2) -> o1.getName().compareToIgnoreCase(o2.getName()); public static final Comparator<ContributedLibrary> CASE_INSENSITIVE_ORDER = (o1, o2) -> o1.getName().compareToIgnoreCase(o2.getName());
private Optional<UserLibrary> installedLib = Optional.empty();
public Optional<UserLibrary> getInstalledLibrary() {
return installedLib;
}
public boolean isLibraryInstalled() {
return installedLib.isPresent();
}
public void setInstalledUserLibrary(UserLibrary installed) {
this.installedLib = Optional.of(installed);
}
public void unsetInstalledUserLibrary() {
installedLib = Optional.empty();
}
/** /**
* Returns <b>true</b> if the library declares to support the specified * Returns <b>true</b> if the library declares to support the specified
* architecture (through the "architectures" property field). * architecture (through the "architectures" property field).

View File

@ -30,7 +30,6 @@
package cc.arduino.contributions.libraries; package cc.arduino.contributions.libraries;
import cc.arduino.contributions.DownloadableContributionBuiltInAtTheBottomComparator; import cc.arduino.contributions.DownloadableContributionBuiltInAtTheBottomComparator;
import cc.arduino.contributions.filters.InstalledPredicate;
import cc.arduino.contributions.libraries.filters.LibraryWithNamePredicate; import cc.arduino.contributions.libraries.filters.LibraryWithNamePredicate;
import java.util.*; import java.util.*;
@ -92,7 +91,7 @@ public abstract class LibrariesIndex {
} }
public Optional<ContributedLibrary> getInstalled(String name) { public Optional<ContributedLibrary> getInstalled(String name) {
List<ContributedLibrary> installedReleases = find(name).stream().filter(new InstalledPredicate()).collect(Collectors.toList()); List<ContributedLibrary> installedReleases = find(name).stream().filter(l -> l.isLibraryInstalled()).collect(Collectors.toList());
Collections.sort(installedReleases, new DownloadableContributionBuiltInAtTheBottomComparator()); Collections.sort(installedReleases, new DownloadableContributionBuiltInAtTheBottomComparator());
if (installedReleases.isEmpty()) { if (installedReleases.isEmpty()) {

View File

@ -122,7 +122,7 @@ public class LibrariesIndexer {
} }
for (ContributedLibrary lib : index.getLibraries()) { for (ContributedLibrary lib : index.getLibraries()) {
lib.setInstalled(false); lib.unsetInstalledUserLibrary();
} }
// Rescan libraries // Rescan libraries
@ -176,7 +176,6 @@ public class LibrariesIndexer {
if (!check.exists() || !check.isFile()) { if (!check.exists() || !check.isFile()) {
// Create a legacy library and exit // Create a legacy library and exit
LegacyUserLibrary lib = LegacyUserLibrary.create(folder); LegacyUserLibrary lib = LegacyUserLibrary.create(folder);
lib.setReadOnly(readOnly);
String[] headers = BaseNoGui.headerListFromIncludePath(lib.getSrcFolder()); String[] headers = BaseNoGui.headerListFromIncludePath(lib.getSrcFolder());
if (headers.length == 0) { if (headers.length == 0) {
throw new IOException(lib.getSrcFolder().getAbsolutePath()); throw new IOException(lib.getSrcFolder().getAbsolutePath());
@ -187,7 +186,6 @@ public class LibrariesIndexer {
// Create a regular library // Create a regular library
UserLibrary lib = UserLibrary.create(folder); UserLibrary lib = UserLibrary.create(folder);
lib.setReadOnly(readOnly);
String[] headers = BaseNoGui.headerListFromIncludePath(lib.getSrcFolder()); String[] headers = BaseNoGui.headerListFromIncludePath(lib.getSrcFolder());
if (headers.length == 0) { if (headers.length == 0) {
throw new IOException(lib.getSrcFolder().getAbsolutePath()); throw new IOException(lib.getSrcFolder().getAbsolutePath());
@ -196,15 +194,13 @@ public class LibrariesIndexer {
// Check if we can find the same library in the index // Check if we can find the same library in the index
// and mark it as installed // and mark it as installed
ContributedLibrary foundLib = index.find(lib.getName(), lib.getParsedVersion()); ContributedLibrary foundLib = index.find(lib.getName(), lib.getVersion());
if (foundLib != null) { if (foundLib != null) {
foundLib.setInstalled(true); foundLib.setInstalledUserLibrary(lib);
foundLib.setInstalledFolder(folder);
foundLib.setReadOnly(readOnly);
lib.setTypes(foundLib.getTypes()); lib.setTypes(foundLib.getTypes());
} }
if (lib.isReadOnly() && lib.getTypes() == null && !lib.getDeclaredTypes().isEmpty()) { if (readOnly && lib.getTypes() == null && !lib.getDeclaredTypes().isEmpty()) {
lib.setTypes(lib.getDeclaredTypes()); lib.setTypes(lib.getDeclaredTypes());
} }

View File

@ -84,7 +84,7 @@ public class LibraryInstaller {
} }
public synchronized void install(ContributedLibrary lib, Optional<ContributedLibrary> mayReplacedLib, ProgressListener progressListener) throws Exception { public synchronized void install(ContributedLibrary lib, Optional<ContributedLibrary> mayReplacedLib, ProgressListener progressListener) throws Exception {
if (lib.isInstalled()) { if (lib.isLibraryInstalled()) {
System.out.println(I18n.format(tr("Library is already installed: {0} version {1}"), lib.getName(), lib.getParsedVersion())); System.out.println(I18n.format(tr("Library is already installed: {0} version {1}"), lib.getName(), lib.getParsedVersion()));
return; return;
} }
@ -141,7 +141,7 @@ public class LibraryInstaller {
// Step 1: Remove library // Step 1: Remove library
progress.setStatus(I18n.format(tr("Removing library: {0}"), lib.getName())); progress.setStatus(I18n.format(tr("Removing library: {0}"), lib.getName()));
progressListener.onProgress(progress); progressListener.onProgress(progress);
FileUtils.recursiveDelete(lib.getInstalledFolder()); FileUtils.recursiveDelete(lib.getInstalledLibrary().get().getInstalledFolder());
progress.stepDone(); progress.stepDone();
// Step 2: Rescan index // Step 2: Rescan index

View File

@ -29,15 +29,15 @@
package cc.arduino.contributions.libraries.filters; package cc.arduino.contributions.libraries.filters;
import cc.arduino.contributions.libraries.ContributedLibrary;
import processing.app.BaseNoGui; import processing.app.BaseNoGui;
import processing.app.packages.UserLibrary;
import java.util.function.Predicate; import java.util.function.Predicate;
public class LibraryInstalledInsideCore implements Predicate<ContributedLibrary> { public class LibraryInstalledInsideCore implements Predicate<UserLibrary> {
@Override @Override
public boolean test(ContributedLibrary contributedLibrary) { public boolean test(UserLibrary contributedLibrary) {
return BaseNoGui.indexer.isFolderInsidePlatform(contributedLibrary.getInstalledFolder()); return BaseNoGui.indexer.isFolderInsidePlatform(contributedLibrary.getInstalledFolder());
} }

View File

@ -29,11 +29,11 @@
package cc.arduino.contributions.libraries.filters; package cc.arduino.contributions.libraries.filters;
import cc.arduino.contributions.libraries.ContributedLibrary; import processing.app.packages.UserLibrary;
import java.util.function.Predicate; import java.util.function.Predicate;
public class TypePredicate implements Predicate<ContributedLibrary> { public class TypePredicate implements Predicate<UserLibrary> {
private final String type; private final String type;
@ -42,7 +42,7 @@ public class TypePredicate implements Predicate<ContributedLibrary> {
} }
@Override @Override
public boolean test(ContributedLibrary input) { public boolean test(UserLibrary input) {
return input.getTypes() != null && input.getTypes().contains(type); return input.getTypes() != null && input.getTypes().contains(type);
} }

View File

@ -39,8 +39,7 @@ public class LegacyUserLibrary extends UserLibrary {
public static LegacyUserLibrary create(File libFolder) { public static LegacyUserLibrary create(File libFolder) {
// construct an old style library // construct an old style library
LegacyUserLibrary res = new LegacyUserLibrary(); LegacyUserLibrary res = new LegacyUserLibrary();
res.setInstalledFolder(libFolder); res.installedFolder = libFolder;
res.setInstalled(true);
res.layout = LibraryLayout.FLAT; res.layout = LibraryLayout.FLAT;
res.name = libFolder.getName(); res.name = libFolder.getName();
res.setTypes(Arrays.asList("Contributed")); res.setTypes(Arrays.asList("Contributed"));

View File

@ -33,7 +33,6 @@ import java.util.Collections;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import cc.arduino.contributions.libraries.ContributedLibrary;
import processing.app.helpers.FileUtils; import processing.app.helpers.FileUtils;
@SuppressWarnings("serial") @SuppressWarnings("serial")
@ -80,7 +79,7 @@ public class LibraryList extends LinkedList<UserLibrary> {
} }
public synchronized void sort() { public synchronized void sort() {
Collections.sort(this, ContributedLibrary.CASE_INSENSITIVE_ORDER); Collections.sort(this, (x, y) -> x.getName().compareToIgnoreCase(y.getName()));
} }
public synchronized LibraryList filterLibrariesInSubfolder(File subFolder) { public synchronized LibraryList filterLibrariesInSubfolder(File subFolder) {

View File

@ -29,7 +29,7 @@
package processing.app.packages; package processing.app.packages;
import cc.arduino.Constants; import cc.arduino.Constants;
import cc.arduino.contributions.libraries.ContributedLibrary; import cc.arduino.contributions.VersionHelper;
import cc.arduino.contributions.libraries.ContributedLibraryReference; import cc.arduino.contributions.libraries.ContributedLibraryReference;
import processing.app.helpers.PreferencesMap; import processing.app.helpers.PreferencesMap;
@ -41,7 +41,9 @@ import java.util.ArrayList;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
public class UserLibrary extends ContributedLibrary { import com.github.zafarkhaja.semver.Version;
public class UserLibrary {
private String name; private String name;
private String version; private String version;
@ -57,6 +59,7 @@ public class UserLibrary extends ContributedLibrary {
private List<String> declaredTypes; private List<String> declaredTypes;
private boolean onGoingDevelopment; private boolean onGoingDevelopment;
private List<String> includes; private List<String> includes;
protected File installedFolder;
public static UserLibrary create(File libFolder) throws IOException { public static UserLibrary create(File libFolder) throws IOException {
// Parse metadata // Parse metadata
@ -139,11 +142,13 @@ public class UserLibrary extends ContributedLibrary {
includes.add(i.trim()); includes.add(i.trim());
} }
String declaredVersion = properties.get("version").trim();
Version version = VersionHelper.valueOf(declaredVersion);
UserLibrary res = new UserLibrary(); UserLibrary res = new UserLibrary();
res.setInstalledFolder(libFolder); res.installedFolder = libFolder;
res.setInstalled(true);
res.name = properties.get("name").trim(); res.name = properties.get("name").trim();
res.version = properties.get("version").trim(); res.version = version.toString();
res.author = properties.get("author").trim(); res.author = properties.get("author").trim();
res.maintainer = properties.get("maintainer").trim(); res.maintainer = properties.get("maintainer").trim();
res.sentence = properties.get("sentence").trim(); res.sentence = properties.get("sentence").trim();
@ -159,42 +164,34 @@ public class UserLibrary extends ContributedLibrary {
return res; return res;
} }
@Override
public String getName() { public String getName() {
return name; return name;
} }
@Override
public List<String> getArchitectures() { public List<String> getArchitectures() {
return architectures; return architectures;
} }
@Override
public String getAuthor() { public String getAuthor() {
return author; return author;
} }
@Override
public String getParagraph() { public String getParagraph() {
return paragraph; return paragraph;
} }
@Override
public String getSentence() { public String getSentence() {
return sentence; return sentence;
} }
@Override
public String getWebsite() { public String getWebsite() {
return website; return website;
} }
@Override
public String getCategory() { public String getCategory() {
return category; return category;
} }
@Override
public List<String> getTypes() { public List<String> getTypes() {
return types; return types;
} }
@ -203,47 +200,22 @@ public class UserLibrary extends ContributedLibrary {
this.types = types; this.types = types;
} }
@Override
public String getLicense() { public String getLicense() {
return license; return license;
} }
@Override
public void setCategory(String category) { public void setCategory(String category) {
this.category = category; this.category = category;
} }
@Override
public String getVersion() { public String getVersion() {
return version; return version;
} }
@Override
public String getMaintainer() { public String getMaintainer() {
return maintainer; return maintainer;
} }
@Override
public String getChecksum() {
return null;
}
@Override
public long getSize() {
return 0;
}
@Override
public String getUrl() {
return null;
}
@Override
public String getArchiveFileName() {
return null;
}
@Override
public List<ContributedLibraryReference> getRequires() { public List<ContributedLibraryReference> getRequires() {
return null; return null;
} }
@ -269,9 +241,9 @@ public class UserLibrary extends ContributedLibrary {
public File getSrcFolder() { public File getSrcFolder() {
switch (layout) { switch (layout) {
case FLAT: case FLAT:
return getInstalledFolder(); return installedFolder;
case RECURSIVE: case RECURSIVE:
return new File(getInstalledFolder(), "src"); return new File(installedFolder, "src");
default: default:
return null; // Keep compiler happy :-( return null; // Keep compiler happy :-(
} }
@ -286,4 +258,8 @@ public class UserLibrary extends ContributedLibrary {
return name + ":" + version + " " + architectures + " " + installedFolder.getAbsolutePath(); return name + ":" + version + " " + architectures + " " + installedFolder.getAbsolutePath();
} }
public File getInstalledFolder() {
return installedFolder;
}
} }