From 2e86853955a19bf290efca723456619ea45cb75f Mon Sep 17 00:00:00 2001 From: gjoranv Date: Thu, 1 Jun 2023 16:54:48 +0200 Subject: Add new manifest header for non-PublicApi usage .. to facilitate testing and support. --- .../plugin/mojo/GenerateOsgiManifestMojo.java | 23 ++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) (limited to 'bundle-plugin/src') 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 nonPublicApiUsed = disallowedVespaImports(calculatedImports, publicApiPackagesFromProvidedJars); + logNonPublicApiUsage(nonPublicApiUsed); Map 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 calculatedImports, List publicApiPackagesFromProvidedJars) { - if (bundleType != BundleType.USER) return; - - List 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 manifestContent, List nonPublicApiUsed) { + if (bundleType != BundleType.USER) return; + addIfNotEmpty(manifestContent, "X-JDisc-Non-PublicApi-Import-Package", String.join(",", nonPublicApiUsed)); + } + + private void logNonPublicApiUsage(List 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(",")); } -- cgit v1.2.3