felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r1750295 - in /felix/sandbox/cziegeler: bnd-maven-plugin/src/main/java/org/apache/felix/bundleplugin/ scrplugin/
Date Mon, 27 Jun 2016 07:55:51 GMT
Author: cziegeler
Date: Mon Jun 27 07:55:51 2016
New Revision: 1750295

URL: http://svn.apache.org/viewvc?rev=1750295&view=rev
Log:
Remove obsolete scrplugin code

Removed:
    felix/sandbox/cziegeler/scrplugin/
Modified:
    felix/sandbox/cziegeler/bnd-maven-plugin/src/main/java/org/apache/felix/bundleplugin/AbstractDependencyFilter.java
    felix/sandbox/cziegeler/bnd-maven-plugin/src/main/java/org/apache/felix/bundleplugin/DependencyEmbedder.java
    felix/sandbox/cziegeler/bnd-maven-plugin/src/main/java/org/apache/felix/bundleplugin/DependencyExcluder.java
    felix/sandbox/cziegeler/bnd-maven-plugin/src/main/java/org/apache/felix/bundleplugin/ManifestWriter.java

Modified: felix/sandbox/cziegeler/bnd-maven-plugin/src/main/java/org/apache/felix/bundleplugin/AbstractDependencyFilter.java
URL: http://svn.apache.org/viewvc/felix/sandbox/cziegeler/bnd-maven-plugin/src/main/java/org/apache/felix/bundleplugin/AbstractDependencyFilter.java?rev=1750295&r1=1750294&r2=1750295&view=diff
==============================================================================
--- felix/sandbox/cziegeler/bnd-maven-plugin/src/main/java/org/apache/felix/bundleplugin/AbstractDependencyFilter.java
(original)
+++ felix/sandbox/cziegeler/bnd-maven-plugin/src/main/java/org/apache/felix/bundleplugin/AbstractDependencyFilter.java
Mon Jun 27 07:55:51 2016
@@ -28,13 +28,14 @@ import java.util.regex.Pattern;
 import org.apache.maven.artifact.Artifact;
 import org.apache.maven.plugin.MojoExecutionException;
 
-import aQute.bnd.osgi.Instruction;
+import aQute.bnd.header.Attrs;
 import aQute.bnd.header.OSGiHeader;
+import aQute.bnd.osgi.Instruction;
 
 
 /**
  * Apply clause-based filter over given dependencies
- * 
+ *
  * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
  */
 public abstract class AbstractDependencyFilter
@@ -44,10 +45,10 @@ public abstract class AbstractDependency
     /**
      * Dependency artifacts.
      */
-    private final Collection m_dependencyArtifacts;
+    private final Collection<Artifact> m_dependencyArtifacts;
 
 
-    public AbstractDependencyFilter( Collection dependencyArtifacts )
+    public AbstractDependencyFilter( Collection<Artifact> dependencyArtifacts )
     {
         m_dependencyArtifacts = dependencyArtifacts;
     }
@@ -71,11 +72,11 @@ public abstract class AbstractDependency
         }
 
 
