import java.nio.file.Files;
import java.nio.file.Path;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
import java.util.SortedMap;
import java.util.StringJoiner;
private final Path base;
private final Map<String, String> variantsXOr;
-// public FsA2Source(Path base) {
-// this(base, new HashMap<>());
-// }
+ private final List<String> includes;
+ private final List<String> excludes;
- public FsA2Source(Path base, Map<String, String> variantsXOr, boolean usingReference) {
+ public FsA2Source(Path base, Map<String, String> variantsXOr, boolean usingReference, List<String> includes,
+ List<String> excludes) {
super(usingReference);
this.base = base;
this.variantsXOr = new HashMap<>(variantsXOr);
+ this.includes = includes;
+ this.excludes = excludes;
}
void load() throws IOException {
}
}
- for (Path contributionPath : contributions.keySet()) {
+ contributions: for (Path contributionPath : contributions.keySet()) {
String contributionId = contributionPath.getFileName().toString();
+ if (includes != null && !includes.contains(contributionId))
+ continue contributions;
+ if (excludes != null && excludes.contains(contributionId))
+ continue contributions;
A2Contribution contribution = getOrAddContribution(contributionId);
DirectoryStream<Path> modulePaths = Files.newDirectoryStream(contributionPath);
modules: for (Path modulePath : modulePaths) {
// XOR
Map<String, List<String>> properties = queryToMap(u);
Map<String, String> xOr = new HashMap<>();
+ List<String> includes = null;
+ List<String> excludes = null;
for (String key : properties.keySet()) {
List<String> lst = properties.get(key);
- if (lst.size() != 1)
- throw new IllegalArgumentException("Invalid XOR definitions in " + uri);
- xOr.put(key, lst.get(0));
+ if (A2Source.INCLUDE.equals(key)) {
+ includes = new ArrayList<>(lst);
+ } else if (A2Source.EXCLUDE.equals(key)) {
+ excludes = new ArrayList<>(lst);
+ } else {
+ if (lst.size() != 1)
+ throw new IllegalArgumentException("Invalid XOR definitions in " + uri);
+ xOr.put(key, lst.get(0));
+ }
}
if (SCHEME_A2.equals(u.getScheme()) || SCHEME_A2_REFERENCE.equals(u.getScheme())) {
}
Path base = Paths.get(baseStr);
if (Files.exists(base)) {
- FsA2Source source = new FsA2Source(base, xOr, SCHEME_A2_REFERENCE.equals(u.getScheme()));
+ FsA2Source source = new FsA2Source(base, xOr, SCHEME_A2_REFERENCE.equals(u.getScheme()),
+ includes, excludes);
source.load();
addSource(source);
OsgiBootUtils.info("Registered " + uri + " as source");
Path localLibBase = base.resolve(A2Contribution.LIB).resolve(localRelPath);
if (Files.exists(localLibBase)) {
FsA2Source libSource = new FsA2Source(localLibBase, xOr,
- SCHEME_A2_REFERENCE.equals(u.getScheme()));
+ SCHEME_A2_REFERENCE.equals(u.getScheme()), includes, excludes);
libSource.load();
addSource(libSource);
OsgiBootUtils.info("Registered OS-specific " + uri + " as source (" + localRelPath + ")");
// TODO make it more dynamic, based on OSGi APIs
// TODO remove old module? Or keep update history?
osgiContext.registerBundle(bundle);
- OsgiBootUtils.info("Updated bundle " + bundle.getLocation() + " to version " + moduleVersion);
+ if (compare == 0)
+ OsgiBootUtils
+ .debug("Updated bundle " + bundle.getLocation() + " to same version " + moduleVersion);
+ else
+ OsgiBootUtils.info("Updated bundle " + bundle.getLocation() + " to version " + moduleVersion);
return bundle;
} else {
if (OsgiBootUtils.isDebug())