You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by fg...@apache.org on 2006/10/24 18:06:53 UTC

svn commit: r467370 - in /maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/ide: AbstractIdeSupportMojo.java IdeDependency.java

Author: fgiust
Date: Tue Oct 24 09:06:53 2006
New Revision: 467370

URL: http://svn.apache.org/viewvc?view=rev&rev=467370
Log:
keep the dependency depth and the osgi bundle name, they could be useful for the Required-Bundles manifest entry.

Modified:
    maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/ide/AbstractIdeSupportMojo.java
    maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/ide/IdeDependency.java

Modified: maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/ide/AbstractIdeSupportMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/ide/AbstractIdeSupportMojo.java?view=diff&rev=467370&r1=467369&r2=467370
==============================================================================
--- maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/ide/AbstractIdeSupportMojo.java (original)
+++ maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/ide/AbstractIdeSupportMojo.java Tue Oct 24 09:06:53 2006
@@ -16,6 +16,22 @@
  * limitations under the License.
  */
 
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.TreeSet;
+import java.util.jar.Attributes;
+import java.util.jar.JarFile;
+import java.util.jar.Manifest;
+import java.util.zip.ZipFile;
+
 import org.apache.maven.artifact.Artifact;
 import org.apache.maven.artifact.factory.ArtifactFactory;
 import org.apache.maven.artifact.metadata.ArtifactMetadataSource;
@@ -42,22 +58,6 @@
 import org.codehaus.plexus.logging.LogEnabled;
 import org.codehaus.plexus.logging.Logger;
 
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.TreeSet;
-import java.util.jar.Attributes;
-import java.util.jar.JarFile;
-import java.util.jar.Manifest;
-import java.util.zip.ZipFile;
-
 /**
  * Abstract base plugin which takes care of the common stuff usually needed by maven IDE plugins. A
  * plugin extending AbstractIdeSupportMojo should implement the <code>setup()</code> and
@@ -450,7 +450,9 @@
 
             for ( Iterator i = artifactResolutionResult.getArtifactResolutionNodes().iterator(); i.hasNext(); )
             {
+
                 ResolutionNode node = (ResolutionNode) i.next();
+                int dependencyDepth = node.getDepth();
                 Artifact art = node.getArtifact();
                 boolean isReactorProject = getUseProjectReferences() && isAvailableAsAReactorProject( art );
 
@@ -497,6 +499,7 @@
                     // we need to check the manifest, if "Bundle-SymbolicName" is there the artifact can be considered
                     // an osgi bundle
                     boolean isOsgiBundle = false;
+                    String osgiSymbolicName = null;
                     if ( art.getFile() != null )
                     {
                         JarFile jarFile = null;
@@ -507,8 +510,8 @@
                             Manifest manifest = jarFile.getManifest();
                             if ( manifest != null )
                             {
-                                isOsgiBundle = manifest.getMainAttributes()
-                                    .getValue( new Attributes.Name( "Bundle-SymbolicName" ) ) != null;
+                                osgiSymbolicName = manifest.getMainAttributes()
+                                    .getValue( new Attributes.Name( "Bundle-SymbolicName" ) );
                             }
                         }
                         catch ( IOException e )
@@ -531,13 +534,15 @@
                         }
                     }
 
+                    isOsgiBundle = osgiSymbolicName != null;
+
                     IdeDependency dep = new IdeDependency( art.getGroupId(), art.getArtifactId(), art.getVersion(),
                                                            isReactorProject, Artifact.SCOPE_TEST
                                                                .equals( art.getScope() ), Artifact.SCOPE_SYSTEM
                                                                .equals( art.getScope() ), Artifact.SCOPE_PROVIDED
                                                                .equals( art.getScope() ), art.getArtifactHandler()
                                                                .isAddedToClasspath(), art.getFile(), art.getType(),
-                                                           isOsgiBundle );
+                                                           isOsgiBundle, osgiSymbolicName, dependencyDepth );
 
                     dependencyList.add( dep );
                 }

Modified: maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/ide/IdeDependency.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/ide/IdeDependency.java?view=diff&rev=467370&r1=467369&r2=467370
==============================================================================
--- maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/ide/IdeDependency.java (original)
+++ maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/ide/IdeDependency.java Tue Oct 24 09:06:53 2006
@@ -91,6 +91,16 @@
     private boolean osgiBundle;
 
     /**
+     * If this jar is an osgi bundle, this is its Bundle-SymbolicName?
+     */
+    private String osgiSymbolicName;
+
+    /**
+     * Depth of this dependency in the transitive dependency trail.
+     */
+    private int dependencyDepth;
+
+    /**
      * 
      * @param groupId Group id
      * @param artifactId Artifact id
@@ -102,10 +112,13 @@
      * @param addedToClasspath Is this dependency added to classpath?
      * @param file Resolved artifact file
      * @param type Artifact type
+     * @param osgiBundle Does this artifact contains a OSGI Manifest?
+     * @param osgiSymbolicName Bundle-SymbolicName from the Manifest (if available)
+     * @param dependencyDepth Depth of this dependency in the transitive dependency trail.
      */
     public IdeDependency( String groupId, String artifactId, String version, boolean referencedProject,
                           boolean testDependency, boolean systemScoped, boolean provided, boolean addedToClasspath,
-                          File file, String type, boolean osgiBundle )
+                          File file, String type, boolean osgiBundle, String osgiSymbolicName, int dependencyDepth )
     {
         // group:artifact:version
         this.groupId = groupId;
@@ -118,7 +131,11 @@
         this.systemScoped = systemScoped;
         this.provided = provided;
         this.addedToClasspath = addedToClasspath;
+
+        // needed for OSGI support
         this.osgiBundle = osgiBundle;
+        this.osgiSymbolicName = osgiSymbolicName;
+        this.dependencyDepth = dependencyDepth;
 
         // file and type
         this.file = file;