summaryrefslogtreecommitdiffstats
path: root/bundle-plugin
diff options
context:
space:
mode:
authorgjoranv <gv@yahooinc.com>2023-06-02 16:48:05 +0200
committergjoranv <gv@yahooinc.com>2023-06-02 16:59:01 +0200
commitf9b4d126fb1b812051323a63cc750bf1748dd94f (patch)
tree30f4122d13d7fbeaa16c3e56990c54c99acab080 /bundle-plugin
parent9c0eeab774895b3c3c9b218f82f71fd7314c388c (diff)
Add 'failOnWarnings' config parameter.
- Explicity set to 'false' for integration test.
Diffstat (limited to 'bundle-plugin')
-rw-r--r--bundle-plugin/src/main/java/com/yahoo/container/plugin/mojo/GenerateOsgiManifestMojo.java25
1 files changed, 18 insertions, 7 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 dbc20674710..fdf05d088c5 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
@@ -68,6 +68,9 @@ public class GenerateOsgiManifestMojo extends AbstractGenerateOsgiManifestMojo {
private BundleType bundleType = BundleType.USER;
@Parameter(defaultValue = "false")
+ private boolean failOnWarnings;
+
+ @Parameter(defaultValue = "false")
private boolean buildLegacyVespaPlatformBundle;
public void execute() throws MojoExecutionException {
@@ -103,7 +106,7 @@ 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 '%s' as provided dependency, so the generated 'Import-Package' " +
+ warnOrThrow(("This project does not have '%s' as provided dependency, so the generated 'Import-Package' " +
"OSGi header may be missing important packages.").formatted(wantedProvidedDependency()));
}
logOverlappingPackages(projectPackages, exportedPackagesFromProvidedDeps);
@@ -156,7 +159,7 @@ public class GenerateOsgiManifestMojo extends AbstractGenerateOsgiManifestMojo {
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));
+ warnOrThrow("This project uses packages that are not part of Vespa's public api: %s".formatted(nonPublicApiUsed));
}
private static String publicApi(PackageTally tally) {
@@ -200,8 +203,8 @@ public class GenerateOsgiManifestMojo extends AbstractGenerateOsgiManifestMojo {
Set<String> exportedPackagesFromProvidedDeps) {
Set<String> overlappingProjectPackages = Sets.intersection(projectPackages.definedPackages(), exportedPackagesFromProvidedDeps);
if (! overlappingProjectPackages.isEmpty()) {
- getLog().warn("This project defines packages that are also defined in provided scoped dependencies " +
- "(overlapping packages are strongly discouraged): " + overlappingProjectPackages);
+ warnOrThrow("This project defines packages that are also defined in provided scoped dependencies " +
+ "(overlapping packages are strongly discouraged): " + overlappingProjectPackages);
}
}
@@ -228,9 +231,8 @@ public class GenerateOsgiManifestMojo extends AbstractGenerateOsgiManifestMojo {
List<Artifact> unsupportedArtifacts = nonJarArtifacts.stream().filter(a -> ! a.getType().equals("pom"))
.toList();
- unsupportedArtifacts.forEach(artifact -> getLog()
- .warn(String.format("Unsupported artifact '%s': Type '%s' is not supported. Please file a feature request.",
- artifact.getId(), artifact.getType())));
+ unsupportedArtifacts.forEach(artifact -> warnOrThrow(String.format("Unsupported artifact '%s': Type '%s' is not supported. Please file a feature request.",
+ artifact.getId(), artifact.getType())));
}
private void throwIfInternalContainerArtifactsAreIncluded(Collection<Artifact> includedArtifacts) throws MojoExecutionException {
@@ -263,4 +265,13 @@ public class GenerateOsgiManifestMojo extends AbstractGenerateOsgiManifestMojo {
return PackageTally.fromAnalyzedClassFiles(analyzedClasses);
}
+
+ private void warnOrThrow(String... messages){
+ String message = String.join("\n", messages);
+ if (failOnWarnings) {
+ throw new RuntimeException(message);
+ }
+ getLog().warn(message);
+ }
+
}