-        public void filter( Collection dependencies )
+        public void filter( Collection<Artifact> dependencies )
         {
-            for ( Iterator i = dependencies.iterator(); i.hasNext(); )
+            for ( Iterator<Artifact> i = dependencies.iterator(); i.hasNext(); )
             {
-                if ( false == matches( ( Artifact ) i.next() ) )
+                if ( false == matches( i.next() ) )
                 {
                     i.remove();
                 }
@@ -106,21 +107,21 @@ public abstract class AbstractDependency
 
     protected final void processInstructions( String header ) throws MojoExecutionException
     {
-        Map instructions = OSGiHeader.parseHeader( MISSING_KEY_PATTERN.matcher( header ).replaceAll(
"$1$2*;$3" ) );
+        Map<String,Attrs> instructions = OSGiHeader.parseHeader( MISSING_KEY_PATTERN.matcher(
header ).replaceAll( "$1$2*;$3" ) );
 
-        Collection availableDependencies = new LinkedHashSet( m_dependencyArtifacts );
+        Collection<Artifact> availableDependencies = new LinkedHashSet<Artifact>(
m_dependencyArtifacts );
 
         DependencyFilter filter;
-        for ( Iterator clauseIterator = instructions.entrySet().iterator(); clauseIterator.hasNext();
)
+        for ( Iterator<Map.Entry<String,Attrs>> clauseIterator = instructions.entrySet().iterator();
clauseIterator.hasNext(); )
         {
             String inline = "false";
 
             // always start with a fresh *modifiable* collection for each unique clause
-            Collection filteredDependencies = new LinkedHashSet( availableDependencies );
+            Collection<Artifact> filteredDependencies = new LinkedHashSet<Artifact>(
availableDependencies );
 
             // CLAUSE: REGEXP --> { ATTRIBUTE MAP }
-            Map.Entry clause = ( Map.Entry ) clauseIterator.next();
-            String primaryKey = ( ( String ) clause.getKey() ).replaceFirst( "~+$", "" );
+            Map.Entry<String,Attrs> clause = clauseIterator.next();
+            String primaryKey = clause.getKey().replaceFirst( "~+$", "" );
             boolean isNegative = primaryKey.startsWith( "!" );
             if ( isNegative )
             {
@@ -131,6 +132,7 @@ public abstract class AbstractDependency
             {
                 filter = new DependencyFilter( primaryKey )
                 {
+                    @Override
                     boolean matches( Artifact dependency )
                     {
                         return super.matches( dependency.getArtifactId() );
@@ -140,14 +142,15 @@ public abstract class AbstractDependency
                 filter.filter( filteredDependencies );
             }
 
-            for ( Iterator attrIterator = ( ( Map ) clause.getValue() ).entrySet().iterator();
attrIterator.hasNext(); )
+            for ( Iterator<Map.Entry<String,String>> attrIterator = clause.getValue().entrySet().iterator();
attrIterator.hasNext(); )
             {
                 // ATTRIBUTE: KEY --> REGEXP
-                Map.Entry attr = ( Map.Entry ) attrIterator.next();
+                Map.Entry<String,String> attr = attrIterator.next();
                 if ( "groupId".equals( attr.getKey() ) )
                 {
-                    filter = new DependencyFilter( ( String ) attr.getValue() )
+                    filter = new DependencyFilter( attr.getValue() )
                     {
+                        @Override
                         boolean matches( Artifact dependency )
                         {
                             return super.matches( dependency.getGroupId() );
@@ -156,8 +159,9 @@ public abstract class AbstractDependency
                 }
                 else if ( "artifactId".equals( attr.getKey() ) )
                 {
-                    filter = new DependencyFilter( ( String ) attr.getValue() )
+                    filter = new DependencyFilter( attr.getValue() )
                     {
+                        @Override
                         boolean matches( Artifact dependency )
                         {
                             return super.matches( dependency.getArtifactId() );
@@ -166,8 +170,9 @@ public abstract class AbstractDependency
                 }
                 else if ( "version".equals( attr.getKey() ) )
                 {
-                    filter = new DependencyFilter( ( String ) attr.getValue() )
+                    filter = new DependencyFilter( attr.getValue() )
                     {
+                        @Override
                         boolean matches( Artifact dependency )
                         {
                             try
@@ -184,8 +189,9 @@ public abstract class AbstractDependency
                 }
                 else if ( "scope".equals( attr.getKey() ) )
                 {
-                    filter = new DependencyFilter( ( String ) attr.getValue(), "compile"
)
+                    filter = new DependencyFilter( attr.getValue(), "compile" )
                     {
+                        @Override
                         boolean matches( Artifact dependency )
                         {
                             return super.matches( dependency.getScope() );
@@ -194,8 +200,9 @@ public abstract class AbstractDependency
                 }
                 else if ( "type".equals( attr.getKey() ) )
                 {
-                    filter = new DependencyFilter( ( String ) attr.getValue(), "jar" )
+                    filter = new DependencyFilter( attr.getValue(), "jar" )
                     {
+                        @Override
                         boolean matches( Artifact dependency )
                         {
                             return super.matches( dependency.getType() );
@@ -204,8 +211,9 @@ public abstract class AbstractDependency
                 }
                 else if ( "classifier".equals( attr.getKey() ) )
                 {
-                    filter = new DependencyFilter( ( String ) attr.getValue() )
+                    filter = new DependencyFilter( attr.getValue() )
                     {
+                        @Override
                         boolean matches( Artifact dependency )
                         {
                             return super.matches( dependency.getClassifier() );
@@ -214,8 +222,9 @@ public abstract class AbstractDependency
                 }
                 else if ( "optional".equals( attr.getKey() ) )
                 {
-                    filter = new DependencyFilter( ( String ) attr.getValue(), "false" )
+                    filter = new DependencyFilter( attr.getValue(), "false" )
                     {
+                        @Override
                         boolean matches( Artifact dependency )
                         {
                             return super.matches( "" + dependency.isOptional() );
@@ -224,7 +233,7 @@ public abstract class AbstractDependency
                 }
                 else if ( "inline".equals( attr.getKey() ) )
                 {
-                    inline = ( String ) attr.getValue();
+                    inline = attr.getValue();
                     continue;
                 }
                 else
@@ -255,5 +264,5 @@ public abstract class AbstractDependency
     }
 
 
-    protected abstract void processDependencies( Collection dependencies, String inline );
+    protected abstract void processDependencies( Collection<Artifact> dependencies,
String inline );
 }

Modified: felix/sandbox/cziegeler/bnd-maven-plugin/src/main/java/org/apache/felix/bundleplugin/DependencyEmbedder.java
URL: http://svn.apache.org/viewvc/felix/sandbox/cziegeler/bnd-maven-plugin/src/main/java/org/apache/felix/bundleplugin/DependencyEmbedder.java?rev=1750295&r1=1750294&r2=1750295&view=diff
==============================================================================
--- felix/sandbox/cziegeler/bnd-maven-plugin/src/main/java/org/apache/felix/bundleplugin/DependencyEmbedder.java
(original)
+++ felix/sandbox/cziegeler/bnd-maven-plugin/src/main/java/org/apache/felix/bundleplugin/DependencyEmbedder.java
Mon Jun 27 07:55:51 2016
@@ -54,29 +54,22 @@ public final class DependencyEmbedder ex
     private String m_embedStripVersion;
 
     /**
-     * Maven logger.
-     */
-    private final Log m_log;
-
-    /**
      * Inlined paths.
      */
-    private final Collection m_inlinedPaths;
+    private final Collection<String> m_inlinedPaths;
 
     /**
      * Embedded artifacts.
      */
-    private final Collection m_embeddedArtifacts;
+    private final Collection<Artifact> m_embeddedArtifacts;
 
 
-    public DependencyEmbedder( Log log, Collection dependencyArtifacts )
+    public DependencyEmbedder( Log log, Collection<Artifact> dependencyArtifacts )
     {
         super( dependencyArtifacts );
 
-        m_log = log;
-
-        m_inlinedPaths = new LinkedHashSet();
-        m_embeddedArtifacts = new LinkedHashSet();
+        m_inlinedPaths = new LinkedHashSet<String>();
+        m_embeddedArtifacts = new LinkedHashSet<Artifact>();
     }
 
 
@@ -98,13 +91,13 @@ public final class DependencyEmbedder ex
 
             processInstructions( embedDependencyHeader );
 
-            for ( Iterator i = m_inlinedPaths.iterator(); i.hasNext(); )
+            for ( Iterator<String> i = m_inlinedPaths.iterator(); i.hasNext(); )
             {
-                inlineDependency( ( String ) i.next(), includeResource );
+                inlineDependency( i.next(), includeResource );
             }
-            for ( Iterator i = m_embeddedArtifacts.iterator(); i.hasNext(); )
+            for ( Iterator<Artifact> i = m_embeddedArtifacts.iterator(); i.hasNext();
)
             {
-                embedDependency( ( Artifact ) i.next(), includeResource, bundleClassPath,
embeddedArtifacts );
+                embedDependency( i.next(), includeResource, bundleClassPath, embeddedArtifacts
);
             }
         }
 
@@ -124,7 +117,7 @@ public final class DependencyEmbedder ex
 
 
     @Override
-    protected void processDependencies( Collection dependencies, String inline )
+    protected void processDependencies( Collection<Artifact> dependencies, String inline
)
     {
         if ( null == inline || "false".equalsIgnoreCase( inline ) )
         {
@@ -132,15 +125,15 @@ public final class DependencyEmbedder ex
         }
         else
         {
-            for ( Iterator i = dependencies.iterator(); i.hasNext(); )
+            for ( Iterator<Artifact> i = dependencies.iterator(); i.hasNext(); )
             {
-                addInlinedPaths( ( Artifact ) i.next(), inline, m_inlinedPaths );
+                addInlinedPaths( i.next(), inline, m_inlinedPaths );
             }
         }
     }
 
 
-    private static void addInlinedPaths( Artifact dependency, String inline, Collection inlinedPaths
)
+    private static void addInlinedPaths( Artifact dependency, String inline, Collection<String>
inlinedPaths )
     {
         File path = dependency.getFile();
         if ( null != path && path.exists() )
@@ -252,13 +245,13 @@ public final class DependencyEmbedder ex
     }
 
 
-    public Collection getInlinedPaths()
+    public Collection<String> getInlinedPaths()
     {
         return m_inlinedPaths;
     }
 
 
-    public Collection getEmbeddedArtifacts()
+    public Collection<Artifact> getEmbeddedArtifacts()
     {
         return m_embeddedArtifacts;
     }

Modified: felix/sandbox/cziegeler/bnd-maven-plugin/src/main/java/org/apache/felix/bundleplugin/DependencyExcluder.java
URL: http://svn.apache.org/viewvc/felix/sandbox/cziegeler/bnd-maven-plugin/src/main/java/org/apache/felix/bundleplugin/DependencyExcluder.java?rev=1750295&r1=1750294&r2=1750295&view=diff
==============================================================================
--- felix/sandbox/cziegeler/bnd-maven-plugin/src/main/java/org/apache/felix/bundleplugin/DependencyExcluder.java
(original)
+++ felix/sandbox/cziegeler/bnd-maven-plugin/src/main/java/org/apache/felix/bundleplugin/DependencyExcluder.java
Mon Jun 27 07:55:51 2016
@@ -22,12 +22,13 @@ package org.apache.felix.bundleplugin;
 import java.util.Collection;
 import java.util.HashSet;
 
+import org.apache.maven.artifact.Artifact;
 import org.apache.maven.plugin.MojoExecutionException;
 
 
 /**
  * Exclude selected dependencies from the classpath passed to BND.
- * 
+ *
  * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
  */
 public final class DependencyExcluder extends AbstractDependencyFilter
@@ -35,14 +36,14 @@ public final class DependencyExcluder ex
     /**
      * Excluded artifacts.
      */
-    private final Collection m_excludedArtifacts;
+    private final Collection<Artifact> m_excludedArtifacts;
 
 
-    public DependencyExcluder( Collection dependencyArtifacts )
+    public DependencyExcluder( Collection<Artifact> dependencyArtifacts )
     {
         super( dependencyArtifacts );
 
-        m_excludedArtifacts = new HashSet();
+        m_excludedArtifacts = new HashSet<Artifact>();
     }
 
 
@@ -58,13 +59,13 @@ public final class DependencyExcluder ex
 
 
     @Override
-    protected void processDependencies( Collection dependencies, String inline )
+    protected void processDependencies( Collection<Artifact> dependencies, String inline
)
     {
         m_excludedArtifacts.addAll( dependencies );
     }
 
 
-    public Collection getExcludedArtifacts()
+    public Collection<Artifact> getExcludedArtifacts()
     {
         return m_excludedArtifacts;
     }

Modified: felix/sandbox/cziegeler/bnd-maven-plugin/src/main/java/org/apache/felix/bundleplugin/ManifestWriter.java
URL: http://svn.apache.org/viewvc/felix/sandbox/cziegeler/bnd-maven-plugin/src/main/java/org/apache/felix/bundleplugin/ManifestWriter.java?rev=1750295&r1=1750294&r2=1750295&view=diff
==============================================================================
--- felix/sandbox/cziegeler/bnd-maven-plugin/src/main/java/org/apache/felix/bundleplugin/ManifestWriter.java
(original)
+++ felix/sandbox/cziegeler/bnd-maven-plugin/src/main/java/org/apache/felix/bundleplugin/ManifestWriter.java
Mon Jun 27 07:55:51 2016
@@ -196,55 +196,4 @@ public class ManifestWriter {
             writeEntry(out, entry.getKey(), entry.getValue(), nice);
         }
     }
-
-    private static Manifest clean(Manifest org) {
-
-        Manifest result = new Manifest();
-        for (Map.Entry< ? , ? > entry : org.getMainAttributes().entrySet()) {
-            String nice = clean((String) entry.getValue());
-            result.getMainAttributes().put(entry.getKey(), nice);
-        }
-        for (String name : org.getEntries().keySet()) {
-            Attributes attrs = result.getAttributes(name);
-            if (attrs == null) {
-                attrs = new Attributes();
-                result.getEntries().put(name, attrs);
-            }
-
-            for (Map.Entry< ? , ? > entry : org.getAttributes(name).entrySet()) {
-                String nice = clean((String) entry.getValue());
-                attrs.put(entry.getKey(), nice);
-            }
-        }
-        return result;
-    }
-
-    private static String clean(String s) {
-        StringBuilder sb = new StringBuilder(s);
-        boolean changed = false;
-        boolean replacedPrev = false;
-        for ( int i=0; i<sb.length(); i++) {
-            char c = s.charAt(i);
-            switch(c) {
-            case 0:
-            case '\n':
-            case '\r':
-                changed = true;
-                if ( !replacedPrev ) {
-                    sb.replace(i, i+1, " ");
-                    replacedPrev= true;
-                } else
-                    sb.delete(i, i+1);
-                break;
-            default:
-                replacedPrev = false;
-                break;
-            }
-        }
-        if ( changed)
-            return sb.toString();
-        else
-            return s;
-    }
-
 }



Mime
View raw message