X-Git-Url: https://git.argeo.org/?a=blobdiff_plain;f=src%2Forg%2Fargeo%2Fbuild%2FMake.java;h=67246d527d3d17920579a2ec106e9d08de388225;hb=a8a1725244e8daa2ad1b59d202784300d23a7a56;hp=2b6187bcd6d9912d570232e7c40dd0426f5ffa86;hpb=981fb47f2abf1587a2b7551310617ce532927472;p=cc0%2Fargeo-build.git diff --git a/src/org/argeo/build/Make.java b/src/org/argeo/build/Make.java index 2b6187b..67246d5 100644 --- a/src/org/argeo/build/Make.java +++ b/src/org/argeo/build/Make.java @@ -45,6 +45,7 @@ import org.eclipse.jdt.core.compiler.CompilationProgress; import aQute.bnd.osgi.Analyzer; import aQute.bnd.osgi.Jar; +import aQute.bnd.osgi.Resource; import aQute.bnd.plugin.jpms.JPMSModuleInfoPlugin; /** @@ -482,14 +483,18 @@ public class Make { 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); } @@ -506,6 +511,18 @@ public class Make { manifest.write(out); } + // Write module-info.class + if (moduleInfoClass != null) { + Path moduleInfoClassP = binP.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 excludes = new ArrayList<>(); Path excludesP = argeoBuildBase.resolve("excludes.txt"); @@ -660,7 +677,7 @@ public class Make { Map listLegalFilesToInclude(Path bundleBase) throws IOException { Map toInclude = new HashMap<>(); if (!noSdkLegal) { - DirectoryStream sdkSrcLegal = Files.newDirectoryStream(sdkSrcBase, (p) -> { + try (DirectoryStream sdkSrcLegal = Files.newDirectoryStream(sdkSrcBase, (p) -> { String fileName = p.getFileName().toString(); return switch (fileName) { case "NOTICE": @@ -671,9 +688,10 @@ public class Make { default: yield false; }; - }); - for (Path p : sdkSrcLegal) - toInclude.put(p.getFileName().toString(), p); + });) { + for (Path p : sdkSrcLegal) + toInclude.put(p.getFileName().toString(), p); + } } for (Iterator> entries = toInclude.entrySet().iterator(); entries.hasNext();) { Map.Entry entry = entries.next();