From 64f9b6528390d9859f48d37d06ffb163e00215c2 Mon Sep 17 00:00:00 2001 From: gjoranv Date: Thu, 25 May 2023 13:26:52 +0200 Subject: Warn about correct missing provided artifact, based on bundle type --- .../plugin/mojo/GenerateOsgiManifestMojo.java | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'bundle-plugin/src/main/java/com/yahoo/container/plugin') 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 21eba6a283a..818e1510bd6 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 @@ -38,6 +38,10 @@ import static com.yahoo.container.plugin.util.Files.allDescendantFiles; @Mojo(name = "generate-osgi-manifest", requiresDependencyResolution = ResolutionScope.TEST, threadSafe = true) public class GenerateOsgiManifestMojo extends AbstractGenerateOsgiManifestMojo { + private enum BundleType { + CORE, INTERNAL, USER + } + @Parameter private String discApplicationClass = null; @@ -56,6 +60,9 @@ public class GenerateOsgiManifestMojo extends AbstractGenerateOsgiManifestMojo { @Parameter(alias = "Main-Class") private String mainClass = null; + @Parameter(alias = "Bundle-Type") + private BundleType bundleType = BundleType.USER; + @Parameter(defaultValue = "false") private boolean buildLegacyVespaPlatformBundle; @@ -90,8 +97,8 @@ public class GenerateOsgiManifestMojo extends AbstractGenerateOsgiManifestMojo { // jdisc_core being provided guarantees that log output does not contain its exported packages logMissingPackages(exportedPackagesFromProvidedDeps, projectPackages, compileJarsPackages, includedPackages); } else { - getLog().warn("This project does not have jdisc_core as provided dependency, so the " + - "generated 'Import-Package' OSGi header may be missing important packages."); + getLog().warn(("This project does not have '%s' as provided dependency, so the generated 'Import-Package' " + + "OSGi header may be missing important packages.").formatted(wantedProvidedDependency(bundleType))); } logOverlappingPackages(projectPackages, exportedPackagesFromProvidedDeps); logUnnecessaryPackages(compileJarsPackages, exportedPackagesFromProvidedDeps); @@ -110,6 +117,14 @@ public class GenerateOsgiManifestMojo extends AbstractGenerateOsgiManifestMojo { } } + private static String wantedProvidedDependency(BundleType bundleType) { + return switch (bundleType) { + case CORE -> "jdisc_core"; + case INTERNAL -> "container-dev"; + case USER -> "container"; + }; + } + private void addAdditionalManifestProperties(Map manifestContent, PackageTally includedPackages) { addIfNotEmpty(manifestContent, "X-JDisc-PublicApi-Package", publicApi(includedPackages)); addIfNotEmpty(manifestContent, "Bundle-Activator", bundleActivator); -- cgit v1.2.3