Author: cziegeler
Date: Tue Mar  3 13:03:27 2015
New Revision: 1663692

URL: http://svn.apache.org/r1663692
Log:
Remove obsolete stuff and reduce to minimum functionality

Removed:
    felix/sandbox/cziegeler/bnd-maven-plugin/doc/
    
felix/sandbox/cziegeler/bnd-maven-plugin/src/main/java/org/apache/felix/bundleplugin/ManifestPlugin.java
    
felix/sandbox/cziegeler/bnd-maven-plugin/src/main/java/org/apache/felix/bundleplugin/baseline/BaselineReport.java
    felix/sandbox/cziegeler/bnd-maven-plugin/src/main/resources/META-INF/plexus/
    felix/sandbox/cziegeler/bnd-maven-plugin/src/main/resources/SchemaObr.xsd
    
felix/sandbox/cziegeler/bnd-maven-plugin/src/main/resources/baseline-report.properties
    felix/sandbox/cziegeler/bnd-maven-plugin/src/main/resources/build.xml
    felix/sandbox/cziegeler/bnd-maven-plugin/src/main/resources/org/
    felix/sandbox/cziegeler/bnd-maven-plugin/upgrade_local_poms.sh
Modified:
    felix/sandbox/cziegeler/bnd-maven-plugin/pom.xml
    
felix/sandbox/cziegeler/bnd-maven-plugin/src/main/java/org/apache/felix/bundleplugin/BundlePlugin.java
    
felix/sandbox/cziegeler/bnd-maven-plugin/src/main/java/org/apache/felix/bundleplugin/baseline/AbstractBaselinePlugin.java
    
felix/sandbox/cziegeler/bnd-maven-plugin/src/main/java/org/apache/felix/bundleplugin/baseline/BaselinePlugin.java
    
felix/sandbox/cziegeler/bnd-maven-plugin/src/main/resources/META-INF/m2e/lifecycle-mapping-metadata.xml

Modified: felix/sandbox/cziegeler/bnd-maven-plugin/pom.xml
URL: 
http://svn.apache.org/viewvc/felix/sandbox/cziegeler/bnd-maven-plugin/pom.xml?rev=1663692&r1=1663691&r2=1663692&view=diff
==============================================================================
--- felix/sandbox/cziegeler/bnd-maven-plugin/pom.xml (original)
+++ felix/sandbox/cziegeler/bnd-maven-plugin/pom.xml Tue Mar  3 13:03:27 2015
@@ -145,11 +145,6 @@
            <version>2.6</version>
        </dependency>
        <dependency>
-           <groupId>org.apache.maven.reporting</groupId>
-           <artifactId>maven-reporting-api</artifactId>
-           <version>3.0</version>
-       </dependency>
-       <dependency>
            <groupId>org.sonatype.plexus</groupId>
            <artifactId>plexus-build-api</artifactId>
            <version>0.0.7</version>

Modified: 
felix/sandbox/cziegeler/bnd-maven-plugin/src/main/java/org/apache/felix/bundleplugin/BundlePlugin.java
URL: 
http://svn.apache.org/viewvc/felix/sandbox/cziegeler/bnd-maven-plugin/src/main/java/org/apache/felix/bundleplugin/BundlePlugin.java?rev=1663692&r1=1663691&r2=1663692&view=diff
==============================================================================
--- 
felix/sandbox/cziegeler/bnd-maven-plugin/src/main/java/org/apache/felix/bundleplugin/BundlePlugin.java
 (original)
+++ 
felix/sandbox/cziegeler/bnd-maven-plugin/src/main/java/org/apache/felix/bundleplugin/BundlePlugin.java
 Tue Mar  3 13:03:27 2015
@@ -23,6 +23,7 @@ import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.File;
 import java.io.FileInputStream;
+import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.lang.reflect.Array;
@@ -58,6 +59,11 @@ import org.apache.maven.plugin.AbstractM
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.plugin.MojoFailureException;
 import org.apache.maven.plugin.logging.Log;
+import org.apache.maven.plugins.annotations.Component;
+import org.apache.maven.plugins.annotations.LifecyclePhase;
+import org.apache.maven.plugins.annotations.Mojo;
+import org.apache.maven.plugins.annotations.Parameter;
+import org.apache.maven.plugins.annotations.ResolutionScope;
 import org.apache.maven.project.MavenProject;
 import org.apache.maven.project.MavenProjectHelper;
 import org.apache.maven.shared.osgi.DefaultMaven2OsgiConverter;
