felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r688446 - /felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/JavaClassDescriptorManager.java
Date Sun, 24 Aug 2008 04:29:28 GMT
Author: cziegeler
Date: Sat Aug 23 21:29:28 2008
New Revision: 688446

URL: http://svn.apache.org/viewvc?rev=688446&view=rev
Log:
FELIX-696: Check artifact type when searching for scr configuration files.

Modified:
    felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/JavaClassDescriptorManager.java

Modified: felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/JavaClassDescriptorManager.java
URL: http://svn.apache.org/viewvc/felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/JavaClassDescriptorManager.java?rev=688446&r1=688445&r2=688446&view=diff
==============================================================================
--- felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/JavaClassDescriptorManager.java
(original)
+++ felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/JavaClassDescriptorManager.java
Sat Aug 23 21:29:28 2008
@@ -139,54 +139,58 @@
         while ( it.hasNext() ) {
             final Artifact declared = (Artifact) it.next();
             this.log.debug("Checking artifact " + declared);
-            if (Artifact.SCOPE_COMPILE.equals(declared.getScope())
-                || Artifact.SCOPE_RUNTIME.equals(declared.getScope())
-                || Artifact.SCOPE_PROVIDED.equals(declared.getScope())) {
-                this.log.debug("Resolving artifact " + declared);
-                final Artifact artifact = (Artifact) resolved.get(ArtifactUtils.versionlessKey(declared));
-                if (artifact != null) {
-                    this.log.debug("Trying to get manifest from artifact " + artifact);
-                    try {
-                        final Manifest manifest = this.getManifest(artifact);
-                        if ( manifest != null ) {
-                            // read Service-Component entry
-                            if ( manifest.getMainAttributes().getValue(JavaClassDescriptorManager.SERVICE_COMPONENT)
!= null ) {
-                                final String serviceComponent = manifest.getMainAttributes().getValue(JavaClassDescriptorManager.SERVICE_COMPONENT);
-                                this.log.debug("Found Service-Component: " + serviceComponent
+ " in artifact " + artifact);
-                                final StringTokenizer st = new StringTokenizer(serviceComponent,
",");
-                                while ( st.hasMoreTokens() ) {
-                                    final String entry = st.nextToken().trim();
-                                    if ( entry.length() > 0 ) {
-                                        components.addAll(this.readServiceComponentDescriptor(artifact,
entry).getComponents());
+            if ( this.isJavaArtifact(declared)) {
+                if (Artifact.SCOPE_COMPILE.equals(declared.getScope())
+                    || Artifact.SCOPE_RUNTIME.equals(declared.getScope())
+                    || Artifact.SCOPE_PROVIDED.equals(declared.getScope())) {
+                    this.log.debug("Resolving artifact " + declared);
+                    final Artifact artifact = (Artifact) resolved.get(ArtifactUtils.versionlessKey(declared));
+                    if (artifact != null) {
+                        this.log.debug("Trying to get manifest from artifact " + artifact);
+                        try {
+                            final Manifest manifest = this.getManifest(artifact);
+                            if ( manifest != null ) {
+                                // read Service-Component entry
+                                if ( manifest.getMainAttributes().getValue(JavaClassDescriptorManager.SERVICE_COMPONENT)
!= null ) {
+                                    final String serviceComponent = manifest.getMainAttributes().getValue(JavaClassDescriptorManager.SERVICE_COMPONENT);
+                                    this.log.debug("Found Service-Component: " + serviceComponent
+ " in artifact " + artifact);
+                                    final StringTokenizer st = new StringTokenizer(serviceComponent,
",");
+                                    while ( st.hasMoreTokens() ) {
+                                        final String entry = st.nextToken().trim();
+                                        if ( entry.length() > 0 ) {
+                                            components.addAll(this.readServiceComponentDescriptor(artifact,
entry).getComponents());
+                                        }
                                     }
+                                } else {
+                                    this.log.debug("Artifact has no service component entry
in manifest " + artifact);
                                 }
                             } else {
-                                this.log.debug("Artifact has no service component entry in
manifest " + artifact);
+                                this.log.debug("Unable to get manifest from artifact " +
artifact);
                             }
-                        } else {
-                            this.log.debug("Unable to get manifest from artifact " + artifact);
+                        } catch (IOException ioe) {
+                            throw new MojoExecutionException("Unable to get manifest from
artifact " + artifact, ioe);
                         }
-                    } catch (IOException ioe) {
-                        throw new MojoExecutionException("Unable to get manifest from artifact
" + artifact, ioe);
-                    }
-                    this.log.debug("Trying to get scrinfo from artifact " + artifact);
-                    // now read the scr private file - components stored there overwrite
components already
-                    // read from the service component section.
-                    try {
-                        final File scrInfoFile = this.getFile(artifact, Constants.ABSTRACT_DESCRIPTOR_ARCHIV_PATH);
-                        if ( scrInfoFile != null ) {
-                            components.addAll(this.parseServiceComponentDescriptor(artifact,
scrInfoFile).getComponents());
-                        } else {
-                            this.log.debug("Artifact has no scrinfo file (it's optional):
" + artifact);
+                        this.log.debug("Trying to get scrinfo from artifact " + artifact);
+                        // now read the scr private file - components stored there overwrite
components already
+                        // read from the service component section.
+                        try {
+                            final File scrInfoFile = this.getFile(artifact, Constants.ABSTRACT_DESCRIPTOR_ARCHIV_PATH);
+                            if ( scrInfoFile != null ) {
+                                components.addAll(this.parseServiceComponentDescriptor(artifact,
scrInfoFile).getComponents());
+                            } else {
+                                this.log.debug("Artifact has no scrinfo file (it's optional):
" + artifact);
+                            }
+                        } catch (IOException ioe) {
+                            throw new MojoExecutionException("Unable to get scrinfo from
artifact " + artifact, ioe);
                         }
-                    } catch (IOException ioe) {
-                        throw new MojoExecutionException("Unable to get scrinfo from artifact
" + artifact, ioe);
+                    } else {
+                        this.log.debug("Unable to resolve artifact " + declared);
                     }
                 } else {
-                    this.log.debug("Unable to resolve artifact " + declared);
+                    this.log.debug("Artifact " + declared + " has not scope compile or runtime,
but " + declared.getScope());
                 }
             } else {
-                this.log.debug("Artifact " + declared + " has not scope compile or runtime,
but " + declared.getScope());
+                this.log.debug("Artifact " + declared + " is not a java artifact, type is
" + declared.getType());
             }
         }
         // now create map with component descriptions
@@ -198,6 +202,19 @@
     }
 
     /**
+     * Check if the artifact is a java artifact (jar or bundle)
+     */
+    private boolean isJavaArtifact(Artifact artifact) {
+        if ( "jar".equals(artifact.getType()) ) {
+            return true;
+        }
+        if ( "bundle".equals(artifact.getType()) ) {
+            return true;
+        }
+        return false;
+    }
+
+    /**
      * Return the log.
      */
     public Log getLog() {



Mime
View raw message