diff --git a/bundleplugin/src/main/java/org/apache/felix/bundleplugin/AbstractDependencyFilter.java b/bundleplugin/src/main/java/org/apache/felix/bundleplugin/AbstractDependencyFilter.java
index 06cf109..3918cc3 100644
--- a/bundleplugin/src/main/java/org/apache/felix/bundleplugin/AbstractDependencyFilter.java
+++ b/bundleplugin/src/main/java/org/apache/felix/bundleplugin/AbstractDependencyFilter.java
@@ -115,7 +115,8 @@
             StringBuilder tag = new StringBuilder();
             tag.append( clause.getKey() );
 
-            if( !((String)clause.getKey()).matches("\\*~*") ) {
+            if ( !( ( String ) clause.getKey() ).matches( "\\*~*" ) )
+            {
                 filter = new DependencyFilter( ( String ) clause.getKey() )
                 {
                     boolean matches( Artifact dependency )
diff --git a/bundleplugin/src/main/java/org/apache/felix/bundleplugin/BlueprintPlugin.java b/bundleplugin/src/main/java/org/apache/felix/bundleplugin/BlueprintPlugin.java
index 81aaee9..2c8b3d9 100644
--- a/bundleplugin/src/main/java/org/apache/felix/bundleplugin/BlueprintPlugin.java
+++ b/bundleplugin/src/main/java/org/apache/felix/bundleplugin/BlueprintPlugin.java
@@ -33,6 +33,7 @@
 import java.util.Set;
 import java.util.TreeSet;
 import java.util.regex.Pattern;
+
 import javax.xml.transform.Transformer;
 import javax.xml.transform.TransformerFactory;
 import javax.xml.transform.stream.StreamResult;
@@ -48,134 +49,150 @@
 import aQute.libg.reporter.Reporter;
 
 
-public class BlueprintPlugin implements AnalyzerPlugin {
+public class BlueprintPlugin implements AnalyzerPlugin
+{
 
-
-    static Pattern QN = Pattern.compile("[_A-Za-z$][_A-Za-z0-9$]*(\\.[_A-Za-z$][_A-Za-z0-9$]*)*");
-    static Pattern PATHS = Pattern.compile( ".*\\.xml");
+    static Pattern QN = Pattern.compile( "[_A-Za-z$][_A-Za-z0-9$]*(\\.[_A-Za-z$][_A-Za-z0-9$]*)*" );
+    static Pattern PATHS = Pattern.compile( ".*\\.xml" );
 
     Transformer transformer;
 
-    public BlueprintPlugin() throws Exception {
-        transformer = getTransformer(getClass().getResource("blueprint.xsl"));
+
+    public BlueprintPlugin() throws Exception
+    {
+        transformer = getTransformer( getClass().getResource( "blueprint.xsl" ) );
     }
 
-    public boolean analyzeJar(Analyzer analyzer) throws Exception {
-        transformer.setParameter("nsh_interface", analyzer.getProperty("nsh_interface") != null ? analyzer.getProperty("nsh_interface") : "");
-        transformer.setParameter("nsh_namespace", analyzer.getProperty("nsh_namespace") != null ? analyzer.getProperty("nsh_namespace") : "");
+
+    public boolean analyzeJar( Analyzer analyzer ) throws Exception
+    {
+        transformer.setParameter( "nsh_interface",
+            analyzer.getProperty( "nsh_interface" ) != null ? analyzer.getProperty( "nsh_interface" ) : "" );
+        transformer.setParameter( "nsh_namespace",
+            analyzer.getProperty( "nsh_namespace" ) != null ? analyzer.getProperty( "nsh_namespace" ) : "" );
 
         Set<String> headers = Create.set();
 
-        String bpHeader = analyzer.getProperty("Bundle-Blueprint", "OSGI-INF/blueprint");
-        Map<String, Map<String,String>> map = Processor.parseHeader(bpHeader, null);
-        for (String root : map.keySet())
+        String bpHeader = analyzer.getProperty( "Bundle-Blueprint", "OSGI-INF/blueprint" );
+        Map<String, Map<String, String>> map = Processor.parseHeader( bpHeader, null );
+        for ( String root : map.keySet() )
         {
             Jar jar = analyzer.getJar();
-            Map<String, Resource> dir = jar.getDirectories().get(root);
-            if(dir == null || dir.isEmpty())
+            Map<String, Resource> dir = jar.getDirectories().get( root );
+            if ( dir == null || dir.isEmpty() )
             {
-                Resource resource = jar.getResource(root);
-                if(resource != null)
-                    process(analyzer, root, resource, headers);
+                Resource resource = jar.getResource( root );
+                if ( resource != null )
+                    process( analyzer, root, resource, headers );
                 return false;
             }
-            for(Map.Entry<String,Resource> entry : dir.entrySet())
+            for ( Map.Entry<String, Resource> entry : dir.entrySet() )
             {
                 String path = entry.getKey();
                 Resource resource = entry.getValue();
-                if(PATHS.matcher(path).matches())
-                    process(analyzer, path, resource, headers);
+                if ( PATHS.matcher( path ).matches() )
+                    process( analyzer, path, resource, headers );
             }
 
         }
 
         // Group and analyze
         Map<String, Set<Attribute>> hdrs = Create.map();
-        for (String str : headers) {
-            int idx = str.indexOf(':');
-            if (idx < 0)
+        for ( String str : headers )
+        {
+            int idx = str.indexOf( ':' );
+            if ( idx < 0 )
             {
-                analyzer.warning((new StringBuilder("Error analyzing services in blueprint resource: ")).append(str).toString());
+                analyzer.warning( ( new StringBuilder( "Error analyzing services in blueprint resource: " ) ).append(
+                    str ).toString() );
                 continue;
             }
-            String h = str.substring(0, idx).trim();
-            String v = str.substring(idx + 1).trim();
-            Set<Attribute> att = hdrs.get(h);
-            if (att == null) {
+            String h = str.substring( 0, idx ).trim();
+            String v = str.substring( idx + 1 ).trim();
+            Set<Attribute> att = hdrs.get( h );
+            if ( att == null )
+            {
                 att = new TreeSet<Attribute>();
-                hdrs.put(h, att);
+                hdrs.put( h, att );
             }
-            att.addAll(parseHeader(v, null));
+            att.addAll( parseHeader( v, null ) );
         }
         // Merge
-        for (String header : hdrs.keySet())
+        for ( String header : hdrs.keySet() )
         {
-            if ("Import-Class".equals(header) || "Import-Package".equals(header))
+            if ( "Import-Class".equals( header ) || "Import-Package".equals( header ) )
             {
-                Set<Attribute> newAttr = hdrs.get(header);
-                for (Attribute a : newAttr)
+                Set<Attribute> newAttr = hdrs.get( header );
+                for ( Attribute a : newAttr )
                 {
                     String pkg = a.getName();
-                    if ("Import-Class".equals(header))
+                    if ( "Import-Class".equals( header ) )
                     {
-                        int n = a.getName().lastIndexOf('.');
-                        if (n > 0) {
-                            pkg = pkg.subSequence(0, n).toString();
-                        } else {
+                        int n = a.getName().lastIndexOf( '.' );
+                        if ( n > 0 )
+                        {
+                            pkg = pkg.subSequence( 0, n ).toString();
+                        }
+                        else
+                        {
                             continue;
                         }
                     }
-                    if (!analyzer.getReferred().containsKey(pkg))
+                    if ( !analyzer.getReferred().containsKey( pkg ) )
                     {
-                        analyzer.getReferred().put(pkg, a.getProperties());
+                        analyzer.getReferred().put( pkg, a.getProperties() );
                     }
                 }
             }
             else
             {
-                Set<Attribute> orgAttr = parseHeader(analyzer.getProperty(header), null);
-                Set<Attribute> newAttr = hdrs.get(header);
-                for (Iterator<Attribute> it = newAttr.iterator(); it.hasNext();)
+                Set<Attribute> orgAttr = parseHeader( analyzer.getProperty( header ), null );
+                Set<Attribute> newAttr = hdrs.get( header );
+                for ( Iterator<Attribute> it = newAttr.iterator(); it.hasNext(); )
                 {
                     Attribute a = it.next();
-                    for (Attribute b : orgAttr)
+                    for ( Attribute b : orgAttr )
                     {
-                        if (b.getName().equals(a.getName()))
+                        if ( b.getName().equals( a.getName() ) )
                         {
                             it.remove();
                             break;
                         }
                     }
                 }
-                orgAttr.addAll(newAttr);
+                orgAttr.addAll( newAttr );
                 // Rebuild from orgAttr
                 StringBuilder sb = new StringBuilder();
-                for (Attribute a : orgAttr)
+                for ( Attribute a : orgAttr )
                 {
-                    if (sb.length() > 0)
+                    if ( sb.length() > 0 )
                     {
-                        sb.append(",");
+                        sb.append( "," );
                     }
-                    sb.append(a.getName());
-                    for (Map.Entry<String, String> prop : a.getProperties().entrySet())
+                    sb.append( a.getName() );
+                    for ( Map.Entry<String, String> prop : a.getProperties().entrySet() )
                     {
-                        sb.append(';').append(prop.getKey()).append("=");
-                        if (prop.getValue().matches("[0-9a-zA-Z_-]+")) {
-                            sb.append(prop.getValue());
-                        } else {
-                            sb.append("\"");
-                            sb.append(prop.getValue().replace("\"", "\\\""));
-                            sb.append("\"");
+                        sb.append( ';' ).append( prop.getKey() ).append( "=" );
+                        if ( prop.getValue().matches( "[0-9a-zA-Z_-]+" ) )
+                        {
+                            sb.append( prop.getValue() );
+                        }
+                        else
+                        {
+                            sb.append( "\"" );
+                            sb.append( prop.getValue().replace( "\"", "\\\"" ) );
+                            sb.append( "\"" );
                         }
                     }
                 }
-                analyzer.setProperty(header, sb.toString());
+                analyzer.setProperty( header, sb.toString() );
             }
         }
         return false;
     }
 
-    private void process(Analyzer analyzer, String path, Resource resource, Set<String> headers)
+
+    private void process( Analyzer analyzer, String path, Resource resource, Set<String> headers )
     {
         InputStream in = null;
         try
@@ -183,46 +200,47 @@
             in = resource.openInputStream();
 
             // Retrieve headers
-            Set<String> set = analyze(in);
-            headers.addAll(set);
+            Set<String> set = analyze( in );
+            headers.addAll( set );
         }
-        catch(Exception e)
+        catch ( Exception e )
         {
-            analyzer.error((new StringBuilder("Unexpected exception in processing spring resources(")).append(path).append("): ").append(e).toString());
+            analyzer.error( ( new StringBuilder( "Unexpected exception in processing spring resources(" ) )
+                .append( path ).append( "): " ).append( e ).toString() );
         }
         finally
         {
             try
             {
-                if (in != null)
+                if ( in != null )
                 {
                     in.close();
                 }
             }
-            catch (IOException e)
+            catch ( IOException e )
             {
             }
         }
     }
 
-    public Set<String> analyze(InputStream in)
-        throws Exception
+
+    public Set<String> analyze( InputStream in ) throws Exception
     {
         Set<String> refers = new HashSet<String>();
         ByteArrayOutputStream bout = new ByteArrayOutputStream();
-        javax.xml.transform.Result r = new StreamResult(bout);
-        javax.xml.transform.Source s = new StreamSource(in);
-        transformer.transform(s, r);
-        ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray());
+        javax.xml.transform.Result r = new StreamResult( bout );
+        javax.xml.transform.Source s = new StreamSource( in );
+        transformer.transform( s, r );
+        ByteArrayInputStream bin = new ByteArrayInputStream( bout.toByteArray() );
         bout.close();
-        BufferedReader br = new BufferedReader(new InputStreamReader(bin));
-        for(String line = br.readLine(); line != null; line = br.readLine())
+        BufferedReader br = new BufferedReader( new InputStreamReader( bin ) );
+        for ( String line = br.readLine(); line != null; line = br.readLine() )
         {
             line = line.trim();
-            line = line.replace(";availability:=mandatory", "");
-            if(line.length() > 0)
+            line = line.replace( ";availability:=mandatory", "" );
+            if ( line.length() > 0 )
             {
-                refers.add(line);
+                refers.add( line );
             }
         }
 
@@ -230,136 +248,157 @@
         return refers;
     }
 
-    protected Transformer getTransformer(URL url)
-        throws Exception
+
+    protected Transformer getTransformer( URL url ) throws Exception
     {
         TransformerFactory tf = TransformerFactory.newInstance();
-        javax.xml.transform.Source source = new StreamSource(url.openStream());
-        return tf.newTransformer(source);
+        javax.xml.transform.Source source = new StreamSource( url.openStream() );
+        return tf.newTransformer( source );
     }
 
     public static class Attribute implements Comparable<Attribute>
     {
         private final String name;
-        private final Map<String,String> properties;
+        private final Map<String, String> properties;
 
-        public Attribute(String name, Map<String, String> properties) {
+
+        public Attribute( String name, Map<String, String> properties )
+        {
             this.name = name;
             this.properties = properties;
         }
 
-        public String getName() {
+
+        public String getName()
+        {
             return name;
         }
 
-        public Map<String, String> getProperties() {
+
+        public Map<String, String> getProperties()
+        {
             return properties;
         }
 
-        public int compareTo(Attribute a) {
-            int c = name.compareTo(a.name);
-            if (c == 0)
+
+        public int compareTo( Attribute a )
+        {
+            int c = name.compareTo( a.name );
+            if ( c == 0 )
             {
-                c = properties.equals(a.properties) ? 0 :
-                        properties.size() < a.properties.size() ? -1 :
-                            properties.hashCode() < a.properties.hashCode() ? -1 : +1;
+                c = properties.equals( a.properties ) ? 0 : properties.size() < a.properties.size() ? -1 : properties
+                    .hashCode() < a.properties.hashCode() ? -1 : +1;
             }
             return c;
         }
 
 
         @Override
-        public boolean equals(Object o) {
-            if (this == o) return true;
-            if (o == null || getClass() != o.getClass()) return false;
+        public boolean equals( Object o )
+        {
+            if ( this == o )
+                return true;
+            if ( o == null || getClass() != o.getClass() )
+                return false;
 
-            Attribute attribute = (Attribute) o;
+            Attribute attribute = ( Attribute ) o;
 
-            if (name != null ? !name.equals(attribute.name) : attribute.name != null) return false;
-            if (properties != null ? !properties.equals(attribute.properties) : attribute.properties != null)
+            if ( name != null ? !name.equals( attribute.name ) : attribute.name != null )
+                return false;
+            if ( properties != null ? !properties.equals( attribute.properties ) : attribute.properties != null )
                 return false;
 
             return true;
         }
 
+
         @Override
-        public int hashCode() {
+        public int hashCode()
+        {
             int result = name != null ? name.hashCode() : 0;
-            result = 31 * result + (properties != null ? properties.hashCode() : 0);
+            result = 31 * result + ( properties != null ? properties.hashCode() : 0 );
             return result;
         }
     }
 
-    public static Set<Attribute> parseHeader(String value, Reporter logger)
+
+    public static Set<Attribute> parseHeader( String value, Reporter logger )
     {
-        if ((value == null) || (value.trim().length() == 0)) {
+        if ( ( value == null ) || ( value.trim().length() == 0 ) )
+        {
             return new TreeSet<Attribute>();
         }
         Set<Attribute> result = new TreeSet<Attribute>();
-        QuotedTokenizer qt = new QuotedTokenizer(value, ";=,");
+        QuotedTokenizer qt = new QuotedTokenizer( value, ";=," );
         char del = '\0';
-        do {
+        do
+        {
             boolean hadAttribute = false;
-            Map<String,String> clause = Create.map();
+            Map<String, String> clause = Create.map();
             List<String> aliases = Create.list();
-            String name = qt.nextToken(",;");
+            String name = qt.nextToken( ",;" );
 
             del = qt.getSeparator();
-            if ((name == null) || (name.length() == 0)) {
-                if ((logger != null) && (logger.isPedantic())) {
-                    logger.warning("Empty clause, usually caused by repeating a comma without any name field or by having " +
-                                            "spaces after the backslash of a property file: " +
-                                            value);
+            if ( ( name == null ) || ( name.length() == 0 ) )
+            {
+                if ( ( logger != null ) && ( logger.isPedantic() ) )
+                {
+                    logger
+                        .warning( "Empty clause, usually caused by repeating a comma without any name field or by having "
+                            + "spaces after the backslash of a property file: " + value );
                 }
 
-                if (name != null)
+                if ( name != null )
                     continue;
                 break;
             }
             name = name.trim();
 
-            aliases.add(name);
+            aliases.add( name );
             String advalue;
-            while (del == ';') {
+            while ( del == ';' )
+            {
                 String adname = qt.nextToken();
-                if ((del = qt.getSeparator()) != '=') {
-                    if ((hadAttribute) && (logger != null)) {
-                        logger.error("Header contains name field after attribute or directive: " +
-                                        adname +
-                                        " from " +
-                                        value +
-                                        ". Name fields must be consecutive, separated by a ';' like a;b;c;x=3;y=4");
+                if ( ( del = qt.getSeparator() ) != '=' )
+                {
+                    if ( ( hadAttribute ) && ( logger != null ) )
+                    {
+                        logger.error( "Header contains name field after attribute or directive: " + adname + " from "
+                            + value + ". Name fields must be consecutive, separated by a ';' like a;b;c;x=3;y=4" );
                     }
 
-                    if ((adname != null) && (adname.length() > 0))
-                        aliases.add(adname.trim());
-                } else {
+                    if ( ( adname != null ) && ( adname.length() > 0 ) )
+                        aliases.add( adname.trim() );
+                }
+                else
+                {
                     advalue = qt.nextToken();
-                    if ((clause.containsKey(adname)) && (logger != null) && (logger.isPedantic())) {
-                        logger.warning("Duplicate attribute/directive name " +
-                            adname +
-                            " in " +
-                            value +
-                            ". This attribute/directive will be ignored");
+                    if ( ( clause.containsKey( adname ) ) && ( logger != null ) && ( logger.isPedantic() ) )
+                    {
+                        logger.warning( "Duplicate attribute/directive name " + adname + " in " + value
+                            + ". This attribute/directive will be ignored" );
                     }
 
-                    if (advalue == null) {
-                        if (logger != null) {
-                            logger.error("No value after '=' sign for attribute " + adname);
+                    if ( advalue == null )
+                    {
+                        if ( logger != null )
+                        {
+                            logger.error( "No value after '=' sign for attribute " + adname );
                         }
                         advalue = "";
                     }
-                    clause.put(adname.trim(), advalue.trim());
+                    clause.put( adname.trim(), advalue.trim() );
                     del = qt.getSeparator();
                     hadAttribute = true;
                 }
             }
 
-            for (String clauseName : aliases) {
-                result.add(new Attribute(clauseName, clause));
+            for ( String clauseName : aliases )
+            {
+                result.add( new Attribute( clauseName, clause ) );
             }
         }
-        while (del == ',');
+        while ( del == ',' );
         return result;
     }
 
diff --git a/bundleplugin/src/main/java/org/apache/felix/bundleplugin/BundlePlugin.java b/bundleplugin/src/main/java/org/apache/felix/bundleplugin/BundlePlugin.java
index fd31a98..f5402a6 100644
--- a/bundleplugin/src/main/java/org/apache/felix/bundleplugin/BundlePlugin.java
+++ b/bundleplugin/src/main/java/org/apache/felix/bundleplugin/BundlePlugin.java
@@ -202,7 +202,7 @@
      * @required
      * @readonly
      */
-    private MavenSession m_mavenSession;   
+    private MavenSession m_mavenSession;
 
     private static final String MAVEN_SYMBOLICNAME = "maven-symbolicname";
     private static final String MAVEN_RESOURCES = "{maven-resources}";
@@ -324,7 +324,7 @@
             {
                 // treat as warning; this error happens when you have duplicate entries in Include-Resource
                 String duplicate = Processor.removeDuplicateMarker( msg.substring( fileNotFound.length() ) );
-                getLog().warn( prefix + " : Duplicate path '" + duplicate  + "' in Include-Resource" );
+                getLog().warn( prefix + " : Duplicate path '" + duplicate + "' in Include-Resource" );
             }
             else
             {
@@ -429,6 +429,7 @@
         return builder;
     }
 
+
     protected void addMavenInstructions( MavenProject currentProject, Builder builder ) throws Exception
     {
         if ( currentProject.getBasedir() != null )
@@ -599,8 +600,7 @@
     }
 
 
-    protected void mergeMavenManifest( MavenProject currentProject, Builder builder )
-        throws Exception
+    protected void mergeMavenManifest( MavenProject currentProject, Builder builder ) throws Exception
     {
         Jar jar = builder.getJar();
 
@@ -685,20 +685,23 @@
 
             // adjust the import package attributes so that optional dependencies use
             // optional resolution.
-            String importPackages = bundleManifest.getMainAttributes().getValue("Import-Package");
-            if( importPackages!=null ) {
-                Set optionalPackages = getOptionalPackages(currentProject);
+            String importPackages = bundleManifest.getMainAttributes().getValue( "Import-Package" );
+            if ( importPackages != null )
+            {
+                Set optionalPackages = getOptionalPackages( currentProject );
 
-                Map<String, Map<String, String>> values = new Analyzer().parseHeader(importPackages);
-                for (Map.Entry<String, Map<String, String>> entry: values.entrySet()) {
+                Map<String, Map<String, String>> values = new Analyzer().parseHeader( importPackages );
+                for ( Map.Entry<String, Map<String, String>> entry : values.entrySet() )
+                {
                     String pkg = entry.getKey();
                     Map<String, String> options = entry.getValue();
-                    if( !options.containsKey("resolution:") && optionalPackages.contains(pkg) ) {
-                        options.put("resolution:", "optional");
+                    if ( !options.containsKey( "resolution:" ) && optionalPackages.contains( pkg ) )
+                    {
+                        options.put( "resolution:", "optional" );
                     }
                 }
-                String result = Processor.printClauses(values, "resolution:");
-                bundleManifest.getMainAttributes().putValue("Import-Package", result);
+                String result = Processor.printClauses( values, "resolution:" );
+                bundleManifest.getMainAttributes().putValue( "Import-Package", result );
             }
 
             jar.setManifest( bundleManifest );
@@ -733,7 +736,7 @@
             {
                 if ( !Artifact.SCOPE_TEST.equals( artifact.getScope() ) )
                 {
-                    inscope.add(artifact);
+                    inscope.add( artifact );
                 }
             }
         }
@@ -742,13 +745,15 @@
         for ( Iterator it = inscope.iterator(); it.hasNext(); )
         {
             Artifact artifact = ( Artifact ) it.next();
-            if( artifact.isOptional() ) {
+            if ( artifact.isOptional() )
+            {
                 String id = artifact.toString();
-                if( artifact.getScope()!=null ) {
+                if ( artifact.getScope() != null )
+                {
                     // strip the scope...
-                    id = id.replaceFirst(":[^:]*$", "");
+                    id = id.replaceFirst( ":[^:]*$", "" );
                 }
-                optionalArtifactIds.add(id);
+                optionalArtifactIds.add( id );
             }
 
         }
@@ -765,35 +770,43 @@
             }
 
             Jar jar = new Jar( artifact.getArtifactId(), file );
-            if( isTransitivelyOptional(optionalArtifactIds, artifact) ) {
-                optional.addAll(jar.getPackages());
-            } else {
-                required.addAll(jar.getPackages());
+            if ( isTransitivelyOptional( optionalArtifactIds, artifact ) )
+            {
+                optional.addAll( jar.getPackages() );
+            }
+            else
+            {
+                required.addAll( jar.getPackages() );
             }
             jar.close();
         }
 
-        optional.removeAll(required);
+        optional.removeAll( required );
         return optional;
     }
 
+
     /**
      * Check to see if any dependency along the dependency trail of
      * the artifact is optional.
      *
      * @param artifact
      */
-    protected boolean isTransitivelyOptional(HashSet optionalArtifactIds, Artifact artifact) {
+    protected boolean isTransitivelyOptional( HashSet optionalArtifactIds, Artifact artifact )
+    {
         List trail = artifact.getDependencyTrail();
-        for (Iterator iterator = trail.iterator(); iterator.hasNext();) {
-            String next = (String) iterator.next();
-            if( optionalArtifactIds.contains(next) ) {
+        for ( Iterator iterator = trail.iterator(); iterator.hasNext(); )
+        {
+            String next = ( String ) iterator.next();
+            if ( optionalArtifactIds.contains( next ) )
+            {
                 return true;
             }
         }
         return false;
     }
 
+
     private void unpackBundle( File jarFile )
     {
         File outputDir = getOutputDirectory();
@@ -917,9 +930,7 @@
         p.put( "artifactId", currentProject.getArtifactId() );
         ByteArrayOutputStream out = new ByteArrayOutputStream();
         p.store( out, "Generated by org.apache.felix.bundleplugin" );
-        jar
-            .putResource( path + "/pom.properties",
-                new EmbeddedResource( out.toByteArray(), System.currentTimeMillis() ) );
+        jar.putResource( path + "/pom.properties", new EmbeddedResource( out.toByteArray(), System.currentTimeMillis() ) );
     }
 
 
@@ -1071,7 +1082,7 @@
         properties.put( MAVEN_SYMBOLICNAME, bsn );
         properties.put( Analyzer.BUNDLE_SYMBOLICNAME, bsn );
         properties.put( Analyzer.IMPORT_PACKAGE, "*" );
-        properties.put( Analyzer.BUNDLE_VERSION, getMaven2OsgiConverter().getVersion(currentProject.getVersion()) );
+        properties.put( Analyzer.BUNDLE_VERSION, getMaven2OsgiConverter().getVersion( currentProject.getVersion() ) );
 
         // remove the extraneous Include-Resource and Private-Package entries from generated manifest
         properties.put( Constants.REMOVEHEADERS, Analyzer.INCLUDE_RESOURCE + ',' + Analyzer.PRIVATE_PACKAGE );
@@ -1120,9 +1131,7 @@
         properties.put( "classifier", classifier == null ? "" : classifier );
 
         // Add default plugins
-        header( properties, Analyzer.PLUGIN,
-                    BlueprintPlugin.class.getName() + ","
-                        + SpringXMLType.class.getName());
+        header( properties, Analyzer.PLUGIN, BlueprintPlugin.class.getName() + "," + SpringXMLType.class.getName() );
 
         return properties;
     }
@@ -1170,8 +1179,8 @@
 
         StringBuffer exportedPkgs = new StringBuffer();
         StringBuffer privatePkgs = new StringBuffer();
-        
-        boolean noprivatePackages = "!*".equals(analyzer.getProperty( Analyzer.PRIVATE_PACKAGE ) );
+
+        boolean noprivatePackages = "!*".equals( analyzer.getProperty( Analyzer.PRIVATE_PACKAGE ) );
 
         for ( Iterator i = packages.iterator(); i.hasNext(); )
         {
@@ -1183,7 +1192,7 @@
             // we can't export the default package (".") and we shouldn't export internal packages 
             if ( noprivatePackages || !( ".".equals( pkg ) || pkg.contains( ".internal" ) || pkg.contains( ".impl" ) ) )
             {
-                if( exportedPkgs.length() > 0 )
+                if ( exportedPkgs.length() > 0 )
                 {
                     exportedPkgs.append( ';' );
                 }
@@ -1207,7 +1216,7 @@
         else
         {
             String exported = analyzer.getProperty( Analyzer.EXPORT_PACKAGE );
-            if( exported.indexOf( LOCAL_PACKAGES ) >= 0 )
+            if ( exported.indexOf( LOCAL_PACKAGES ) >= 0 )
             {
                 String newExported = StringUtils.replace( exported, LOCAL_PACKAGES, exportedPkgs.toString() );
                 analyzer.setProperty( Analyzer.EXPORT_PACKAGE, newExported );
@@ -1232,7 +1241,7 @@
 
     private static List getMavenResources( MavenProject currentProject )
     {
-        List resources = new ArrayList(currentProject.getResources());
+        List resources = new ArrayList( currentProject.getResources() );
 
         if ( currentProject.getCompileSourceRoots() != null )
         {
@@ -1240,7 +1249,7 @@
             List packageInfoIncludes = Collections.singletonList( "**/packageinfo" );
             for ( Iterator i = currentProject.getCompileSourceRoots().iterator(); i.hasNext(); )
             {
-                String sourceRoot = (String) i.next();
+                String sourceRoot = ( String ) i.next();
                 Resource packageInfoResource = new Resource();
                 packageInfoResource.setDirectory( sourceRoot );
                 packageInfoResource.setIncludes( packageInfoIncludes );
@@ -1334,7 +1343,7 @@
         }
 
         StringBuffer resourcePaths = new StringBuffer();
-        for ( Iterator i = pathSet.iterator() ; i.hasNext(); )
+        for ( Iterator i = pathSet.iterator(); i.hasNext(); )
         {
             resourcePaths.append( i.next() );
             if ( i.hasNext() )
diff --git a/bundleplugin/src/main/java/org/apache/felix/bundleplugin/DependencyEmbedder.java b/bundleplugin/src/main/java/org/apache/felix/bundleplugin/DependencyEmbedder.java
index 6937206..9c01de8 100644
--- a/bundleplugin/src/main/java/org/apache/felix/bundleplugin/DependencyEmbedder.java
+++ b/bundleplugin/src/main/java/org/apache/felix/bundleplugin/DependencyEmbedder.java
@@ -26,8 +26,8 @@
 import java.util.Map;
 
 import org.apache.maven.artifact.Artifact;
-import org.apache.maven.plugin.logging.Log;
 import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.logging.Log;
 import org.codehaus.plexus.util.StringUtils;
 
 import aQute.lib.osgi.Analyzer;
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 4d46efd..212dd3d 100644
--- a/bundleplugin/src/main/java/org/apache/felix/bundleplugin/ManifestPlugin.java
+++ b/bundleplugin/src/main/java/org/apache/felix/bundleplugin/ManifestPlugin.java
@@ -127,8 +127,8 @@
     }
 
 
-    protected Analyzer getAnalyzer( MavenProject project, Jar[] classpath )
-        throws IOException, MojoExecutionException, Exception
+    protected Analyzer getAnalyzer( MavenProject project, Jar[] classpath ) throws IOException, MojoExecutionException,
+        Exception
     {
         return getAnalyzer( project, new LinkedHashMap(), new Properties(), classpath );
     }
@@ -152,9 +152,9 @@
 
         analyzer.setJar( file );
 
-        if ( analyzer.getProperty( Analyzer.EXPORT_PACKAGE ) == null &&
-             analyzer.getProperty( Analyzer.EXPORT_CONTENTS ) == null &&
-             analyzer.getProperty( Analyzer.PRIVATE_PACKAGE ) == null )
+        if ( analyzer.getProperty( Analyzer.EXPORT_PACKAGE ) == null
+            && analyzer.getProperty( Analyzer.EXPORT_CONTENTS ) == null
+            && analyzer.getProperty( Analyzer.PRIVATE_PACKAGE ) == null )
         {
             String export = analyzer.calculateExportsFromContents( analyzer.getJar() );
             analyzer.setProperty( Analyzer.EXPORT_PACKAGE, export );
diff --git a/bundleplugin/src/main/java/org/apache/felix/bundleplugin/PackageVersionAnalyzer.java b/bundleplugin/src/main/java/org/apache/felix/bundleplugin/PackageVersionAnalyzer.java
index e6ee34b..c4d24b9 100644
--- a/bundleplugin/src/main/java/org/apache/felix/bundleplugin/PackageVersionAnalyzer.java
+++ b/bundleplugin/src/main/java/org/apache/felix/bundleplugin/PackageVersionAnalyzer.java
@@ -32,34 +32,34 @@
     /*
      * Remove META-INF subfolders from exports and set package versions to bundle version.
      */
-/*
-    public Map analyzeBundleClasspath( Jar dot, Map bundleClasspath, Map contained, Map referred, Map uses )
-        throws IOException
-    {
-        Map classSpace = super.analyzeBundleClasspath( dot, bundleClasspath, contained, referred, uses );
-        String bundleVersion = getProperty( BUNDLE_VERSION );
-        for ( Iterator it = contained.entrySet().iterator(); it.hasNext(); )
+    /*
+        public Map analyzeBundleClasspath( Jar dot, Map bundleClasspath, Map contained, Map referred, Map uses )
+            throws IOException
         {
-            Map.Entry entry = ( Map.Entry ) it.next();
-
-            // remove packages under META-INF
-            String packageName = ( String ) entry.getKey();
-            if ( packageName.startsWith( "META-INF." ) )
+            Map classSpace = super.analyzeBundleClasspath( dot, bundleClasspath, contained, referred, uses );
+            String bundleVersion = getProperty( BUNDLE_VERSION );
+            for ( Iterator it = contained.entrySet().iterator(); it.hasNext(); )
             {
-                it.remove();
-            }
+                Map.Entry entry = ( Map.Entry ) it.next();
 
-            // set package versions to bundle version values
-            if ( bundleVersion != null )
-            {
-                Map values = ( Map ) entry.getValue();
-                if ( values.get( "version" ) == null )
+                // remove packages under META-INF
+                String packageName = ( String ) entry.getKey();
+                if ( packageName.startsWith( "META-INF." ) )
                 {
-                    values.put( "version", bundleVersion );
+                    it.remove();
+                }
+
+                // set package versions to bundle version values
+                if ( bundleVersion != null )
+                {
+                    Map values = ( Map ) entry.getValue();
+                    if ( values.get( "version" ) == null )
+                    {
+                        values.put( "version", bundleVersion );
+                    }
                 }
             }
+            return classSpace;
         }
-        return classSpace;
-    }
-*/
+    */
 }
diff --git a/bundleplugin/src/main/java/org/apache/felix/bundleplugin/VersionCleanerPlugin.java b/bundleplugin/src/main/java/org/apache/felix/bundleplugin/VersionCleanerPlugin.java
index 6b33c9d..22e9024 100644
--- a/bundleplugin/src/main/java/org/apache/felix/bundleplugin/VersionCleanerPlugin.java
+++ b/bundleplugin/src/main/java/org/apache/felix/bundleplugin/VersionCleanerPlugin.java
@@ -18,6 +18,7 @@
  */
 package org.apache.felix.bundleplugin;
 
+
 import java.util.LinkedHashMap;
 import java.util.Map;
 
@@ -28,12 +29,14 @@
 import org.apache.maven.shared.osgi.DefaultMaven2OsgiConverter;
 import org.apache.maven.shared.osgi.Maven2OsgiConverter;
 
+
 /**
  * @goal cleanVersions
  * @description clean OSGi versions
  * @threadSafe
  */
-public class VersionCleanerPlugin extends AbstractMojo {
+public class VersionCleanerPlugin extends AbstractMojo
+{
 
     /**
      * The BND instructions for the bundle.
@@ -53,21 +56,27 @@
 
     private Maven2OsgiConverter maven2OsgiConverter = new DefaultMaven2OsgiConverter();
 
-    public Maven2OsgiConverter getMaven2OsgiConverter() {
+
+    public Maven2OsgiConverter getMaven2OsgiConverter()
+    {
         return maven2OsgiConverter;
     }
 
-    public void setMaven2OsgiConverter(Maven2OsgiConverter maven2OsgiConverter) {
+
+    public void setMaven2OsgiConverter( Maven2OsgiConverter maven2OsgiConverter )
+    {
         this.maven2OsgiConverter = maven2OsgiConverter;
     }
 
-    public void execute() throws MojoExecutionException, MojoFailureException {
-        for (Object key : versions.keySet())
+
+    public void execute() throws MojoExecutionException, MojoFailureException
+    {
+        for ( Object key : versions.keySet() )
         {
-            String name = (String) key;
-            String version = (String) versions.get(key);
-            String osgi = maven2OsgiConverter.getVersion(version);
-            project.getProperties().put(name, osgi);
+            String name = ( String ) key;
+            String version = ( String ) versions.get( key );
+            String osgi = maven2OsgiConverter.getVersion( version );
+            project.getProperties().put( name, osgi );
         }
     }
 }
diff --git a/bundleplugin/src/main/java/org/apache/felix/obrplugin/ObrDeploy.java b/bundleplugin/src/main/java/org/apache/felix/obrplugin/ObrDeploy.java
index 258e470..bd69d17 100644
--- a/bundleplugin/src/main/java/org/apache/felix/obrplugin/ObrDeploy.java
+++ b/bundleplugin/src/main/java/org/apache/felix/obrplugin/ObrDeploy.java
@@ -233,7 +233,7 @@
             {
                 // public URL differs from the bundle file location
                 URI uri = URI.create( bundleUrl );
-                log.info("Computed bundle uri: " + uri);
+                log.info( "Computed bundle uri: " + uri );
                 userConfig.setRemoteBundle( uri );
             }
             else if ( prefixUrl != null )
@@ -244,7 +244,7 @@
                     .toASCIIString();
                 URL resourceURL = new URL( new URL( prefixUrl + '/' ), relative );
                 URI uri = URI.create( resourceURL.toString() );
-                log.info("Computed bundle uri: " + uri);
+                log.info( "Computed bundle uri: " + uri );
                 userConfig.setRemoteBundle( uri );
             }
 
diff --git a/bundleplugin/src/main/java/org/apache/felix/obrplugin/ObrDeployFile.java b/bundleplugin/src/main/java/org/apache/felix/obrplugin/ObrDeployFile.java
index 2dc8f55..8a33c7a 100644
--- a/bundleplugin/src/main/java/org/apache/felix/obrplugin/ObrDeployFile.java
+++ b/bundleplugin/src/main/java/org/apache/felix/obrplugin/ObrDeployFile.java
@@ -187,14 +187,14 @@
             {
                 // public URL differs from the bundle file location
                 URI uri = URI.create( bundleUrl );
-                log.info("Computed bundle uri: " + uri);
+                log.info( "Computed bundle uri: " + uri );
                 userConfig.setRemoteBundle( uri );
             }
             else if ( null != file )
             {
                 // assume file will be deployed in remote repository, so find the remote relative location
                 URI uri = URI.create( localRepository.pathOf( project.getArtifact() ) );
-                log.info("Computed bundle uri: " + uri);
+                log.info( "Computed bundle uri: " + uri );
                 userConfig.setRemoteBundle( uri );
             }
 
diff --git a/bundleplugin/src/main/java/org/apache/felix/obrplugin/ObrIndex.java b/bundleplugin/src/main/java/org/apache/felix/obrplugin/ObrIndex.java
index cfa77f5..9667af5 100644
--- a/bundleplugin/src/main/java/org/apache/felix/obrplugin/ObrIndex.java
+++ b/bundleplugin/src/main/java/org/apache/felix/obrplugin/ObrIndex.java
@@ -18,6 +18,7 @@
  */
 package org.apache.felix.obrplugin;
 
+
 import java.io.File;
 import java.io.FileFilter;
 import java.io.FileWriter;
@@ -38,6 +39,7 @@
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.plugin.logging.Log;
 
+
 /**
  * Index the content of a maven repository using OBR
  *
@@ -46,7 +48,8 @@
  *
  * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
  */
-public final class ObrIndex extends AbstractMojo {
+public final class ObrIndex extends AbstractMojo
+{
 
     /**
      * OBR Repository.
@@ -78,56 +81,62 @@
      */
     private ArtifactRepository localRepository;
 
-    public void execute() throws MojoExecutionException {
+
+    public void execute() throws MojoExecutionException
+    {
         Log log = getLog();
         try
         {
-            log.info("Indexing...");
+            log.info( "Indexing..." );
 
             String repo = mavenRepository;
-            if (repo == null) {
+            if ( repo == null )
+            {
                 repo = localRepository.getBasedir();
             }
-            URI mavenRepoUri = new File(repo).toURI();
+            URI mavenRepoUri = new File( repo ).toURI();
 
             URI repositoryXml = ObrUtils.findRepositoryXml( repo, obrRepository );
 
-            log.info("Repository:   " + mavenRepoUri);
-            log.info("OBR xml:      " + repositoryXml);
-            log.info("URL template: " + urlTemplate);
+            log.info( "Repository:   " + mavenRepoUri );
+            log.info( "OBR xml:      " + repositoryXml );
+            log.info( "URL template: " + urlTemplate );
 
             List<File> files = new ArrayList<File>();
-            findAllJars( new File(repo), files );
+            findAllJars( new File( repo ), files );
 
             DataModelHelperImpl dmh = new DataModelHelperImpl();
             RepositoryImpl repository;
 
-            File obrRepoFile = new File(repositoryXml);
-            if (obrRepoFile.isFile()) {
-                repository = (RepositoryImpl) dmh.repository( repositoryXml.toURL() );
-            } else {
+            File obrRepoFile = new File( repositoryXml );
+            if ( obrRepoFile.isFile() )
+            {
+                repository = ( RepositoryImpl ) dmh.repository( repositoryXml.toURL() );
+            }
+            else
+            {
                 repository = new RepositoryImpl();
             }
 
-            for (File file : files)
+            for ( File file : files )
             {
                 try
                 {
-                    ResourceImpl resource = (ResourceImpl) dmh.createResource(file.toURI().toURL());
-                    if (resource != null)
+                    ResourceImpl resource = ( ResourceImpl ) dmh.createResource( file.toURI().toURL() );
+                    if ( resource != null )
                     {
-                        repository.addResource(resource);
-                        doTemplate(mavenRepoUri, file, resource);
-                        log.info("Adding resource: " + file);
+                        repository.addResource( resource );
+                        doTemplate( mavenRepoUri, file, resource );
+                        log.info( "Adding resource: " + file );
                     }
                     else
                     {
-                        log.info("Ignoring non OSGi bundle: " + file);
+                        log.info( "Ignoring non OSGi bundle: " + file );
                     }
                 }
-                catch (Exception e)
+                catch ( Exception e )
                 {
-                    log.warn("Error processing bundle: " + file + " " + e.getMessage());
+                    log.warn( "Error processing bundle: " + file + " " + e.getMessage() );
                 }
             }
             Writer writer = new FileWriter( obrRepoFile );
@@ -146,94 +155,105 @@
         }
     }
 
-    protected void doTemplate(URI root, File path, ResourceImpl resource) throws IOException, URISyntaxException
+
+    protected void doTemplate( URI root, File path, ResourceImpl resource ) throws IOException, URISyntaxException
     {
         path = path.getAbsoluteFile().getCanonicalFile();
-        String finalUri = root.relativize(path.toURI()).toString();
-        if ("maven".equals(urlTemplate))
+        String finalUri = root.relativize( path.toURI() ).toString();
+        if ( "maven".equals( urlTemplate ) )
         {
-            String dir = root.relativize(path.toURI()).toString();
-            String[] p = dir.split("/");
-            if (p.length >= 4 && p[p.length-1].startsWith(p[p.length-3] + "-" + p[p.length-2]))
+            String dir = root.relativize( path.toURI() ).toString();
+            String[] p = dir.split( "/" );
+            if ( p.length >= 4 && p[p.length - 1].startsWith( p[p.length - 3] + "-" + p[p.length - 2] ) )
             {
-                String artifactId = p[p.length-3];
-                String version = p[p.length-2];
+                String artifactId = p[p.length - 3];
+                String version = p[p.length - 2];
                 String classifier;
                 String type;
                 String artifactIdVersion = artifactId + "-" + version;
                 StringBuffer sb = new StringBuffer();
-                if (p[p.length-1].charAt(artifactIdVersion.length()) == '-')
+                if ( p[p.length - 1].charAt( artifactIdVersion.length() ) == '-' )
                 {
-                    classifier = p[p.length-1].substring(artifactIdVersion.length() + 1, p[p.length-1].lastIndexOf('.'));
+                    classifier = p[p.length - 1].substring( artifactIdVersion.length() + 1,
+                        p[p.length - 1].lastIndexOf( '.' ) );
                 }
                 else
                 {
                     classifier = null;
                 }
-                type = p[p.length-1].substring(p[p.length-1].lastIndexOf('.') + 1);
-                sb.append("mvn:");
-                for (int j = 0; j < p.length - 3; j++)
+                type = p[p.length - 1].substring( p[p.length - 1].lastIndexOf( '.' ) + 1 );
+                sb.append( "mvn:" );
+                for ( int j = 0; j < p.length - 3; j++ )
                 {
-                    if (j > 0)
+                    if ( j > 0 )
                     {
-                        sb.append('.');
+                        sb.append( '.' );
                     }
-                    sb.append(p[j]);
+                    sb.append( p[j] );
                 }
-                sb.append('/').append(artifactId).append('/').append(version);
-                if (!"jar".equals(type) || classifier != null)
+                sb.append( '/' ).append( artifactId ).append( '/' ).append( version );
+                if ( !"jar".equals( type ) || classifier != null )
                 {
-                    sb.append('/');
-                    if (!"jar".equals(type))
+                    sb.append( '/' );
+                    if ( !"jar".equals( type ) )
                     {
-                        sb.append(type);
+                        sb.append( type );
                     }
-                    if (classifier != null)
+                    if ( classifier != null )
                     {
-                        sb.append('/').append(classifier);
+                        sb.append( '/' ).append( classifier );
                     }
                 }
                 finalUri = sb.toString();
             }
         }
-        else if (urlTemplate != null)
+        else if ( urlTemplate != null )
         {
             String dir = path.getParentFile().toURI().toURL().toString();
-            if (dir.endsWith("/"))
-                dir = dir.substring(0, dir.length() - 1);
+            if ( dir.endsWith( "/" ) )
+                dir = dir.substring( 0, dir.length() - 1 );
 
-            if (dir.startsWith(root.toString()))
-                dir = dir.substring(root.toString().length());
+            if ( dir.startsWith( root.toString() ) )
+                dir = dir.substring( root.toString().length() );
 
-            String url = urlTemplate.replaceAll("%v", "" + resource.getVersion());
-            url = url.replaceAll("%s", resource.getSymbolicName());
-            url = url.replaceAll("%f", path.getName());
-            url = url.replaceAll("%p", dir);
+            String url = urlTemplate.replaceAll( "%v", "" + resource.getVersion() );
+            url = url.replaceAll( "%s", resource.getSymbolicName() );
+            url = url.replaceAll( "%f", path.getName() );
+            url = url.replaceAll( "%p", dir );
             finalUri = url;
         }
-        resource.put(Resource.URI, finalUri, Property.URI);
+        resource.put( Resource.URI, finalUri, Property.URI );
     }
 
-    private final FileFilter filter = new FileFilter() {
+    private final FileFilter filter = new FileFilter()
+    {
 
-        public boolean accept(File pathname) {
-            return pathname.getName().endsWith("ar");
+        public boolean accept( File pathname )
+        {
+            return pathname.getName().endsWith( "ar" );
         }
     };
 
 
-    private void findAllJars(File mainRoot, List<File> files) {
+    private void findAllJars( File mainRoot, List<File> files )
+    {
         List<File> roots = new ArrayList<File>();
-        roots.add(mainRoot);
-        while (!roots.isEmpty()) {
-            File root = roots.remove(0);
+        roots.add( mainRoot );
+        while ( !roots.isEmpty() )
+        {
+            File root = roots.remove( 0 );
             File[] children = root.listFiles();
-            if (children != null) {
-                for (File child : children) {
-                    if (child.isFile() && filter.accept(child)) {
-                        files.add(child);
-                    } else if (child.isDirectory()) {
-                        roots.add(child);
+            if ( children != null )
+            {
+                for ( File child : children )
+                {
+                    if ( child.isFile() && filter.accept( child ) )
+                    {
+                        files.add( child );
+                    }
+                    else if ( child.isDirectory() )
+                    {
+                        roots.add( child );
                     }
                 }
             }
diff --git a/bundleplugin/src/main/java/org/apache/felix/obrplugin/ObrInstall.java b/bundleplugin/src/main/java/org/apache/felix/obrplugin/ObrInstall.java
index 24fe99a..5f4039d 100644
--- a/bundleplugin/src/main/java/org/apache/felix/obrplugin/ObrInstall.java
+++ b/bundleplugin/src/main/java/org/apache/felix/obrplugin/ObrInstall.java
@@ -41,7 +41,7 @@
  * 
  * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
  */
-public final class  ObrInstall extends AbstractMojo
+public final class ObrInstall extends AbstractMojo
 {
     /**
      * OBR Repository.
diff --git a/bundleplugin/src/main/java/org/apache/felix/obrplugin/ObrUpdate.java b/bundleplugin/src/main/java/org/apache/felix/obrplugin/ObrUpdate.java
index 6c9fe01..00adea4 100644
--- a/bundleplugin/src/main/java/org/apache/felix/obrplugin/ObrUpdate.java
+++ b/bundleplugin/src/main/java/org/apache/felix/obrplugin/ObrUpdate.java
@@ -167,15 +167,15 @@
 
             try
             {
-                m_resourceBundle = (ResourceImpl) new DataModelHelperImpl().createResource( bundleJar.toURL() );
-                if (m_resourceBundle == null)
+                m_resourceBundle = ( ResourceImpl ) new DataModelHelperImpl().createResource( bundleJar.toURL() );
+                if ( m_resourceBundle == null )
                 {
                     return;
                 }
             }
-            catch (IOException e)
+            catch ( IOException e )
             {
-                throw new MojoExecutionException("Unable to load resource information", e);
+                throw new MojoExecutionException( "Unable to load resource information", e );
             }
 
             m_resourceBundle.put( Resource.SIZE, String.valueOf( bundleFile.length() ) );
@@ -202,11 +202,11 @@
         String sourcePath = relativisePath( sourceJar );
         String docPath = relativisePath( docJar );
 
-//        m_resourceBundle.construct( m_project, bindexExtractor, sourcePath, docPath );
-//         TODO: rebuild wrt m_project
+        //        m_resourceBundle.construct( m_project, bindexExtractor, sourcePath, docPath );
+        //         TODO: rebuild wrt m_project
 
         m_repository.addResource( m_resourceBundle );
-        m_repository.setLastModified(System.currentTimeMillis());
+        m_repository.setLastModified( System.currentTimeMillis() );
     }
 
 
@@ -246,7 +246,7 @@
 
         try
         {
-            new DataModelHelperImpl().writeRepository(m_repository, writer);
+            new DataModelHelperImpl().writeRepository( m_repository, writer );
         }
         catch ( IOException e )
         {
@@ -271,11 +271,11 @@
     }
 
 
-   /**
-     * Parse the repository descriptor file.
-     *
-     * @throws MojoExecutionException if the plugin failed
-     */
+    /**
+      * Parse the repository descriptor file.
+      *
+      * @throws MojoExecutionException if the plugin failed
+      */
     public void parseRepositoryXml() throws MojoExecutionException
     {
         File fout = new File( m_repositoryXml );
@@ -288,7 +288,7 @@
         {
             try
             {
-                m_repository = (RepositoryImpl) new DataModelHelperImpl().repository( m_repositoryXml.toURL() );
+                m_repository = ( RepositoryImpl ) new DataModelHelperImpl().repository( m_repositoryXml.toURL() );
             }
             catch ( Exception e )
             {
@@ -301,54 +301,55 @@
     /**
      * put the information from obr.xml into ressourceBundle object.
      */
-    private void parseObrXml() throws MojoExecutionException {
+    private void parseObrXml() throws MojoExecutionException
+    {
         try
         {
-            InputStream is = new FileInputStream(new File(m_obrXml));
+            InputStream is = new FileInputStream( new File( m_obrXml ) );
             try
             {
                 KXmlParser kxp = new KXmlParser();
-                kxp.setInput(is, null);
+                kxp.setInput( is, null );
                 kxp.nextTag(); // skip top level element
                 kxp.nextTag(); // go to first child element
-                parseObrXml(kxp);
+                parseObrXml( kxp );
             }
             finally
             {
                 is.close();
             }
         }
-        catch (Exception e)
+        catch ( Exception e )
         {
-            throw new MojoExecutionException("Unable to parse obr xml: " + m_obrXml, e);
+            throw new MojoExecutionException( "Unable to parse obr xml: " + m_obrXml, e );
         }
     }
 
-    private void parseObrXml(KXmlParser kxp) throws Exception
+
+    private void parseObrXml( KXmlParser kxp ) throws Exception
     {
         PullParser parser = new PullParser();
-        while (kxp.getEventType() == XmlPullParser.START_TAG)
+        while ( kxp.getEventType() == XmlPullParser.START_TAG )
         {
-            if (RepositoryParser.CATEGORY.equals(kxp.getName()))
+            if ( RepositoryParser.CATEGORY.equals( kxp.getName() ) )
             {
-                m_resourceBundle.addCategory(parser.parseCategory(kxp));
+                m_resourceBundle.addCategory( parser.parseCategory( kxp ) );
             }
-            else if (RepositoryParser.REQUIRE.equals(kxp.getName()))
+            else if ( RepositoryParser.REQUIRE.equals( kxp.getName() ) )
             {
-                m_resourceBundle.addRequire(parser.parseRequire(kxp));
+                m_resourceBundle.addRequire( parser.parseRequire( kxp ) );
             }
-            else if (RepositoryParser.CAPABILITY.equals(kxp.getName()))
+            else if ( RepositoryParser.CAPABILITY.equals( kxp.getName() ) )
             {
-                m_resourceBundle.addCapability(parser.parseCapability(kxp));
+                m_resourceBundle.addCapability( parser.parseCapability( kxp ) );
             }
             else
             {
                 kxp.nextTag();
-                parseObrXml(kxp);
+                parseObrXml( kxp );
             }
             kxp.nextTag();
         }
     }
 
-
 }
diff --git a/bundleplugin/src/main/java/org/apache/maven/shared/dependency/tree/DependencyTreeResolutionListener.java b/bundleplugin/src/main/java/org/apache/maven/shared/dependency/tree/DependencyTreeResolutionListener.java
index b03b914..cd3b3c3 100644
--- a/bundleplugin/src/main/java/org/apache/maven/shared/dependency/tree/DependencyTreeResolutionListener.java
+++ b/bundleplugin/src/main/java/org/apache/maven/shared/dependency/tree/DependencyTreeResolutionListener.java
@@ -1,5 +1,6 @@
 package org.apache.maven.shared.dependency.tree;
 
+
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
@@ -34,6 +35,7 @@
 import org.apache.maven.shared.dependency.tree.traversal.CollectingDependencyNodeVisitor;
 import org.codehaus.plexus.logging.Logger;
 
+
 /**
  * An artifact resolution listener that constructs a dependency tree.
  * 
@@ -44,7 +46,7 @@
 public class DependencyTreeResolutionListener implements ResolutionListener, ResolutionListenerForDepMgmt
 {
     // fields -----------------------------------------------------------------
-    
+
     /**
      * The log to write debug messages to.
      */
@@ -69,7 +71,7 @@
      * The dependency node currently being processed by this listener.
      */
     private DependencyNode currentNode;
-    
+
     /**
      * Map &lt; String replacementId, String premanaged version >
      */
@@ -80,6 +82,7 @@
      */
     private Map managedScopes = new HashMap();
 
+
     // constructors -----------------------------------------------------------
 
     /**
@@ -91,13 +94,14 @@
     public DependencyTreeResolutionListener( Logger logger )
     {
         this.logger = logger;
-        
+
         parentNodes = new Stack();
         nodesByArtifact = new IdentityHashMap();
         rootNode = null;
         currentNode = null;
     }
 
+
     // ResolutionListener methods ---------------------------------------------
 
     /**
@@ -108,31 +112,33 @@
         log( "testArtifact: artifact=" + artifact );
     }
 
+
     /**
      * {@inheritDoc}
      */
     public void startProcessChildren( Artifact artifact )
     {
         log( "startProcessChildren: artifact=" + artifact );
-        
+
         if ( !currentNode.getArtifact().equals( artifact ) )
         {
             throw new IllegalStateException( "Artifact was expected to be " + currentNode.getArtifact() + " but was "
-                            + artifact );
+                + artifact );
         }
 
         parentNodes.push( currentNode );
     }
 
+
     /**
      * {@inheritDoc}
      */
     public void endProcessChildren( Artifact artifact )
     {
-        DependencyNode node = (DependencyNode) parentNodes.pop();
+        DependencyNode node = ( DependencyNode ) parentNodes.pop();
 
         log( "endProcessChildren: artifact=" + artifact );
-        
+
         if ( node == null )
         {
             throw new IllegalStateException( "Parent dependency node was null" );
@@ -141,17 +147,18 @@
         if ( !node.getArtifact().equals( artifact ) )
         {
             throw new IllegalStateException( "Parent dependency node artifact was expected to be " + node.getArtifact()
-                            + " but was " + artifact );
+                + " but was " + artifact );
         }
     }
 
+
     /**
      * {@inheritDoc}
      */
     public void includeArtifact( Artifact artifact )
     {
         log( "includeArtifact: artifact=" + artifact );
-        
+
         DependencyNode existingNode = getNode( artifact );
 
         /*
@@ -170,18 +177,19 @@
         }
     }
 
+
     /**
      * {@inheritDoc}
      */
     public void omitForNearer( Artifact omitted, Artifact kept )
     {
         log( "omitForNearer: omitted=" + omitted + " kept=" + kept );
-        
+
         if ( !omitted.getDependencyConflictId().equals( kept.getDependencyConflictId() ) )
         {
             throw new IllegalArgumentException( "Omitted artifact dependency conflict id "
-                            + omitted.getDependencyConflictId() + " differs from kept artifact dependency conflict id "
-                            + kept.getDependencyConflictId() );
+                + omitted.getDependencyConflictId() + " differs from kept artifact dependency conflict id "
+                + kept.getDependencyConflictId() );
         }
 
         if ( isCurrentNodeIncluded() )
@@ -200,15 +208,15 @@
             }
 
             omittedNode.omitForConflict( kept );
-            
+
             /*
              * Add the dependency management information cached in any prior manageArtifact calls, since omitForNearer
              * is always called after manageArtifact.
              */
             flushDependencyManagement( omittedNode );
-            
+
             DependencyNode keptNode = getNode( kept );
-            
+
             if ( keptNode == null )
             {
                 addNode( kept );
@@ -216,13 +224,14 @@
         }
     }
 
+
     /**
      * {@inheritDoc}
      */
     public void updateScope( Artifact artifact, String scope )
     {
         log( "updateScope: artifact=" + artifact + ", scope=" + scope );
-        
+
         DependencyNode node = getNode( artifact );
 
         if ( node == null )
@@ -234,33 +243,35 @@
         node.setOriginalScope( artifact.getScope() );
     }
 
+
     /**
      * {@inheritDoc}
      */
     public void manageArtifact( Artifact artifact, Artifact replacement )
     {
         // TODO: remove when ResolutionListenerForDepMgmt merged into ResolutionListener
-        
+
         log( "manageArtifact: artifact=" + artifact + ", replacement=" + replacement );
-        
+
         if ( replacement.getVersion() != null )
         {
             manageArtifactVersion( artifact, replacement );
         }
-        
+
         if ( replacement.getScope() != null )
         {
             manageArtifactScope( artifact, replacement );
         }
     }
 
+
     /**
      * {@inheritDoc}
      */
     public void omitForCycle( Artifact artifact )
     {
         log( "omitForCycle: artifact=" + artifact );
-        
+
         if ( isCurrentNodeIncluded() )
         {
             DependencyNode node = createNode( artifact );
@@ -269,13 +280,14 @@
         }
     }
 
+
     /**
      * {@inheritDoc}
      */
     public void updateScopeCurrentPom( Artifact artifact, String scopeIgnored )
     {
         log( "updateScopeCurrentPom: artifact=" + artifact + ", scopeIgnored=" + scopeIgnored );
-        
+
         DependencyNode node = getNode( artifact );
 
         if ( node == null )
@@ -288,6 +300,7 @@
         node.setFailedUpdateScope( scopeIgnored );
     }
 
+
     /**
      * {@inheritDoc}
      */
@@ -309,25 +322,27 @@
         node.setAvailableVersions( artifact.getAvailableVersions() );
     }
 
+
     /**
      * {@inheritDoc}
      */
     public void restrictRange( Artifact artifact, Artifact replacement, VersionRange versionRange )
     {
         log( "restrictRange: artifact=" + artifact + ", replacement=" + replacement + ", versionRange=" + versionRange );
-        
+
         // TODO: track range restriction in node (MNG-3093)
     }
-    
+
+
     // ResolutionListenerForDepMgmt methods -----------------------------------
-    
+
     /**
      * {@inheritDoc}
      */
     public void manageArtifactVersion( Artifact artifact, Artifact replacement )
     {
         log( "manageArtifactVersion: artifact=" + artifact + ", replacement=" + replacement );
-        
+
         /*
          * DefaultArtifactCollector calls manageArtifact twice: first with the change; then subsequently with no change.
          * We ignore the second call when the versions are equal.
@@ -342,13 +357,14 @@
         }
     }
 
+
     /**
      * {@inheritDoc}
      */
     public void manageArtifactScope( Artifact artifact, Artifact replacement )
     {
         log( "manageArtifactScope: artifact=" + artifact + ", replacement=" + replacement );
-        
+
         /*
          * DefaultArtifactCollector calls manageArtifact twice: first with the change; then subsequently with no change.
          * We ignore the second call when the scopes are equal.
@@ -362,7 +378,8 @@
             managedScopes.put( getRangeId( replacement ), artifact.getScope() );
         }
     }
-    
+
+
     // public methods ---------------------------------------------------------
 
     /**
@@ -376,6 +393,7 @@
         return Collections.unmodifiableCollection( nodesByArtifact.values() );
     }
 
+
     /**
      * Gets the root dependency node of the computed dependency tree.
      * 
@@ -386,8 +404,9 @@
         return rootNode;
     }
 
+
     // private methods --------------------------------------------------------
-    
+
     /**
      * Writes the specified message to the log at debug level with indentation for the current node's depth.
      * 
@@ -410,6 +429,7 @@
         logger.debug( buffer.toString() );
     }
 
+
     /**
      * Creates a new dependency node for the specified artifact and appends it to the current parent dependency node.
      * 
@@ -423,14 +443,15 @@
 
         if ( !parentNodes.isEmpty() )
         {
-            DependencyNode parent = (DependencyNode) parentNodes.peek();
+            DependencyNode parent = ( DependencyNode ) parentNodes.peek();
 
             parent.addChild( node );
         }
 
         return node;
     }
-    
+
+
     /**
      * Creates a new dependency node for the specified artifact, appends it to the current parent dependency node and
      * puts it into the dependency node cache.
@@ -444,23 +465,24 @@
     {
         DependencyNode node = createNode( artifact );
 
-        DependencyNode previousNode = (DependencyNode) nodesByArtifact.put( node.getArtifact(), node );
-        
+        DependencyNode previousNode = ( DependencyNode ) nodesByArtifact.put( node.getArtifact(), node );
+
         if ( previousNode != null )
         {
             throw new IllegalStateException( "Duplicate node registered for artifact: " + node.getArtifact() );
         }
-        
+
         if ( rootNode == null )
         {
             rootNode = node;
         }
 
         currentNode = node;
-        
+
         return node;
     }
 
+
     /**
      * Gets the dependency node for the specified artifact from the dependency node cache.
      * 
@@ -471,9 +493,10 @@
      */
     private DependencyNode getNode( Artifact artifact )
     {
-        return (DependencyNode) nodesByArtifact.get( artifact );
+        return ( DependencyNode ) nodesByArtifact.get( artifact );
     }
 
+
     /**
      * Removes the dependency node for the specified artifact from the dependency node cache.
      * 
@@ -482,15 +505,16 @@
      */
     private void removeNode( Artifact artifact )
     {
-        DependencyNode node = (DependencyNode) nodesByArtifact.remove( artifact );
+        DependencyNode node = ( DependencyNode ) nodesByArtifact.remove( artifact );
 
         if ( !artifact.equals( node.getArtifact() ) )
         {
             throw new IllegalStateException( "Removed dependency node artifact was expected to be " + artifact
-                            + " but was " + node.getArtifact() );
+                + " but was " + node.getArtifact() );
         }
     }
 
+
     /**
      * Gets whether the all the ancestors of the dependency node currently being processed by this listener have an
      * included state.
@@ -504,7 +528,7 @@
 
         for ( Iterator iterator = parentNodes.iterator(); included && iterator.hasNext(); )
         {
-            DependencyNode node = (DependencyNode) iterator.next();
+            DependencyNode node = ( DependencyNode ) iterator.next();
 
             if ( node.getState() != DependencyNode.INCLUDED )
             {
@@ -515,6 +539,7 @@
         return included;
     }
 
+
     /**
      * Updates the specified node with any dependency management information cached in prior <code>manageArtifact</code>
      * calls.
@@ -525,26 +550,27 @@
     private void flushDependencyManagement( DependencyNode node )
     {
         Artifact artifact = node.getArtifact();
-        String premanagedVersion = (String) managedVersions.get( getRangeId( artifact ) );
-        String premanagedScope = (String) managedScopes.get( getRangeId( artifact ) );
-        
+        String premanagedVersion = ( String ) managedVersions.get( getRangeId( artifact ) );
+        String premanagedScope = ( String ) managedScopes.get( getRangeId( artifact ) );
+
         if ( premanagedVersion != null || premanagedScope != null )
         {
             if ( premanagedVersion != null )
             {
                 node.setPremanagedVersion( premanagedVersion );
             }
-            
+
             if ( premanagedScope != null )
             {
                 node.setPremanagedScope( premanagedScope );
             }
-            
+
             premanagedVersion = null;
             premanagedScope = null;
         }
     }
 
+
     private static String getRangeId( Artifact artifact )
     {
         return artifact.getDependencyConflictId() + ":" + artifact.getVersionRange();
diff --git a/bundleplugin/src/main/java/org/apache/maven/shared/osgi/DefaultMaven2OsgiConverter.java b/bundleplugin/src/main/java/org/apache/maven/shared/osgi/DefaultMaven2OsgiConverter.java
index db45c43..a622d78 100644
--- a/bundleplugin/src/main/java/org/apache/maven/shared/osgi/DefaultMaven2OsgiConverter.java
+++ b/bundleplugin/src/main/java/org/apache/maven/shared/osgi/DefaultMaven2OsgiConverter.java
@@ -18,6 +18,7 @@
  */
 package org.apache.maven.shared.osgi;
 
+
 import java.io.File;
 import java.io.IOException;
 import java.util.Enumeration;
@@ -34,6 +35,7 @@
 
 import aQute.lib.osgi.Analyzer;
 
+
 /**
  * Default implementation of {@link Maven2OsgiConverter}
  * 
@@ -42,17 +44,18 @@
  * @author <a href="mailto:carlos@apache.org">Carlos Sanchez</a>
  * @version $Id: DefaultMaven2OsgiConverter.java 661727 2008-05-30 14:21:49Z bentmann $
  */
-public class DefaultMaven2OsgiConverter
-    implements Maven2OsgiConverter
+public class DefaultMaven2OsgiConverter implements Maven2OsgiConverter
 {
 
     private static final String FILE_SEPARATOR = System.getProperty( "file.separator" );
 
+
     private String getBundleSymbolicName( String groupId, String artifactId )
     {
         return groupId + "." + artifactId;
     }
 
+
     /**
      * Get the symbolic name as groupId + "." + artifactId, with the following exceptions
      * <ul>
@@ -87,7 +90,7 @@
                     Iterator it = bundleSymbolicNameHeader.keySet().iterator();
                     if ( it.hasNext() )
                     {
-                        return (String) it.next();
+                        return ( String ) it.next();
                     }
                 }
             }
@@ -140,6 +143,7 @@
         return getBundleSymbolicName( artifact.getGroupId(), artifact.getArtifactId() );
     }
 
+
     private String getGroupIdFromPackage( File artifactFile )
     {
         try
@@ -150,7 +154,7 @@
             Enumeration entries = jar.entries();
             while ( entries.hasMoreElements() )
             {
-                ZipEntry entry = (ZipEntry) entries.nextElement();
+                ZipEntry entry = ( ZipEntry ) entries.nextElement();
                 if ( entry.getName().endsWith( ".class" ) )
                 {
                     File f = new File( entry.getName() );
@@ -167,7 +171,7 @@
             String[] groupIdSections = null;
             for ( Iterator it = packageNames.iterator(); it.hasNext(); )
             {
-                String packageName = (String) it.next();
+                String packageName = ( String ) it.next();
 
                 String[] packageNameSections = packageName.split( "\\" + FILE_SEPARATOR );
                 if ( groupIdSections == null )
@@ -223,19 +227,22 @@
         }
     }
 
+
     public String getBundleFileName( Artifact artifact )
     {
         return getBundleSymbolicName( artifact ) + "_" + getVersion( artifact.getVersion() ) + ".jar";
     }
 
+
     public String getVersion( Artifact artifact )
     {
         return getVersion( artifact.getVersion() );
     }
 
+
     public String getVersion( String version )
     {
-        return cleanupVersion(version);
+        return cleanupVersion( version );
     }
 
     /**
@@ -246,58 +253,78 @@
      * @param VERSION_STRING
      * @return
      */
-    static final Pattern FUZZY_VERSION = Pattern.compile("(\\d+)(\\.(\\d+)(\\.(\\d+))?)?([^a-zA-Z0-9](.*))?",
-                                                         Pattern.DOTALL);
+    static final Pattern FUZZY_VERSION = Pattern.compile( "(\\d+)(\\.(\\d+)(\\.(\\d+))?)?([^a-zA-Z0-9](.*))?",
+        Pattern.DOTALL );
 
-    static public String cleanupVersion(String version) {
+
+    static public String cleanupVersion( String version )
+    {
         StringBuffer result = new StringBuffer();
-        Matcher m = FUZZY_VERSION.matcher(version);
-        if (m.matches()) {
-            String major = m.group(1);
-            String minor = m.group(3);
-            String micro = m.group(5);
-            String qualifier = m.group(7);
+        Matcher m = FUZZY_VERSION.matcher( version );
+        if ( m.matches() )
+        {
+            String major = m.group( 1 );
+            String minor = m.group( 3 );
+            String micro = m.group( 5 );
+            String qualifier = m.group( 7 );
 
-            if (major != null) {
-                result.append(major);
-                if (minor != null) {
-                    result.append(".");
-                    result.append(minor);
-                    if (micro != null) {
-                        result.append(".");
-                        result.append(micro);
-                        if (qualifier != null) {
-                            result.append(".");
-                            cleanupModifier(result, qualifier);
+            if ( major != null )
+            {
+                result.append( major );
+                if ( minor != null )
+                {
+                    result.append( "." );
+                    result.append( minor );
+                    if ( micro != null )
+                    {
+                        result.append( "." );
+                        result.append( micro );
+                        if ( qualifier != null )
+                        {
+                            result.append( "." );
+                            cleanupModifier( result, qualifier );
                         }
-                    } else if (qualifier != null) {
-                        result.append(".0.");
-                        cleanupModifier(result, qualifier);
-                    } else {
-                        result.append(".0");
                     }
-                } else if (qualifier != null) {
-                    result.append(".0.0.");
-                    cleanupModifier(result, qualifier);
-                } else {
-                    result.append(".0.0");
+                    else if ( qualifier != null )
+                    {
+                        result.append( ".0." );
+                        cleanupModifier( result, qualifier );
+                    }
+                    else
+                    {
+                        result.append( ".0" );
+                    }
+                }
+                else if ( qualifier != null )
+                {
+                    result.append( ".0.0." );
+                    cleanupModifier( result, qualifier );
+                }
+                else
+                {
+                    result.append( ".0.0" );
                 }
             }
-        } else {
-            result.append("0.0.0.");
-            cleanupModifier(result, version);
+        }
+        else
+        {
+            result.append( "0.0.0." );
+            cleanupModifier( result, version );
         }
         return result.toString();
     }
 
-    static void cleanupModifier(StringBuffer result, String modifier) {
-        for (int i = 0; i < modifier.length(); i++) {
-            char c = modifier.charAt(i);
-            if ((c >= '0' && c <= '9') || (c >= 'a' && c <= 'z')
-                    || (c >= 'A' && c <= 'Z') || c == '_' || c == '-')
-                result.append(c);
+
+    static void cleanupModifier( StringBuffer result, String modifier )
+    {
+        for ( int i = 0; i < modifier.length(); i++ )
+        {
+            char c = modifier.charAt( i );
+            if ( ( c >= '0' && c <= '9' ) || ( c >= 'a' && c <= 'z' ) || ( c >= 'A' && c <= 'Z' ) || c == '_'
+                || c == '-' )
+                result.append( c );
             else
-                result.append('_');
+                result.append( '_' );
         }
     }
 
diff --git a/bundleplugin/src/main/java/org/apache/maven/shared/osgi/ManifestReadingException.java b/bundleplugin/src/main/java/org/apache/maven/shared/osgi/ManifestReadingException.java
index 38483d8..433cc80 100644
--- a/bundleplugin/src/main/java/org/apache/maven/shared/osgi/ManifestReadingException.java
+++ b/bundleplugin/src/main/java/org/apache/maven/shared/osgi/ManifestReadingException.java
@@ -18,14 +18,14 @@
  */
 package org.apache.maven.shared.osgi;
 
+
 /**
  * Exception while reading the manifest. Encapsulates an IOException to make it runtime
  * 
  * @author <a href="mailto:carlos@apache.org">Carlos Sanchez</a>
  * @version $Id: ManifestReadingException.java 661727 2008-05-30 14:21:49Z bentmann $
  */
-public class ManifestReadingException
-    extends RuntimeException
+public class ManifestReadingException extends RuntimeException
 {
 
     public ManifestReadingException()
@@ -33,16 +33,19 @@
         super();
     }
 
+
     public ManifestReadingException( String message, Throwable cause )
     {
         super( message, cause );
     }
 
+
     public ManifestReadingException( String message )
     {
         super( message );
     }
 
+
     public ManifestReadingException( Throwable cause )
     {
         super( cause );
diff --git a/bundleplugin/src/main/java/org/apache/maven/shared/osgi/Maven2OsgiConverter.java b/bundleplugin/src/main/java/org/apache/maven/shared/osgi/Maven2OsgiConverter.java
index eec6cc5..a843920 100644
--- a/bundleplugin/src/main/java/org/apache/maven/shared/osgi/Maven2OsgiConverter.java
+++ b/bundleplugin/src/main/java/org/apache/maven/shared/osgi/Maven2OsgiConverter.java
@@ -18,8 +18,10 @@
  */
 package org.apache.maven.shared.osgi;
 
+
 import org.apache.maven.artifact.Artifact;
 
+
 /**
  * Converter from Maven groupId,artifactId and versions to OSGi Bundle-SymbolicName and version
  * 
@@ -37,8 +39,10 @@
      */
     String getBundleSymbolicName( Artifact artifact );
 
+
     String getBundleFileName( Artifact artifact );
 
+
     /**
      * Convert a Maven version into an OSGi compliant version
      * 
@@ -47,6 +51,7 @@
      */
     String getVersion( Artifact artifact );
 
+
     /**
      * Convert a Maven version into an OSGi compliant version
      * 
diff --git a/bundleplugin/src/test/java/org/apache/felix/bundleplugin/BlueprintComponentTest.java b/bundleplugin/src/test/java/org/apache/felix/bundleplugin/BlueprintComponentTest.java
index 17d2d44..b62083e 100644
--- a/bundleplugin/src/test/java/org/apache/felix/bundleplugin/BlueprintComponentTest.java
+++ b/bundleplugin/src/test/java/org/apache/felix/bundleplugin/BlueprintComponentTest.java
@@ -18,6 +18,7 @@
  */
 package org.apache.felix.bundleplugin;
 
+
 import java.io.File;
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -27,70 +28,81 @@
 import java.util.Properties;
 import java.util.jar.Manifest;
 
-import aQute.lib.osgi.Builder;
 import junit.framework.TestCase;
-import org.apache.felix.bundleplugin.ManifestPlugin;
+
 import org.apache.maven.model.Resource;
 import org.apache.maven.plugin.testing.stubs.MavenProjectStub;
 import org.osgi.framework.Constants;
 
-public class BlueprintComponentTest extends TestCase {
+import aQute.lib.osgi.Builder;
+
+
+public class BlueprintComponentTest extends TestCase
+{
 
     public void testBlueprint() throws Exception
     {
-        MavenProjectStub project = new MavenProjectStub() {
+        MavenProjectStub project = new MavenProjectStub()
+        {
             private final List resources = new ArrayList();
-            @Override
-            public void addResource(Resource resource) {
-                resources.add(resource);
-            }
+
 
             @Override
-            public List getResources() {
+            public void addResource( Resource resource )
+            {
+                resources.add( resource );
+            }
+
+
+            @Override
+            public List getResources()
+            {
                 return resources;
             }
 
+
             @Override
             public File getBasedir()
             {
-                return new File("target/tmp/basedir");
+                return new File( "target/tmp/basedir" );
             }
         };
         project.setGroupId( "group" );
         project.setArtifactId( "artifact" );
         project.setVersion( "1.1.0.0" );
         Resource r = new Resource();
-        r.setDirectory(new File("src/test/resources").getAbsoluteFile().getCanonicalPath());
-        r.setIncludes(Arrays.asList("**/*.*"));
-        project.addResource(r);
-        project.addCompileSourceRoot(new File("src/test/resources").getAbsoluteFile().getCanonicalPath());
+        r.setDirectory( new File( "src/test/resources" ).getAbsoluteFile().getCanonicalPath() );
+        r.setIncludes( Arrays.asList( "**/*.*" ) );
+        project.addResource( r );
+        project.addCompileSourceRoot( new File( "src/test/resources" ).getAbsoluteFile().getCanonicalPath() );
 
         ManifestPlugin plugin = new ManifestPlugin();
-        plugin.setBuildDirectory("target/tmp/basedir/target");
-        plugin.setOutputDirectory(new File("target/tmp/basedir/target/classes"));
+        plugin.setBuildDirectory( "target/tmp/basedir/target" );
+        plugin.setOutputDirectory( new File( "target/tmp/basedir/target/classes" ) );
 
         Map instructions = new HashMap();
-        instructions.put("Test", "Foo");
+        instructions.put( "Test", "Foo" );
 
-        instructions.put("nsh_interface", "foo.bar.Namespace");
-        instructions.put("nsh_namespace", "ns");
+        instructions.put( "nsh_interface", "foo.bar.Namespace" );
+        instructions.put( "nsh_namespace", "ns" );
 
-        instructions.put("Export-Service", "p7.Foo;mk=mv");
-        instructions.put("Import-Service", "org.osgi.service.cm.ConfigurationAdmin;availability:=optional");
+        instructions.put( "Export-Service", "p7.Foo;mk=mv" );
+        instructions.put( "Import-Service", "org.osgi.service.cm.ConfigurationAdmin;availability:=optional" );
 
         Properties props = new Properties();
-        Builder builder = plugin.buildOSGiBundle(project, instructions, props, plugin.getClasspath(project));
+        Builder builder = plugin.buildOSGiBundle( project, instructions, props, plugin.getClasspath( project ) );
 
         Manifest manifest = builder.getJar().getManifest();
-        String expSvc = manifest.getMainAttributes().getValue(Constants.EXPORT_SERVICE);
-        String impSvc = manifest.getMainAttributes().getValue(Constants.IMPORT_SERVICE);
-        assertNotNull(expSvc);
-        assertNotNull(impSvc);
+        String expSvc = manifest.getMainAttributes().getValue( Constants.EXPORT_SERVICE );
+        String impSvc = manifest.getMainAttributes().getValue( Constants.IMPORT_SERVICE );
+        assertNotNull( expSvc );
+        assertNotNull( impSvc );
 
-        String impPkg = manifest.getMainAttributes().getValue(Constants.IMPORT_PACKAGE);
-        List<String> pkgs = Arrays.asList(impPkg.split(","));
-        for (int i = 1; i <= 13; i++) {
-            assertTrue(pkgs.contains("p" + i));
+        String impPkg = manifest.getMainAttributes().getValue( Constants.IMPORT_PACKAGE );
+        List<String> pkgs = Arrays.asList( impPkg.split( "," ) );
+        for ( int i = 1; i <= 13; i++ )
+        {
+            assertTrue( pkgs.contains( "p" + i ) );
         }
     }
 
diff --git a/bundleplugin/src/test/java/org/apache/felix/bundleplugin/BundleAllPluginTest.java b/bundleplugin/src/test/java/org/apache/felix/bundleplugin/BundleAllPluginTest.java
index 253725c..d26483d 100644
--- a/bundleplugin/src/test/java/org/apache/felix/bundleplugin/BundleAllPluginTest.java
+++ b/bundleplugin/src/test/java/org/apache/felix/bundleplugin/BundleAllPluginTest.java
@@ -114,8 +114,8 @@
                 exports.containsKey( packages[i] ) );
         }
 
-        assertFalse( "Bundle info contains a package that it is not exported in the manifest", exports
-            .containsKey( "org.apache.maven.model.io.xpp3" ) );
+        assertFalse( "Bundle info contains a package that it is not exported in the manifest",
+            exports.containsKey( "org.apache.maven.model.io.xpp3" ) );
     }
 
     //    public void testRewriting()
diff --git a/bundleplugin/src/test/java/org/apache/felix/bundleplugin/BundlePluginTest.java b/bundleplugin/src/test/java/org/apache/felix/bundleplugin/BundlePluginTest.java
index bcafd68..773ab1c 100644
--- a/bundleplugin/src/test/java/org/apache/felix/bundleplugin/BundlePluginTest.java
+++ b/bundleplugin/src/test/java/org/apache/felix/bundleplugin/BundlePluginTest.java
@@ -22,13 +22,13 @@
 
 import java.io.File;
 import java.util.Map;
-import java.util.TreeMap;
 import java.util.Properties;
+import java.util.TreeMap;
 
+import org.apache.maven.model.Organization;
 import org.apache.maven.plugin.testing.stubs.MavenProjectStub;
 import org.apache.maven.project.MavenProject;
 import org.apache.maven.shared.osgi.DefaultMaven2OsgiConverter;
-import org.apache.maven.model.Organization;
 
 import aQute.lib.osgi.Analyzer;
 import aQute.lib.osgi.Builder;
@@ -112,7 +112,7 @@
         project.setArtifactId( "artifact" );
         project.setVersion( "1.1.0.0" );
 
-//        PackageVersionAnalyzer analyzer = new PackageVersionAnalyzer();
+        //        PackageVersionAnalyzer analyzer = new PackageVersionAnalyzer();
         Builder analyzer = new Builder();
         Jar jar = new Jar( "name", osgiBundleFile );
         analyzer.setJar( jar );
@@ -165,6 +165,7 @@
         assertEquals( "", transformedInstructions.get( "-z" ) );
     }
 
+
     public void testDefaultPropertiesIncludeOrganization()
     {
         final Organization organization = new Organization();
@@ -174,7 +175,8 @@
         // MavenProjectStub.setOrganization(Organization) doesn't do anything, so we have to make it work this way
         MavenProject project = new MavenProjectStub()
         {
-            @Override public Organization getOrganization()
+            @Override
+            public Organization getOrganization()
             {
                 return organization;
             }
@@ -190,12 +192,14 @@
         assertEquals( organization.getUrl(), properties.getProperty( "pom.organization.url" ) );
     }
 
+
     public void testVersion() throws Exception
     {
         String cleanupVersion = Builder.cleanupVersion( "0.0.0.4aug2000r7-dev" );
         assertEquals( "0.0.0.4aug2000r7-dev", cleanupVersion );
     }
-    
+
+
     public void testPackageInfoDetection() throws Exception
     {
         MavenProject project = new MavenProjectStub();
@@ -203,7 +207,7 @@
 
         String resourcePaths = plugin.getMavenResourcePaths( project );
 
-        assertEquals( "org/apache/felix/bundleplugin/packageinfo=" +
-                      "src/test/java/org/apache/felix/bundleplugin/packageinfo", resourcePaths );
+        assertEquals( "org/apache/felix/bundleplugin/packageinfo="
+            + "src/test/java/org/apache/felix/bundleplugin/packageinfo", resourcePaths );
     }
 }
