You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by ol...@apache.org on 2011/08/14 10:44:26 UTC

svn commit: r1157497 - in /maven/indexer/trunk/indexer-core/src: main/java/org/apache/maven/index/ main/java/org/apache/maven/index/creator/ test/java/org/apache/maven/index/creator/ test/repo-with-osgi/org/apache/felix/ test/repo-with-osgi/org/apache/...

Author: olamy
Date: Sun Aug 14 08:44:26 2011
New Revision: 1157497

URL: http://svn.apache.org/viewvc?rev=1157497&view=rev
Log:
[MINDEXER-36] : Add some OSGI metadata in the index to be able to search on

index  Export-Service

Added:
    maven/indexer/trunk/indexer-core/src/test/repo-with-osgi/org/apache/felix/
    maven/indexer/trunk/indexer-core/src/test/repo-with-osgi/org/apache/felix/org.apache.felix.bundlerepository/
    maven/indexer/trunk/indexer-core/src/test/repo-with-osgi/org/apache/felix/org.apache.felix.bundlerepository/1.6.6/
    maven/indexer/trunk/indexer-core/src/test/repo-with-osgi/org/apache/felix/org.apache.felix.bundlerepository/1.6.6/org.apache.felix.bundlerepository-1.6.6.jar
    maven/indexer/trunk/indexer-core/src/test/repo-with-osgi/org/apache/felix/org.apache.felix.bundlerepository/1.6.6/org.apache.felix.bundlerepository-1.6.6.pom   (with props)
Modified:
    maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/ArtifactInfo.java
    maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/OSGI.java
    maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/creator/OSGIArtifactIndexCreator.java
    maven/indexer/trunk/indexer-core/src/test/java/org/apache/maven/index/creator/OSGIArtifactIndexCreatorTest.java

Modified: maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/ArtifactInfo.java
URL: http://svn.apache.org/viewvc/maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/ArtifactInfo.java?rev=1157497&r1=1157496&r2=1157497&view=diff
==============================================================================
--- maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/ArtifactInfo.java (original)
+++ maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/ArtifactInfo.java Sun Aug 14 08:44:26 2011
@@ -238,6 +238,12 @@ public class ArtifactInfo
      */
     public String bundleExportPackage;
 
+    /**
+     * contains osgi metadata Export-Service if available
+     * @since 4.1.2
+     */
+    public String bundleExportService;
+
 
     private String uinfo = null;
 

Modified: maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/OSGI.java
URL: http://svn.apache.org/viewvc/maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/OSGI.java?rev=1157497&r1=1157496&r2=1157497&view=diff
==============================================================================
--- maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/OSGI.java (original)
+++ maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/OSGI.java Sun Aug 14 08:44:26 2011
@@ -38,4 +38,6 @@ public interface OSGI
 
     Field EXPORT_PACKAGE = new Field( null, OSGI_NAMESPACE, "exportPackage", "Bundle Export-Package" );
 
+    Field EXPORT_SERVICE = new Field( null, OSGI_NAMESPACE, "exportService", "Bundle Export-Service" );
+
 }

Modified: maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/creator/OSGIArtifactIndexCreator.java
URL: http://svn.apache.org/viewvc/maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/creator/OSGIArtifactIndexCreator.java?rev=1157497&r1=1157496&r2=1157497&view=diff
==============================================================================
--- maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/creator/OSGIArtifactIndexCreator.java (original)
+++ maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/creator/OSGIArtifactIndexCreator.java Sun Aug 14 08:44:26 2011
@@ -67,12 +67,19 @@ public class OSGIArtifactIndexCreator
     private static final String BEP = "Export-Package";
 
     public static final IndexerField FLD_BUNDLE_EXPORT_PACKAGE =
