summaryrefslogtreecommitdiffstats
path: root/bundle-plugin
diff options
context:
space:
mode:
authorgjoranv <gv@yahooinc.com>2023-06-01 16:54:48 +0200
committergjoranv <gv@yahooinc.com>2023-06-02 16:59:01 +0200
commit2e86853955a19bf290efca723456619ea45cb75f (patch)
tree234c4d54f13ee4ef42cccf6cc65535153503e66f /bundle-plugin
parent28e10125cd97ee7846f72bce4a42b1ea1ccca027 (diff)
Add new manifest header for non-PublicApi usage
.. to facilitate testing and support.
Diffstat (limited to 'bundle-plugin')
-rw-r--r--bundle-plugin/src/main/java/com/yahoo/container/plugin/mojo/GenerateOsgiManifestMojo.java23
1 files changed, 13 insertions, 10 deletions
diff --git a/bundle-plugin/src/main/java/com/yahoo/container/plugin/mojo/GenerateOsgiManifestMojo.java b/bundle-plugin/src/main/java/com/yahoo/container/plugin/mojo/GenerateOsgiManifestMojo.java
index d5c9d905a16..dbc20674710 100644
--- a/bundle-plugin/src/main/java/com/yahoo/container/plugin/mojo/GenerateOsgiManifestMojo.java
+++ b/bundle-plugin/src/main/java/com/yahoo/container/plugin/mojo/GenerateOsgiManifestMojo.java
@@ -113,10 +113,12 @@ public class GenerateOsgiManifestMojo extends AbstractGenerateOsgiManifestMojo {
includedPackages.definedPackages(),
exportsByPackageName(exportedPackagesFromProvidedJars));
- logNonPublicApiUsage(calculatedImports, publicApiPackagesFromProvidedJars);
+ List<String> nonPublicApiUsed = disallowedVespaImports(calculatedImports, publicApiPackagesFromProvidedJars);
+ logNonPublicApiUsage(nonPublicApiUsed);
Map<String, String> manifestContent = generateManifestContent(artifactSet.getJarArtifactsToInclude(), calculatedImports, includedPackages);
addAdditionalManifestProperties(manifestContent, includedPackages);
+ addManifestPropertiesForUserBundles(manifestContent, nonPublicApiUsed);
createManifestFile(Paths.get(project.getBuild().getOutputDirectory()), manifestContent);
} catch (Exception e) {
@@ -124,15 +126,6 @@ public class GenerateOsgiManifestMojo extends AbstractGenerateOsgiManifestMojo {
}
}
- private void logNonPublicApiUsage(Map<String, Import> calculatedImports, List<String> publicApiPackagesFromProvidedJars) {
- if (bundleType != BundleType.USER) return;
-
- List<String> nonPublicApiUsed = disallowedVespaImports(calculatedImports, publicApiPackagesFromProvidedJars);
- if (! nonPublicApiUsed.isEmpty()) {
- getLog().warn("This project uses packages that are not part of Vespa's public api: %s".formatted(nonPublicApiUsed));
- }
- }
-
private String wantedProvidedDependency() {
return switch (effectiveBundleType()) {
case CORE -> "jdisc_core";
@@ -156,6 +149,16 @@ public class GenerateOsgiManifestMojo extends AbstractGenerateOsgiManifestMojo {
addIfNotEmpty(manifestContent, "WebInfUrl", webInfUrl);
}
+ private void addManifestPropertiesForUserBundles(Map<String, String> manifestContent, List<String> nonPublicApiUsed) {
+ if (bundleType != BundleType.USER) return;
+ addIfNotEmpty(manifestContent, "X-JDisc-Non-PublicApi-Import-Package", String.join(",", nonPublicApiUsed));
+ }
+
+ private void logNonPublicApiUsage(List<String> nonPublicApiUsed) {
+ if (bundleType != BundleType.USER || nonPublicApiUsed.isEmpty()) return;
+ getLog().warn("This project uses packages that are not part of Vespa's public api: %s".formatted(nonPublicApiUsed));
+ }
+
private static String publicApi(PackageTally tally) {
return tally.publicApiPackages().stream().sorted().collect(Collectors.joining(","));
}