@@ -83,134 +89,117 @@ import aQute.bnd.osgi.Processor;
 
 /**
  * Create an OSGi bundle from Maven project
- *
- * @goal bundle
- * @phase package
- * @requiresDependencyResolution test
- * @description build an OSGi bundle jar
- * @threadSafe
  */
+@Mojo(
+        name = "bundle",
+        defaultPhase = LifecyclePhase.PREPARE_PACKAGE,
+        requiresDependencyResolution = ResolutionScope.TEST,
+        threadSafe = true
+)
 public class BundlePlugin extends AbstractMojo
 {
     /**
      * Directory where the manifest will be written
      *
-     * @parameter expression="${manifestLocation}" 
default-value="${project.build.outputDirectory}/META-INF"
      */
+    @Parameter(property="manifestLocation", 
defaultValue="${project.build.outputDirectory}/META-INF")
     protected File manifestLocation;
 
     /**
      * Output a nicely formatted manifest that still respects the 72 character 
line limit.
      *
-     * @parameter expression="${niceManifest}" default-value="false"
      */
+    @Parameter(property="niceManifest", defaultValue="false")
     protected boolean niceManifest;
 
     /**
      * File where the BND instructions will be dumped
      *
-     * @parameter expression="${dumpInstructions}"
      */
+    @Parameter(property="dumpInstructions")
     protected File dumpInstructions;
 
     /**
      * File where the BND class-path will be dumped
      *
-     * @parameter expression="${dumpClasspath}"
      */
+    @Parameter(property="dumpClasspath")
     protected File dumpClasspath;
 
     /**
-     * When true, unpack the bundle contents to the outputDirectory
-     *
-     * @parameter expression="${unpackBundle}"
-     */
-    protected boolean unpackBundle;
-
-    /**
      * Comma separated list of artifactIds to exclude from the dependency 
classpath passed to BND (use "true" to exclude everything)
      *
-     * @parameter expression="${excludeDependencies}"
      */
+    @Parameter(property="excludeDependencies")
     protected String excludeDependencies;
 
     /**
      * Final name of the bundle (without classifier or extension)
      *
-     * @parameter expression="${project.build.finalName}"
      */
+    @Parameter(defaultValue="${project.build.finalName}")
     private String finalName;
 
     /**
      * Classifier type of the bundle to be installed.  For example, "jdk14".
      * Defaults to none which means this is the project's main bundle.
      *
-     * @parameter
      */
+    @Parameter
     protected String classifier;
 
     /**
      * Packaging type of the bundle to be installed.  For example, "jar".
      * Defaults to none which means use the same packaging as the project.
      *
-     * @parameter
      */
+    @Parameter
     protected String packaging;
 
-    /**
-     * @component
-     */
+    @Component
     private MavenProjectHelper m_projectHelper;
 
-    /**
-     * @component
-     */
+    @Component
     private ArchiverManager m_archiverManager;
 
-    /**
-     * @component
-     */
+    @Component
     private ArtifactHandlerManager m_artifactHandlerManager;
 
     /**
      * Project types which this plugin supports.
      *
-     * @parameter
      */
-    protected List supportedProjectTypes = Arrays.asList( new String[]
+    @Parameter
+    protected List<String> supportedProjectTypes = Arrays.asList( new String[]
         { "jar", "bundle" } );
 
     /**
      * The directory for the generated bundles.
      *
-     * @parameter expression="${project.build.outputDirectory}"
-     * @required
      */
+    @Parameter(defaultValue="${project.build.outputDirectory}", required=true)
     private File outputDirectory;
 
     /**
      * The directory for the generated JAR.
      *
-     * @parameter expression="${project.build.directory}"
-     * @required
      */
+    @Parameter(defaultValue="${project.build.outputDirectory}", required=true)
     private String buildDirectory;
 
     /**
      * The Maven project.
      *
-     * @parameter expression="${project}"
-     * @required
-     * @readonly
      */
+    @Parameter(property = "project", readonly = true, required = true)
     private MavenProject project;
 
     /**
      * The BND instructions for the bundle.
      *
-     * @parameter
      */
-    private Map instructions = new LinkedHashMap();
+    @Parameter
+    private Map<String, String> instructions = new LinkedHashMap<String, 
String>();
 
     /**
      * Use locally patched version for now.
@@ -220,15 +209,11 @@ public class BundlePlugin extends Abstra
     /**
      * The archive configuration to use.
      *
-     * @parameter
      */
+    @Parameter
     private MavenArchiveConfiguration archive; // accessed indirectly in 
JarPluginConfiguration
 
-    /**
-     * @parameter default-value="${session}"
-     * @required
-     * @readonly
-     */
+    @Parameter(property = "session", readonly = true, required = true)
     private MavenSession m_mavenSession;
 
     private static final String MAVEN_SYMBOLICNAME = "maven-symbolicname";
@@ -386,7 +371,7 @@ public class BundlePlugin extends Abstra
                     throw new MojoFailureException( "Error(s) found in bundle 
configuration" );
                 }
             }
-
+/*
             // attach bundle to maven project
             jarFile.getParentFile().mkdirs();
             builder.getJar().write( jarFile );
@@ -419,10 +404,7 @@ public class BundlePlugin extends Abstra
                 mainArtifact.setFile( jarFile );
             }
 
-            if ( unpackBundle )
-            {
-                unpackBundle( jarFile );
-            }
+*/
 
             if ( manifestLocation != null )
             {
@@ -431,14 +413,13 @@ public class BundlePlugin extends Abstra
                 try
                 {
                     Manifest manifest = builder.getJar().getManifest();
-                    ManifestPlugin.writeManifest( manifest, outputFile, 
niceManifest );
+                    writeManifest( manifest, outputFile, niceManifest );
                 }
                 catch ( IOException e )
                 {
                     getLog().error( "Error trying to write Manifest to file " 
+ outputFile, e );
                 }
             }
-
             // cleanup...
             builder.close();
         }
