Skip to content

Commit

Permalink
Merge pull request #75 from RefuX/master
Browse files Browse the repository at this point in the history
Export Packages for Automatic Modules
  • Loading branch information
tjwatson authored Oct 19, 2023
2 parents 4d50bad + 685af88 commit 41e89d7
Showing 1 changed file with 22 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -527,14 +527,28 @@ private void generateHeaders(Map<String, String> headers, Module m)
// only do exports for non bundle modules
// real OSGi bundles already have good export capabilities
StringBuilder exportPackageHeader = new StringBuilder();
desc.exports().stream().sorted().forEach((exports) -> {
if (exportPackageHeader.length() > 0)
{
exportPackageHeader.append(", ");
}
exportPackageHeader.append(exports.source());
// TODO map targets to x-friends directive?
});

// ModuleDescriptor.exports() is empty for an automatic module, which is different from
// JPMS at runtime where all packages in the automatic module are exported
if (desc.isAutomatic()) {
desc.packages().stream().sorted().forEach((packageName) -> {
if (exportPackageHeader.length() > 0)
{
exportPackageHeader.append(", ");
}
exportPackageHeader.append(packageName);
});
}
else {
desc.exports().stream().sorted().forEach((exported) -> {
if (exportPackageHeader.length() > 0)
{
exportPackageHeader.append(", ");
}
exportPackageHeader.append(exported.source());
// TODO map targets to x-friends directive?
});
}
if (exportPackageHeader.length() > 0)
{
headers.put(Constants.EXPORT_PACKAGE, exportPackageHeader.toString());
Expand Down

0 comments on commit 41e89d7

Please sign in to comment.