}
public Option testedBundle() throws MalformedURLException {
File out = new File("target/tested/bundle.jar");
TinyBundle tested = TinyBundles.bundle();
// We look inside target/classes to find the class and resources
File classes = new File("target/classes");
Collection<File> files = FileUtils.listFilesAndDirs(classes, TrueFileFilter.INSTANCE, TrueFileFilter.INSTANCE);
List<File> services = new ArrayList<File>();
for (File file : files) {
if (file.isDirectory()) {
// By convention we export of .services and .service package
if (file.getName().endsWith("services") || file.getName().endsWith("service")) {
services.add(file);
}
} else {
// We need to compute the path
String path = file.getAbsolutePath().substring(classes.getAbsolutePath().length() +1);
tested.add(path, file.toURI().toURL());
System.out.println(file.getName() + " added to " + path);
}
}
String export = "";
for (File file : services) {
if (export.length() > 0) { export += ", "; }
String path = file.getAbsolutePath().substring(classes.getAbsolutePath().length() +1);
String packageName = path.replace('/', '.');
export += packageName;
}
System.out.println("Exported packages : " + export);
InputStream inputStream = tested
.set(Constants.BUNDLE_SYMBOLICNAME, "test.bundle")
//.set(Constants.IMPORT_PACKAGE, "*")
.set(Constants.EXPORT_PACKAGE, export)
.build(IPOJOStrategy.withiPOJO(new File("src/main/resources")));