-        new IndexerField( OSGI.EXPORT_PACKAGE, IndexerFieldVersion.V4, "bv", "Export-Package (indexed, stored)",
+        new IndexerField( OSGI.EXPORT_PACKAGE, IndexerFieldVersion.V4, "bep", "Export-Package (indexed, stored)",
+                          Field.Store.YES, Field.Index.ANALYZED );
+
+    private static final String BES = "Export-Service";
+
+    public static final IndexerField FLD_BUNDLE_EXPORT_SERVIVE =
+        new IndexerField( OSGI.EXPORT_SERVICE, IndexerFieldVersion.V4, "bes", "Export-Service (indexed, stored)",
                           Field.Store.YES, Field.Index.ANALYZED );
 
     public Collection<IndexerField> getIndexerFields()
     {
-        return Arrays.asList( FLD_BUNDLE_SYMBOLIC_NAME, FLD_BUNDLE_VERSION, FLD_BUNDLE_EXPORT_PACKAGE );
+        return Arrays.asList( FLD_BUNDLE_SYMBOLIC_NAME, FLD_BUNDLE_VERSION, FLD_BUNDLE_EXPORT_PACKAGE,
+                              FLD_BUNDLE_EXPORT_SERVIVE );
     }
 
     public void populateArtifactInfo( ArtifactContext artifactContext )
@@ -108,6 +115,11 @@ public class OSGIArtifactIndexCreator
             document.add( FLD_BUNDLE_EXPORT_PACKAGE.toField( artifactInfo.bundleExportPackage ) );
         }
 
+        if ( artifactInfo.bundleExportService != null )
+        {
+            document.add( FLD_BUNDLE_EXPORT_SERVIVE.toField( artifactInfo.bundleExportService ) );
+        }
+
     }
 
     public boolean updateArtifactInfo( Document document, ArtifactInfo artifactInfo )
@@ -142,6 +154,16 @@ public class OSGIArtifactIndexCreator
 
         }
 
+        String bundleExportService = document.get( FLD_BUNDLE_EXPORT_SERVIVE.getKey() );
+
+        if ( bundleExportService != null )
+        {
+            artifactInfo.bundleExportService = bundleExportService;
+
+            updated = true;
+
+        }
+
         return updated;
     }
 
@@ -201,6 +223,17 @@ public class OSGIArtifactIndexCreator
                             ai.bundleExportPackage = null;
                         }
 
+                        attValue = mainAttributes.getValue( BES );
+                        if ( StringUtils.isNotBlank( attValue ) )
+                        {
+                            ai.bundleExportService = attValue;
+                            updated = true;
+                        }
+                        else
+                        {
+                            ai.bundleExportService = null;
+                        }
+
                     }
                 }
             }

Modified: maven/indexer/trunk/indexer-core/src/test/java/org/apache/maven/index/creator/OSGIArtifactIndexCreatorTest.java
URL: http://svn.apache.org/viewvc/maven/indexer/trunk/indexer-core/src/test/java/org/apache/maven/index/creator/OSGIArtifactIndexCreatorTest.java?rev=1157497&r1=1157496&r2=1157497&view=diff
==============================================================================
--- maven/indexer/trunk/indexer-core/src/test/java/org/apache/maven/index/creator/OSGIArtifactIndexCreatorTest.java (original)
+++ maven/indexer/trunk/indexer-core/src/test/java/org/apache/maven/index/creator/OSGIArtifactIndexCreatorTest.java Sun Aug 14 08:44:26 2011
@@ -212,4 +212,44 @@ public class OSGIArtifactIndexCreatorTes
 
     }
 
+    public void testIndexOSGIRepoThenSearchWithExportService()
+        throws Exception
+    {
+
+        indexOSGIRepo();
+
+        try
+        {
+
+            BooleanQuery q = new BooleanQuery();
+
+            q.add( nexusIndexer.constructQuery( OSGI.EXPORT_SERVICE, new StringSearchExpression(
+                "org.apache.felix.bundlerepository.RepositoryAdmin" ) ), BooleanClause.Occur.MUST );
+
+            FlatSearchRequest request = new FlatSearchRequest( q );
+            FlatSearchResponse response = nexusIndexer.searchFlat( request );
+
+            //System.out.println("results with export package query " + response.getResults() );
+            assertEquals( 1, response.getResults().size() );
+
+            ArtifactInfo ai = response.getResults().iterator().next();
+            System.out.println("ai " + ai );
+
+            assertEquals( "org.apache.felix", ai.groupId );
+            assertEquals( "org.apache.felix.bundlerepository", ai.artifactId );
+            assertEquals( "1.6.6", ai.version );
+            assertEquals( "bundle", ai.packaging );
+            assertEquals( "org.apache.felix.bundlerepository", ai.bundleSymbolicName );
+            assertEquals( "1.6.6", ai.bundleVersion );
+
+        }
+        finally
+        {
+            nexusIndexer.getIndexingContexts().get( INDEX_ID ).close( true );
+        }
+
+    }
+
+    // Export-Service: org.apache.felix.bundlerepository.RepositoryAdmin,org.osgi.service.obr.RepositoryAdmin
+
 }

