import aQute.bnd.osgi.Analyzer;
import aQute.bnd.osgi.Jar;
+import aQute.bnd.osgi.Resource;
import aQute.bnd.plugin.jpms.JPMSModuleInfoPlugin;
/**
if (!Files.exists(binP))
Files.createDirectories(binP);
Manifest manifest;
+ Resource moduleInfoClass = null;
try (Analyzer bndAnalyzer = new Analyzer()) {
bndAnalyzer.setProperties(properties);
Jar jar = new Jar(bundleSymbolicName, binP.toFile());
bndAnalyzer.setJar(jar);
manifest = bndAnalyzer.calcManifest();
+ // JPMS module
+ jar.setManifest(manifest);
JPMSModuleInfoPlugin jpmsModuleInfoPlugin = new JPMSModuleInfoPlugin();
jpmsModuleInfoPlugin.verify(bndAnalyzer);
+ moduleInfoClass = bndAnalyzer.getJar().getResource("module-info.class");
} catch (Exception e) {
throw new RuntimeException("Bnd analysis of " + compiled + " failed", e);
}
manifest.write(out);
}
+ // Write module-info.class
+ if (moduleInfoClass != null) {
+ Path moduleInfoClassP = compiled.resolve("module-info.class");
+ Files.createDirectories(moduleInfoClassP.getParent());
+ try (OutputStream out = Files.newOutputStream(moduleInfoClassP)) {
+ moduleInfoClass.write(out);
+ logger.log(INFO, "Wrote " + moduleInfoClassP);
+ } catch (Exception e) {
+ throw new RuntimeException("Cannot write module-info.class");
+ }
+ }
+
// Load excludes
List<PathMatcher> excludes = new ArrayList<>();
Path excludesP = argeoBuildBase.resolve("excludes.txt");