FELIX-620: report BND warnings and errors for bundle:manifest goal
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@674433 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/bundleplugin/src/main/java/org/apache/felix/bundleplugin/ManifestPlugin.java b/bundleplugin/src/main/java/org/apache/felix/bundleplugin/ManifestPlugin.java
index 88e20c3..be94f18 100644
--- a/bundleplugin/src/main/java/org/apache/felix/bundleplugin/ManifestPlugin.java
+++ b/bundleplugin/src/main/java/org/apache/felix/bundleplugin/ManifestPlugin.java
@@ -24,11 +24,14 @@
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.jar.Manifest;
import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.project.MavenProject;
import aQute.lib.osgi.Analyzer;
@@ -68,6 +71,11 @@
{
throw new MojoExecutionException( "Error trying to generate Manifest", e );
}
+ catch ( MojoFailureException e )
+ {
+ getLog().error( e.getLocalizedMessage() );
+ throw new MojoExecutionException( "Error(s) found in manifest configuration", e );
+ }
catch ( Exception e )
{
getLog().error( "An internal error occurred", e );
@@ -87,16 +95,41 @@
}
- public Manifest getManifest( MavenProject project, Jar[] classpath ) throws IOException
+ public Manifest getManifest( MavenProject project, Jar[] classpath ) throws IOException, MojoFailureException
{
return getManifest( project, new Properties(), new Properties(), classpath );
}
public Manifest getManifest( MavenProject project, Map instructions, Properties properties, Jar[] classpath )
- throws IOException
+ throws IOException, MojoFailureException
{
- return getAnalyzer( project, instructions, properties, classpath ).getJar().getManifest();
+ Analyzer analyzer = getAnalyzer( project, instructions, properties, classpath );
+
+ List errors = analyzer.getErrors();
+ List warnings = analyzer.getWarnings();
+
+ for ( Iterator w = warnings.iterator(); w.hasNext(); )
+ {
+ String msg = ( String ) w.next();
+ getLog().warn( "Warning in manifest for " + project.getArtifact() + " : " + msg );
+ }
+ for ( Iterator e = errors.iterator(); e.hasNext(); )
+ {
+ String msg = ( String ) e.next();
+ getLog().error( "Error in manifest for " + project.getArtifact() + " : " + msg );
+ }
+
+ if ( errors.size() > 0 )
+ {
+ String failok = properties.getProperty( "-failok" );
+ if ( null == failok || "false".equalsIgnoreCase( failok ) )
+ {
+ throw new MojoFailureException( "Error(s) found in manifest configuration" );
+ }
+ }
+
+ return analyzer.getJar().getManifest();
}