Added: maven/indexer/trunk/indexer-core/src/test/repo-with-osgi/org/apache/felix/org.apache.felix.bundlerepository/1.6.6/org.apache.felix.bundlerepository-1.6.6.jar
URL: http://svn.apache.org/viewvc/maven/indexer/trunk/indexer-core/src/test/repo-with-osgi/org/apache/felix/org.apache.felix.bundlerepository/1.6.6/org.apache.felix.bundlerepository-1.6.6.jar?rev=1157497&view=auto
==============================================================================
Files maven/indexer/trunk/indexer-core/src/test/repo-with-osgi/org/apache/felix/org.apache.felix.bundlerepository/1.6.6/org.apache.felix.bundlerepository-1.6.6.jar (added) and maven/indexer/trunk/indexer-core/src/test/repo-with-osgi/org/apache/felix/org.apache.felix.bundlerepository/1.6.6/org.apache.felix.bundlerepository-1.6.6.jar Sun Aug 14 08:44:26 2011 differ

Added: maven/indexer/trunk/indexer-core/src/test/repo-with-osgi/org/apache/felix/org.apache.felix.bundlerepository/1.6.6/org.apache.felix.bundlerepository-1.6.6.pom
URL: http://svn.apache.org/viewvc/maven/indexer/trunk/indexer-core/src/test/repo-with-osgi/org/apache/felix/org.apache.felix.bundlerepository/1.6.6/org.apache.felix.bundlerepository-1.6.6.pom?rev=1157497&view=auto
==============================================================================
--- maven/indexer/trunk/indexer-core/src/test/repo-with-osgi/org/apache/felix/org.apache.felix.bundlerepository/1.6.6/org.apache.felix.bundlerepository-1.6.6.pom (added)
+++ maven/indexer/trunk/indexer-core/src/test/repo-with-osgi/org/apache/felix/org.apache.felix.bundlerepository/1.6.6/org.apache.felix.bundlerepository-1.6.6.pom Sun Aug 14 08:44:26 2011
@@ -0,0 +1,138 @@
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements.  See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership.  The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied.  See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  <parent>
+    <groupId>org.apache.felix</groupId>
+    <artifactId>felix-parent</artifactId>
+    <version>2.1</version>
+    <relativePath>../pom/pom.xml</relativePath>
+  </parent>
+  <modelVersion>4.0.0</modelVersion>
+  <packaging>bundle</packaging>
+  <name>Apache Felix Bundle Repository</name>
+  <description>Bundle repository service.</description>
+  <artifactId>org.apache.felix.bundlerepository</artifactId>
+  <version>1.6.6</version>
+  <scm>
+    <connection>scm:svn:http://svn.apache.org/repos/asf/felix/releases/org.apache.felix.bundlerepository-1.6.6</connection>
+    <developerConnection>scm:svn:https://svn.apache.org/repos/asf/felix/releases/org.apache.felix.bundlerepository-1.6.6</developerConnection>
+    <url>http://svn.apache.org/repos/asf/felix/releases/org.apache.felix.bundlerepository-1.6.6</url>
+  </scm>
+  <dependencies>
+    <dependency>
+      <groupId>${project.groupId}</groupId>
+      <artifactId>org.apache.felix.utils</artifactId>
+      <version>1.1.0</version>
+      <optional>true</optional>
+    </dependency>
+    <dependency>
+      <groupId>${project.groupId}</groupId>
+      <artifactId>org.osgi.service.obr</artifactId>
+      <version>1.0.2</version>
+      <optional>true</optional>
+    </dependency>
+    <dependency>
+      <groupId>${project.groupId}</groupId>
+      <artifactId>org.apache.felix.shell</artifactId>
+      <version>1.4.1</version>
+      <optional>true</optional>
+    </dependency>
+    <dependency>
+      <groupId>net.sf.kxml</groupId>
+      <artifactId>kxml2</artifactId>
+      <version>2.3.0</version>
+      <optional>true</optional>
+      <exclusions>
+        <exclusion>
+          <groupId>xmlpull</groupId>
+          <artifactId>xmlpull</artifactId>
+        </exclusion>
+      </exclusions>
+    </dependency>
+    <dependency>
+        <groupId>org.osgi</groupId>
+        <artifactId>org.osgi.compendium</artifactId>
+        <version>4.0.0</version>
+        <optional>true</optional>
+    </dependency>
+    <dependency>
+       <groupId>org.osgi</groupId>
+        <artifactId>org.osgi.core</artifactId>
+        <version>4.1.0</version>
+    </dependency>
+    <dependency>
+        <groupId>org.codehaus.woodstox</groupId>
+        <artifactId>woodstox-core-asl</artifactId>
+        <version>4.0.7</version>
+        <optional>true</optional>
+    </dependency>
+    <dependency>
+        <groupId>org.easymock</groupId>
+        <artifactId>easymock</artifactId>
+        <version>2.4</version>
+    </dependency>
+  </dependencies>
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.felix</groupId>
+        <artifactId>maven-bundle-plugin</artifactId>
+        <version>2.3.4</version>
+        <extensions>true</extensions>
+        <configuration>
+          <instructions>
+            <Export-Package>org.apache.felix.bundlerepository;version="2.0"</Export-Package>
+            <Private-Package>
+                org.kxml2.io,
+                org.xmlpull.v1,
+                org.apache.felix.bundlerepository.impl.*,
+                org.apache.felix.utils.*
+            </Private-Package>
+            <Import-Package>!javax.xml.parsers,!org.xml.sax,org.osgi.service.log;resolution:=optional,org.osgi.service.obr;resolution:=optional,javax.xml.stream;resolution:=optional,*</Import-Package>
+            <DynamicImport-Package>org.apache.felix.shell</DynamicImport-Package>
+            <Bundle-Activator>${project.artifactId}.impl.Activator</Bundle-Activator>
+            <Bundle-DocURL>http://felix.apache.org/site/apache-felix-osgi-bundle-repository.html</Bundle-DocURL>
+            <Bundle-Url>http://felix.apache.org/site/downloads.cgi</Bundle-Url>
+            <Bundle-Source>http://felix.apache.org/site/downloads.cgi</Bundle-Source>
+            <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
+            <Bundle-Vendor>The Apache Software Foundation</Bundle-Vendor>
+            <Export-Service>org.apache.felix.bundlerepository.RepositoryAdmin,org.osgi.service.obr.RepositoryAdmin</Export-Service>
+            <_versionpolicy>[$(version;==;$(@)),$(version;+;$(@)))</_versionpolicy>
+            <Include-Resource>META-INF/LICENSE=LICENSE,META-INF/LICENSE.kxml2=LICENSE.kxml2,META-INF/NOTICE=NOTICE,META-INF/DEPENDENCIES=DEPENDENCIES</Include-Resource>
+          </instructions>
+        </configuration>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.rat</groupId>
+        <artifactId>apache-rat-plugin</artifactId>
+        <configuration>
+          <excludeSubProjects>false</excludeSubProjects>
+          <useEclipseDefaultExcludes>true</useEclipseDefaultExcludes>
+          <useMavenDefaultExcludes>true</useMavenDefaultExcludes>
+          <excludes>
+            <param>doc/*</param>
+            <param>maven-eclipse.xml</param>
+            <param>.checkstyle</param>
+            <param>.externalToolBuilders/*</param>
+          </excludes>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+</project>

Propchange: maven/indexer/trunk/indexer-core/src/test/repo-with-osgi/org/apache/felix/org.apache.felix.bundlerepository/1.6.6/org.apache.felix.bundlerepository-1.6.6.pom
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/indexer/trunk/indexer-core/src/test/repo-with-osgi/org/apache/felix/org.apache.felix.bundlerepository/1.6.6/org.apache.felix.bundlerepository-1.6.6.pom
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision