List<CompletableFuture<Void>> toDos = new ArrayList<>();
for (int i = 1; i < args.length; i++) {
- Path p = Paths.get(args[i]);
- if (sequential)
- factory.processCategory(p);
+ Path categoryPath = Paths.get(args[i]);
+ cleanPreviousFailedBuild(categoryPath);
+ if (sequential) // sequential processing happens here
+ factory.processCategory(categoryPath);
else
- toDos.add(CompletableFuture.runAsync(() -> factory.processCategory(p)));
+ toDos.add(CompletableFuture.runAsync(() -> factory.processCategory(categoryPath)));
}
- if (!sequential)
+ if (!sequential)// parallel processing
CompletableFuture.allOf(toDos.toArray(new CompletableFuture[toDos.size()])).join();
// Summary
logger.log(INFO, "# License summary:\n" + sb);
}
+ /** Deletes remaining sub directories. */
+ static void cleanPreviousFailedBuild(Path categoryPath) {
+ // clean previous failed build
+ try {
+ for (Path subDir : Files.newDirectoryStream(categoryPath, (d) -> Files.isDirectory(d))) {
+ if (Files.exists(subDir)) {
+ logger.log(WARNING, "Bundle dir " + subDir
+ + " already exists, probably from a previous failed build, deleting it...");
+ deleteDirectory(subDir);
+ }
+ }
+ } catch (IOException e) {
+ logger.log(ERROR, "Cannot clean previous build", e);
+ }
+ }
+
/** MANIFEST headers. */
enum ManifestHeader {
// OSGi
logger.log(TRACE, "Skip " + entry.getName());
continue entries;
} else if (entry.getName().startsWith("META-INF/NOTICE")) {
- logger.log(TRACE, "Skip " + entry.getName());
+ logger.log(WARNING, "Skip " + entry.getName() + " from " + artifact);
// TODO merge them?
continue entries;
} else {
}
if (!fileProps.containsKey(EXPORT_PACKAGE.toString())) {
- fileProps.put(EXPORT_PACKAGE.toString(),
- "*;version=\"" + fileProps.getProperty(BUNDLE_VERSION.toString()) + "\"");
+ fileProps.put(EXPORT_PACKAGE.toString(), "*");
}
// BND analysis
nameVersion.setName(ourSymbolicName);
}
}
+
bundleDir = targetBase.resolve(nameVersion.getName() + "." + nameVersion.getBranch());
// copy original MANIFEST
arch = libRelativePath.getName(1).toString();
}
-// if (!embed) {
// copy entries
JarEntry entry;
entries: while ((entry = jarIn.getNextJarEntry()) != null) {
origin.deleted.add(bundleDir.relativize(target).toString());
}
logger.log(TRACE, () -> "Copied " + target);
-// }
}
}
entries.get(BUNDLE_SYMBOLICNAME.toString()) + ";singleton:=true");
}
-// if (embed) {// copy embedded jar
-// Files.copy(file, bundleDir.resolve(file.getFileName()));
-// entries.put(ManifestHeader.BUNDLE_CLASSPATH.toString(), file.getFileName().toString());
-// }
-
// Final MANIFEST decisions
// We also check the original OSGi metadata and compare with our changes
for (String key : entries.keySet()) {