@@ -1628,4 +1609,27 @@ public class BundlePlugin extends Abstra
             analyzer.setProperty( Analyzer.SOURCEPATH, 
mavenSourcePaths.toString() );
         }
     }
+
+    public static void writeManifest( Manifest manifest, File outputFile, 
boolean niceManifest ) throws IOException
+    {
+        outputFile.getParentFile().mkdirs();
+
+        FileOutputStream os;
+        os = new FileOutputStream( outputFile );
+        try
+        {
+            ManifestWriter.outputManifest( manifest, os, niceManifest );
+        }
+        finally
+        {
+            try
+            {
+                os.close();
+            }
+            catch ( IOException e )
+            {
+                // nothing we can do here
+            }
+        }
+    }
 }

Modified: 
felix/sandbox/cziegeler/bnd-maven-plugin/src/main/java/org/apache/felix/bundleplugin/baseline/AbstractBaselinePlugin.java
URL: 
http://svn.apache.org/viewvc/felix/sandbox/cziegeler/bnd-maven-plugin/src/main/java/org/apache/felix/bundleplugin/baseline/AbstractBaselinePlugin.java?rev=1663692&r1=1663691&r2=1663692&view=diff
==============================================================================
--- 
felix/sandbox/cziegeler/bnd-maven-plugin/src/main/java/org/apache/felix/bundleplugin/baseline/AbstractBaselinePlugin.java
 (original)
+++ 
felix/sandbox/cziegeler/bnd-maven-plugin/src/main/java/org/apache/felix/bundleplugin/baseline/AbstractBaselinePlugin.java
 Tue Mar  3 13:03:27 2015
@@ -43,6 +43,8 @@ import org.apache.maven.execution.MavenS
 import org.apache.maven.plugin.AbstractMojo;
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.plugins.annotations.Component;
+import org.apache.maven.plugins.annotations.Parameter;
 import org.apache.maven.project.MavenProject;
 import org.codehaus.plexus.util.StringUtils;
 
@@ -67,107 +69,73 @@ abstract class AbstractBaselinePlugin
     /**
      * Flag to easily skip execution.
      *
-     * @parameter expression="${baseline.skip}" default-value="false"
      */
+    @Parameter(property="baseline.skip", defaultValue="false")
     protected boolean skip;
 
     /**
      * Whether to fail on errors.
      *
-     * @parameter expression="${baseline.failOnError}" default-value="true"
      */
+    @Parameter(property="baseline.failOnError", defaultValue="true")
     protected boolean failOnError;
 
     /**
      * Whether to fail on warnings.
      *
-     * @parameter expression="${baseline.failOnWarning}" default-value="false"
      */
+    @Parameter(property="baseline.failOnWarning", defaultValue="false")
     protected boolean failOnWarning;
 
-    /**
-     * @parameter expression="${project}"
-     * @required
-     * @readonly
-     */
+    @Parameter(property = "project", readonly = true, required = true)
     protected MavenProject project;
 
-    /**
-     * @parameter expression="${session}"
-     * @required
-     * @readonly
-     */
+    @Parameter(property = "session", readonly = true, required = true)
     protected MavenSession session;
 
-    /**
-     * @parameter expression="${project.build.directory}"
-     * @required
-     * @readonly
-     */
+    @Parameter(property = "project.build.directory", readonly = true, required 
= true)
     private File buildDirectory;
 
-    /**
-     * @parameter expression="${project.build.finalName}"
-     * @required
-     * @readonly
-     */
+    @Parameter(property = "project.build.finalName", readonly = true, required 
= true)
     private String finalName;
 
-    /**
-     * @component
-     */
+    @Component
     protected ArtifactResolver resolver;
 
-    /**
-     * @component
-     */
+    @Component
     protected ArtifactFactory factory;
 
-    /**
-     * @component
-     */
+    @Component
     private ArtifactMetadataSource metadataSource;
 
     /**
      * Version to compare the current code against.
      *
-     * @parameter expression="${comparisonVersion}" 
default-value="(,${project.version})"
-     * @required
-     * @readonly
      */
+    @Parameter(property="comparisonVersion", 
defaultValue="(,${project.version})")
     protected String comparisonVersion;
 
-    /**
-     * Classifier for the artifact to compare the current code against.
-     *
-     * @parameter expression="${comparisonClassifier}"
-     */
+    @Parameter(property="comparisonClassifier")
     protected String comparisonClassifier;
 
     /**
      * A list of packages filter, if empty the whole bundle will be traversed. 
Values are specified in OSGi package
      * instructions notation, e.g. <code>!org.apache.felix.bundleplugin</code>.
-     *
-     * @parameter
      */
+    @Parameter
     private String[] filters;
 
     /**
      * Project types which this plugin supports.
      *
-     * @parameter
      */
+    @Parameter
     protected List<String> supportedProjectTypes = Arrays.asList( new String[] 
{ "jar", "bundle" } );
 
+    @Override
     public final void execute()
         throws MojoExecutionException, MojoFailureException
     {
-        this.execute(null);
-    }
-
-    protected void execute( Object context)
-            throws MojoExecutionException, MojoFailureException
-    {
         if ( skip )
         {
             getLog().info( "Skipping Baseline execution" );
@@ -239,84 +207,74 @@ abstract class AbstractBaselinePlugin
             throw new MojoExecutionException("Unable to parse baselining 
information.", ioe);
         }
 
-        try
+        startBaseline( generationDate, project.getArtifactId(), 
project.getVersion(), previousArtifact.getVersion() );
+
+        for ( final Info info : infos )
         {
-            // go!
-            context = this.init(context);
-            startBaseline( context, generationDate, project.getArtifactId(), 
project.getVersion(), previousArtifact.getVersion() );
+            DiffMessage diffMessage = null;
 
-            for ( final Info info : infos )
+            if ( info.suggestedVersion != null )
             {
-                DiffMessage diffMessage = null;
-
-                if ( info.suggestedVersion != null )
+                if ( info.newerVersion.compareTo( info.suggestedVersion ) > 0 )
+                {
+                    diffMessage = new DiffMessage( "Excessive version 
increase", DiffMessage.Type.warning );
+                    reporter.warning( "%s: %s; detected %s, suggested %s",
+                                      info.packageName, diffMessage, 
info.newerVersion, info.suggestedVersion );
+                }
+                else if ( info.newerVersion.compareTo( info.suggestedVersion ) 
< 0 )
                 {
-                    if ( info.newerVersion.compareTo( info.suggestedVersion ) 
> 0 )
+                    diffMessage = new DiffMessage( "Version increase 
required", DiffMessage.Type.error );
+                    reporter.error( "%s: %s; detected %s, suggested %s",
+                                    info.packageName, diffMessage, 
info.newerVersion, info.suggestedVersion );
+                }
+            }
+
+            switch ( info.packageDiff.getDelta() )
+            {
+                case UNCHANGED:
+                    if ( info.newerVersion.compareTo( info.suggestedVersion ) 
!= 0 )
                     {
-                        diffMessage = new DiffMessage( "Excessive version 
increase", DiffMessage.Type.warning );
+                        diffMessage = new DiffMessage( "Version has been 
increased but analysis detected no changes", DiffMessage.Type.warning );
                         reporter.warning( "%s: %s; detected %s, suggested %s",
                                           info.packageName, diffMessage, 
info.newerVersion, info.suggestedVersion );
                     }
-                    else if ( info.newerVersion.compareTo( 
info.suggestedVersion ) < 0 )
-                    {
-                        diffMessage = new DiffMessage( "Version increase 
required", DiffMessage.Type.error );
-                        reporter.error( "%s: %s; detected %s, suggested %s",
-                                        info.packageName, diffMessage, 
info.newerVersion, info.suggestedVersion );
-                    }
-                }
+                    break;
 
-                switch ( info.packageDiff.getDelta() )
-                {
-                    case UNCHANGED:
-                        if ( info.newerVersion.compareTo( 
info.suggestedVersion ) != 0 )
-                        {
-                            diffMessage = new DiffMessage( "Version has been 
increased but analysis detected no changes", DiffMessage.Type.warning );
-                            reporter.warning( "%s: %s; detected %s, suggested 
%s",
-                                              info.packageName, diffMessage, 
info.newerVersion, info.suggestedVersion );
-                        }
-                        break;
-
-                    case REMOVED:
-                        diffMessage = new DiffMessage( "Package removed", 
DiffMessage.Type.info );
-                        reporter.trace( "%s: %s ", info.packageName, 
diffMessage );
-                        break;
-
-                    case CHANGED:
-                    case MICRO:
-                    case MINOR:
-                    case MAJOR:
-                    case ADDED:
-                    default:
-                        // ok
-                        break;
-                }
-
-                startPackage( context,
-                              info.mismatch,
-                              info.packageName,
-                              getShortDelta( info.packageDiff.getDelta() ),
-                              StringUtils.lowerCase( String.valueOf( 
info.packageDiff.getDelta() ) ),
-                              info.newerVersion,
-                              info.olderVersion,
-                              info.suggestedVersion,
-                              diffMessage,
-                              info.attributes );
+                case REMOVED:
+                    diffMessage = new DiffMessage( "Package removed", 
DiffMessage.Type.info );
+                    reporter.trace( "%s: %s ", info.packageName, diffMessage );
+                    break;
+
+                case CHANGED:
+                case MICRO:
+                case MINOR:
+                case MAJOR:
+                case ADDED:
+                default:
+                    // ok
+                    break;
+            }
 
-                if ( Delta.REMOVED != info.packageDiff.getDelta() )
-                {
-                    doPackageDiff( context, info.packageDiff );
-                }
+            startPackage( info.mismatch,
+                          info.packageName,
+                          getShortDelta( info.packageDiff.getDelta() ),
+                          StringUtils.lowerCase( String.valueOf( 
info.packageDiff.getDelta() ) ),
+                          info.newerVersion,
+                          info.olderVersion,
+                          info.suggestedVersion,
+                          diffMessage,
+                          info.attributes );
 
-                endPackage(context);
+            if ( Delta.REMOVED != info.packageDiff.getDelta() )
+            {
+                doPackageDiff( info.packageDiff );
             }
 
-            endBaseline(context);
-        }
-        finally
-        {
-            this.close(context);
+            endPackage();
         }
 
+        endBaseline();
+
         // check if it has to fail if some error has been detected
 
         boolean fail = false;
@@ -359,7 +317,7 @@ abstract class AbstractBaselinePlugin
         }
     }
 
-    private void doPackageDiff( Object context, Diff diff )
+    private void doPackageDiff( Diff diff )
     {
         int depth = 1;
 
@@ -367,41 +325,36 @@ abstract class AbstractBaselinePlugin
         {
             if ( Delta.UNCHANGED != curDiff.getDelta() )
             {
-                doDiff( context, curDiff, depth );
+                doDiff( curDiff, depth );
             }
         }
     }
 
-    private void doDiff( Object context, Diff diff, int depth )
+    private void doDiff( Diff diff, int depth )
     {
         String type = StringUtils.lowerCase( String.valueOf( diff.getType() ) 
);
         String shortDelta = getShortDelta( diff.getDelta() );
         String delta = StringUtils.lowerCase( String.valueOf( diff.getDelta() 
) );
         String name = diff.getName();
 
-        startDiff( context, depth, type, name, delta, shortDelta );
+        startDiff(  depth, type, name, delta, shortDelta );
 
         for ( Diff curDiff : diff.getChildren() )
         {
             if ( Delta.UNCHANGED != curDiff.getDelta() )
             {
-                doDiff( context, curDiff, depth + 1 );
+                doDiff( curDiff, depth + 1 );
             }
         }
 
-        endDiff( context, depth );
+        endDiff( depth );
     }
 
     // extensions APIs
 
-    protected abstract Object init(final Object initialContext);
-
-    protected abstract void close(final Object context);
-
-    protected abstract void startBaseline( final Object context, String 
generationDate, String bundleName, String currentVersion, String 
previousVersion );
+    protected abstract void startBaseline( String generationDate, String 
bundleName, String currentVersion, String previousVersion );
 
-    protected abstract void startPackage( final Object context,
-            boolean mismatch,
+    protected abstract void startPackage( boolean mismatch,
                                           String name,
                                           String shortDelta,
                                           String delta,
@@ -411,18 +364,17 @@ abstract class AbstractBaselinePlugin
                                           DiffMessage diffMessage,
                                           Map<String,String> attributes );
 
-    protected abstract void startDiff( final Object context,
-                                       int depth,
+    protected abstract void startDiff( int depth,
                                        String type,
                                        String name,
                                        String delta,
                                        String shortDelta );
 
-    protected abstract void endDiff( final Object context, int depth );
+    protected abstract void endDiff( int depth );
 
-    protected abstract void endPackage(final Object context);
+    protected abstract void endPackage();
 
-    protected abstract void endBaseline(final Object context);
+    protected abstract void endBaseline();
 
     protected void reportErrors(final Info[] infos)
     throws IOException

Modified: 
felix/sandbox/cziegeler/bnd-maven-plugin/src/main/java/org/apache/felix/bundleplugin/baseline/BaselinePlugin.java
URL: 
http://svn.apache.org/viewvc/felix/sandbox/cziegeler/bnd-maven-plugin/src/main/java/org/apache/felix/bundleplugin/baseline/BaselinePlugin.java?rev=1663692&r1=1663691&r2=1663692&view=diff
==============================================================================
--- 
felix/sandbox/cziegeler/bnd-maven-plugin/src/main/java/org/apache/felix/bundleplugin/baseline/BaselinePlugin.java
 (original)
+++ 
felix/sandbox/cziegeler/bnd-maven-plugin/src/main/java/org/apache/felix/bundleplugin/baseline/BaselinePlugin.java
 Tue Mar  3 13:03:27 2015
@@ -19,17 +19,18 @@
 package org.apache.felix.bundleplugin.baseline;
 
 import java.io.File;
-import java.io.FileWriter;
 import java.io.IOException;
 import java.io.LineNumberReader;
 import java.io.StringReader;
 import java.util.Map;
-import java.util.Map.Entry;
 
+import org.apache.maven.plugins.annotations.Component;
+import org.apache.maven.plugins.annotations.LifecyclePhase;
+import org.apache.maven.plugins.annotations.Mojo;
+import org.apache.maven.plugins.annotations.Parameter;
+import org.apache.maven.plugins.annotations.ResolutionScope;
 import org.codehaus.plexus.util.FileUtils;
 import org.codehaus.plexus.util.IOUtil;
-import org.codehaus.plexus.util.xml.PrettyPrintXMLWriter;
-import org.codehaus.plexus.util.xml.XMLWriter;
 import org.sonatype.plexus.build.incremental.BuildContext;
 
 import aQute.bnd.differ.Baseline.Info;
@@ -41,12 +42,13 @@ import aQute.bnd.version.Version;
 /**
  * BND Baseline check between two bundles.
  *
- * @goal baseline
- * @phase verify
- * @requiresDependencyResolution test
- * @threadSafe true
- * @since 2.4.1
  */
+@Mojo(
+        name = "baseline",
+        defaultPhase = LifecyclePhase.VERIFY,
+        requiresDependencyResolution = ResolutionScope.COMPILE,
+        threadSafe = true
+)
 public final class BaselinePlugin
     extends AbstractBaselinePlugin
 {
@@ -54,73 +56,21 @@ public final class BaselinePlugin
     private static final String TABLE_PATTERN = "%s %-50s %-10s %-10s %-10s 
%-10s %-10s";
 
     /**
-     * An XML output file to render to 
<code>${project.build.directory}/baseline.xml</code>.
-     *
-     * @parameter expression="${project.build.directory}/baseline.xml"
-     */
-    private File xmlOutputFile;
-
-    /**
      * Whether to log the results to the console or not, true by default.
      *
-     * @parameter expression="${logResults}" default-value="true"
      */
+    @Parameter(property="logResults", defaultValue="true")
     private boolean logResults;
 
-    /**
-     * @component
-     */
+    @Component
     private BuildContext buildContext;
 
-    private static final class Context {
-        public FileWriter writer;
-        public XMLWriter xmlWriter;
-    }
-
-    @Override
-    protected Object init(final Object noContext)
-    {
-        if ( xmlOutputFile != null )
-        {
-            xmlOutputFile.getParentFile().mkdirs();
-            try
-            {
-                final Context ctx = new Context();
-                ctx.writer = new FileWriter( xmlOutputFile );
-                ctx.xmlWriter = new PrettyPrintXMLWriter( ctx.writer );
-                return ctx;
-            }
-            catch ( IOException e )
-            {
-                getLog().warn( "No XML report will be produced, cannot write 
data to " + xmlOutputFile, e );
-            }
-        }
-        return null;
-    }
-
-    @Override
-    protected void close(final Object writer)
-    {
-        if ( writer != null )
-        {
-            try {
-
-                ((Context)writer).writer.close();
-            }
-            catch (IOException e)
-            {
-                // ignore
-            }
-        }
-    }
     @Override
-    protected void startBaseline( Object context,
-                                  String generationDate,
+    protected void startBaseline( String generationDate,
                                   String bundleName,
                                   String currentVersion,
                                   String previousVersion )
     {
-        final XMLWriter xmlWriter = context == null ? null : 
((Context)context).xmlWriter;
         if ( isLoggingResults() )
         {
             log( "Baseline Report - Generated by Apache Felix Maven Bundle 
Plugin on %s based on Bnd - see http://www.aqute.biz/Bnd/Bnd";,
@@ -147,26 +97,10 @@ public final class BaselinePlugin
                  "==========" );
         }
 
-        if ( xmlWriter != null )
-        {
-            xmlWriter.startElement( "baseline" );
-            xmlWriter.addAttribute( "version", "1.0.0" );
-            xmlWriter.addAttribute( "vendor", "The Apache Software Foundation" 
);
-            xmlWriter.addAttribute( "vendorURL", "http://www.apache.org/"; );
-            xmlWriter.addAttribute( "generator", "Apache Felix Maven Bundle 
Plugin" );
-            xmlWriter.addAttribute( "generatorURL", 
"http://felix.apache.org/site/apache-felix-maven-bundle-plugin-bnd.html"; );
-            xmlWriter.addAttribute( "analyzer", "Bnd" );
-            xmlWriter.addAttribute( "analyzerURL", 
"http://www.aqute.biz/Bnd/Bnd"; );
-            xmlWriter.addAttribute( "generatedOn", generationDate );
-            xmlWriter.addAttribute( "bundleName", bundleName );
-            xmlWriter.addAttribute( "currentVersion", currentVersion );
-            xmlWriter.addAttribute( "previousVersion", previousVersion );
-        }
     }
 
     @Override
-    protected void startPackage( Object context,
-                                 boolean mismatch,
+    protected void startPackage( boolean mismatch,
                                  String name,
                                  String shortDelta,
                                  String delta,
@@ -176,7 +110,6 @@ public final class BaselinePlugin
                                  DiffMessage diffMessage,
                                  Map<String,String> attributes )
     {
-        final XMLWriter xmlWriter = context == null ? null : 
((Context)context).xmlWriter;
         if ( isLoggingResults() )
         {
             log( TABLE_PATTERN,
@@ -190,49 +123,11 @@ public final class BaselinePlugin
                  attributes );
         }
 
-        if ( xmlWriter != null )
-        {
-            xmlWriter.startElement( "package" );
-            xmlWriter.addAttribute( "name", name );
-            xmlWriter.addAttribute( "delta", delta );
-            simpleElement( xmlWriter, "mismatch", String.valueOf( mismatch ) );
-            simpleElement( xmlWriter, "newerVersion", newerVersion.toString() 
);
-            simpleElement( xmlWriter, "olderVersion", olderVersion.toString() 
);
-            if ( suggestedVersion != null )
-            {
-                simpleElement( xmlWriter, "suggestedVersion", 
suggestedVersion.toString() );
-            }
-
-            if ( diffMessage != null )
-            {
-                simpleElement( xmlWriter, diffMessage.getType().name(), 
diffMessage.getMessage() );
-            }
-
-            xmlWriter.startElement( "attributes" );
-            if (attributes != null)
-            {
-                for (Entry<String, String> attribute : attributes.entrySet())
-                {
-                    String attributeName = attribute.getKey();
-                    if (':' == attributeName.charAt(attributeName.length() - 
1))
-                    {
-                        attributeName = attributeName.substring(0, 
attributeName.length() - 1);
-                    }
-                    String attributeValue = attribute.getValue();
-
-                    xmlWriter.startElement(attributeName);
-                    xmlWriter.writeText(attributeValue);
-                    xmlWriter.endElement();
-                }
-            }
-            xmlWriter.endElement();
-        }
     }
 
     @Override
-    protected void startDiff( Object context, int depth, String type, String 
name, String delta, String shortDelta )
+    protected void startDiff( int depth, String type, String name, String 
delta, String shortDelta )
     {
-        final XMLWriter xmlWriter = context == null ? null : 
((Context)context).xmlWriter;
         if ( isLoggingResults() )
         {
             log( "%-" + (depth * 4) + "s %s %s %s",
@@ -242,47 +137,27 @@ public final class BaselinePlugin
                  name );
         }
 
-        if ( xmlWriter != null )
-        {
-            xmlWriter.startElement( type );
-            xmlWriter.addAttribute( "name", name );
-            xmlWriter.addAttribute( "delta", delta );
-        }
     }
 
     @Override
-    protected void endDiff( Object context, int depth )
+    protected void endDiff( int depth )
     {
-        final XMLWriter xmlWriter = context == null ? null : 
((Context)context).xmlWriter;
-        if ( xmlWriter != null )
-        {
-            xmlWriter.endElement();
-        }
+        // nothing to do
     }
 
     @Override
-    protected void endPackage(Object context)
+    protected void endPackage()
     {
-        final XMLWriter xmlWriter = context == null ? null : 
((Context)context).xmlWriter;
         if ( isLoggingResults() )
         {
             log( 
"-----------------------------------------------------------------------------------------------------------"
 );
         }
-
-        if ( xmlWriter != null )
-        {
-            xmlWriter.endElement();
-        }
     }
 
     @Override
-    protected void endBaseline(Object context)
+    protected void endBaseline()
     {
-        final XMLWriter xmlWriter = context == null ? null : 
((Context)context).xmlWriter;
-        if ( xmlWriter != null )
-        {
-            xmlWriter.endElement();
-        }
+        // nothing to do
     }
 
     private boolean isLoggingResults()
@@ -295,13 +170,6 @@ public final class BaselinePlugin
         getLog().info( String.format( format, args ) );
     }
 
-    private void simpleElement( XMLWriter xmlWriter, String name, String value 
)
-    {
-        xmlWriter.startElement( name );
-        xmlWriter.writeText( value );
-        xmlWriter.endElement();
-    }
-
     @Override
     protected void reportErrors(final Info[] infos)
     throws IOException

Modified: 
felix/sandbox/cziegeler/bnd-maven-plugin/src/main/resources/META-INF/m2e/lifecycle-mapping-metadata.xml
URL: 
http://svn.apache.org/viewvc/felix/sandbox/cziegeler/bnd-maven-plugin/src/main/resources/META-INF/m2e/lifecycle-mapping-metadata.xml?rev=1663692&r1=1663691&r2=1663692&view=diff
==============================================================================
--- 
felix/sandbox/cziegeler/bnd-maven-plugin/src/main/resources/META-INF/m2e/lifecycle-mapping-metadata.xml
 (original)
+++ 
felix/sandbox/cziegeler/bnd-maven-plugin/src/main/resources/META-INF/m2e/lifecycle-mapping-metadata.xml
 Tue Mar  3 13:03:27 2015
@@ -21,6 +21,7 @@
         <pluginExecution>
             <pluginExecutionFilter>
                 <goals>
+                    <goal>bundle</goal>
                     <goal>baseline</goal>
                 </goals>
             </pluginExecutionFilter>


Reply via email to