This is an automated email from the ASF dual-hosted git repository.

rec pushed a commit to branch 
feature/100-Enable-type-system-discovery-via-SPI-in-OSGI
in repository https://gitbox.apache.org/repos/asf/uima-ruta.git

commit 416082116a99bea438bd8bd108329206f39bd64c
Author: Richard Eckart de Castilho <[email protected]>
AuthorDate: Thu Sep 15 12:11:35 2022 +0200

    Issue #100 - Enable type system discovery via SPI in OSGI
    
    - Move the SPIs to the ruta-core module
    - Turn the typesystem and basic type modules from OSGI bundles back to 
regular JARs - because we need to export their packages at the bundle level 
(https://issues.apache.org/jira/browse/ARIES-2082) and that means the bundle 
already embeds them...
---
 .../marker-file-identifying-osgi-bundle            |  0
 ruta-basic-type/pom.xml                            | 33 +----------
 .../services/org.apache.uima.spi.JCasClassProvider |  1 -
 ruta-core/pom.xml                                  |  9 +++
 .../uima/ruta/type/spi/RutaBasicTypeProvider.java  | 35 +++++++++++
 .../spi/RutaTypeSystemDescriptionProvider.java     | 68 ++++++++++++++++++++++
 .../services/org.apache.uima.spi.JCasClassProvider |  2 +
 ...g.apache.uima.spi.TypeSystemDescriptionProvider |  1 +
 ruta-maven-plugin/pom.xml                          |  7 +++
 .../marker-file-identifying-osgi-bundle            |  0
 ruta-typesystem/pom.xml                            | 37 +-----------
 .../services/org.apache.uima.spi.JCasClassProvider |  1 -
 12 files changed, 124 insertions(+), 70 deletions(-)

diff --git a/ruta-basic-type/marker-file-identifying-osgi-bundle 
b/ruta-basic-type/marker-file-identifying-osgi-bundle
deleted file mode 100644
index e69de29b..00000000
diff --git a/ruta-basic-type/pom.xml b/ruta-basic-type/pom.xml
index e9105031..e055e57b 100644
--- a/ruta-basic-type/pom.xml
+++ b/ruta-basic-type/pom.xml
@@ -30,7 +30,7 @@
   </parent>
 
   <artifactId>ruta-basic-type</artifactId>
-  <packaging>bundle</packaging>
+  <packaging>jar</packaging>
 
   <name>Apache UIMA Ruta: ${project.artifactId}</name>
   <description>The RutaBasic type provided by ruta-core.</description>
@@ -88,37 +88,6 @@
       </plugins>
     </pluginManagement>
 
-    <plugins>
-      <plugin>
-        <groupId>org.apache.felix</groupId>
-        <artifactId>maven-bundle-plugin</artifactId>
-        <extensions>true</extensions>
-        <configuration>
-          <instructions>
-            <Fragment-Host>org.apache.uima.ruta-core</Fragment-Host>
-            <Export-Package>
-              org.apache.uima.ruta.type
-            </Export-Package>
-          </instructions>
-        </configuration>
-      </plugin>
-
-      <plugin>
-        <groupId>org.apache.rat</groupId>
-        <artifactId>apache-rat-plugin</artifactId>
-        <executions>
-          <execution>
-            <id>default-cli</id>
-            <configuration>
-              <excludes combine.children="append">
-                
<exclude>src/main/resources/META-INF/services/org.apache.uima.spi.JCasClassProvider</exclude>
-              </excludes>
-            </configuration>
-          </execution>
-        </executions>
-      </plugin>
-    </plugins>
-
     <resources>
       <resource>
         <directory>src/main/resources</directory>
diff --git 
a/ruta-basic-type/src/main/resources/META-INF/services/org.apache.uima.spi.JCasClassProvider
 
b/ruta-basic-type/src/main/resources/META-INF/services/org.apache.uima.spi.JCasClassProvider
deleted file mode 100644
index ec3d6cec..00000000
--- 
a/ruta-basic-type/src/main/resources/META-INF/services/org.apache.uima.spi.JCasClassProvider
+++ /dev/null
@@ -1 +0,0 @@
-org.apache.uima.ruta.type.RutaBasicTypeProvider
diff --git a/ruta-core/pom.xml b/ruta-core/pom.xml
index 3f8505b7..65d6893a 100644
--- a/ruta-core/pom.xml
+++ b/ruta-core/pom.xml
@@ -190,6 +190,8 @@
                   
<exclude>src/main/resources/META-INF/org.apache.uima.fit/*.txt</exclude>
                   <exclude>input/**</exclude> <!-- temp test data -->
                   <exclude>TypeSystem.xml</exclude> <!-- temp test data -->
+                  
<exclude>src/main/resources/META-INF/services/org.apache.uima.spi.JCasClassProvider</exclude>
+                  
<exclude>src/main/resources/META-INF/services/org.apache.uima.spi.TypeSystemDescriptionProvider</exclude>
                 </excludes>
               </configuration>
             </execution>
@@ -235,6 +237,7 @@
         <groupId>org.apache.felix</groupId>
         <artifactId>maven-bundle-plugin</artifactId>
         <configuration>
+        
           <instructions>
             
<Bundle-RequiredExecutionEnvironment>JavaSE-1.8</Bundle-RequiredExecutionEnvironment>
             <_dsannotations>*</_dsannotations>
@@ -248,7 +251,13 @@
               *
             </Import-Package>
             -->
+            <Private-Package>
+              org.apache.uima.ruta.engine;-split-package:=merge-first,
+              org.apache.uima.ruta.type;-split-package:=merge-first,
+            </Private-Package>
             <Export-Package>
+              org.apache.uima.ruta.engine;-split-package:=merge-first,
+              org.apache.uima.ruta.type;-split-package:=merge-first,
               org.apache.uima.ruta,
               org.apache.uima.ruta.*
             </Export-Package>
diff --git 
a/ruta-core/src/main/java/org/apache/uima/ruta/type/spi/RutaBasicTypeProvider.java
 
b/ruta-core/src/main/java/org/apache/uima/ruta/type/spi/RutaBasicTypeProvider.java
new file mode 100644
index 00000000..f1417ccd
--- /dev/null
+++ 
b/ruta-core/src/main/java/org/apache/uima/ruta/type/spi/RutaBasicTypeProvider.java
@@ -0,0 +1,35 @@
+/*
+ * 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.
+ */
+package org.apache.uima.ruta.type.spi;
+
+import static java.util.Arrays.asList;
+
+import java.util.List;
+
+import org.apache.uima.jcas.cas.TOP;
+import org.apache.uima.ruta.type.RutaBasic;
+import org.apache.uima.spi.JCasClassProvider;
+
+public class RutaBasicTypeProvider implements JCasClassProvider {
+
+  @Override
+  public List<Class<? extends TOP>> listJCasClasses() {
+    return asList(RutaBasic.class);
+  }
+}
diff --git 
a/ruta-core/src/main/java/org/apache/uima/ruta/type/spi/RutaTypeSystemDescriptionProvider.java
 
b/ruta-core/src/main/java/org/apache/uima/ruta/type/spi/RutaTypeSystemDescriptionProvider.java
new file mode 100644
index 00000000..8739b736
--- /dev/null
+++ 
b/ruta-core/src/main/java/org/apache/uima/ruta/type/spi/RutaTypeSystemDescriptionProvider.java
@@ -0,0 +1,68 @@
+/*
+ * 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.
+ */
+package org.apache.uima.ruta.type.spi;
+
+import static 
org.apache.uima.util.TypeSystemUtil.loadTypeSystemDescriptionsFromClasspath;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.uima.jcas.cas.TOP;
+import org.apache.uima.resource.metadata.TypeDescription;
+import org.apache.uima.resource.metadata.TypeSystemDescription;
+import org.apache.uima.spi.JCasClassProvider;
+import org.apache.uima.spi.TypeSystemDescriptionProvider;
+
+public class RutaTypeSystemDescriptionProvider
+        implements TypeSystemDescriptionProvider, JCasClassProvider {
+
+  @Override
+  public List<TypeSystemDescription> listTypeSystemDescriptions() {
+
+    return loadTypeSystemDescriptionsFromClasspath(getClass(), //
+            "/org/apache/uima/ruta/engine/BasicTypeSystem.xml", //
+            "/org/apache/uima/ruta/engine/DefaultSeederTypeSystem.xml", //
+            "/org/apache/uima/ruta/engine/HtmlTypeSystem.xml", //
+            "/org/apache/uima/ruta/engine/PlainTextTypeSystem.xml", //
+            "/org/apache/uima/ruta/engine/RutaBasicTypeSystem.xml", //
+            "/org/apache/uima/ruta/engine/RutaInternalTypeSystem.xml", //
+            "/org/apache/uima/ruta/engine/SourceDocumentInformation.xml");
+  }
+
+  @SuppressWarnings("unchecked")
+@Override
+  public List<Class<? extends TOP>> listJCasClasses() {
+
+    List<Class<? extends TOP>> classes = new ArrayList<>();
+    ClassLoader cl = getClass().getClassLoader();
+
+    List<TypeSystemDescription> typeSystemDescriptions = 
listTypeSystemDescriptions();
+    for (TypeSystemDescription tsd : typeSystemDescriptions) {
+      for (TypeDescription td : tsd.getTypes()) {
+        try {
+          classes.add((Class<? extends TOP>) cl.loadClass(td.getName()));
+        } catch (ClassNotFoundException e) {
+          // This is acceptable - there may not be a JCas class
+        }
+      }
+    }
+
+    return classes;
+  }
+}
diff --git 
a/ruta-core/src/main/resources/META-INF/services/org.apache.uima.spi.JCasClassProvider
 
b/ruta-core/src/main/resources/META-INF/services/org.apache.uima.spi.JCasClassProvider
new file mode 100644
index 00000000..940694a3
--- /dev/null
+++ 
b/ruta-core/src/main/resources/META-INF/services/org.apache.uima.spi.JCasClassProvider
@@ -0,0 +1,2 @@
+org.apache.uima.ruta.type.spi.RutaBasicTypeProvider
+org.apache.uima.ruta.type.spi.RutaTypeSystemDescriptionProvider
diff --git 
a/ruta-core/src/main/resources/META-INF/services/org.apache.uima.spi.TypeSystemDescriptionProvider
 
b/ruta-core/src/main/resources/META-INF/services/org.apache.uima.spi.TypeSystemDescriptionProvider
new file mode 100644
index 00000000..9bfd15ab
--- /dev/null
+++ 
b/ruta-core/src/main/resources/META-INF/services/org.apache.uima.spi.TypeSystemDescriptionProvider
@@ -0,0 +1 @@
+org.apache.uima.ruta.type.spi.RutaTypeSystemDescriptionProvider
diff --git a/ruta-maven-plugin/pom.xml b/ruta-maven-plugin/pom.xml
index e8b82d7f..a15dfac2 100644
--- a/ruta-maven-plugin/pom.xml
+++ b/ruta-maven-plugin/pom.xml
@@ -78,11 +78,13 @@
       <groupId>org.apache.maven</groupId>
       <artifactId>maven-plugin-api</artifactId>
       <version>3.0.3</version>
+      <scope>provided</scope>
     </dependency>
     <dependency>
       <groupId>org.apache.maven</groupId>
       <artifactId>maven-core</artifactId>
       <version>3.0.3</version>
+      <scope>provided</scope>
     </dependency>
     <dependency>
       <groupId>org.apache.maven.plugin-tools</groupId>
@@ -95,6 +97,11 @@
       <artifactId>plexus-build-api</artifactId>
       <version>0.0.7</version>
     </dependency>
+    <dependency>
+      <groupId>org.codehaus.plexus</groupId>
+      <artifactId>plexus-utils</artifactId>
+      <version>2.0.6</version>
+    </dependency>
     <dependency>
       <groupId>org.apache.maven.plugin-testing</groupId>
       <artifactId>maven-plugin-testing-harness</artifactId>
diff --git a/ruta-typesystem/marker-file-identifying-osgi-bundle 
b/ruta-typesystem/marker-file-identifying-osgi-bundle
deleted file mode 100644
index e69de29b..00000000
diff --git a/ruta-typesystem/pom.xml b/ruta-typesystem/pom.xml
index 89cf63f2..aa3ad0b4 100644
--- a/ruta-typesystem/pom.xml
+++ b/ruta-typesystem/pom.xml
@@ -30,7 +30,7 @@
   </parent>
 
   <artifactId>ruta-typesystem</artifactId>
-  <packaging>bundle</packaging>
+  <packaging>jar</packaging>
 
   <name>Apache UIMA Ruta: ${project.artifactId}</name>
   <description>The type systems provided by ruta-core.</description>
@@ -96,25 +96,6 @@
     </resources>
 
     <plugins>
-      <plugin>
-        <groupId>org.apache.felix</groupId>
-        <artifactId>maven-bundle-plugin</artifactId>
-        <extensions>true</extensions>
-        <configuration>
-          <instructions>
-            <Fragment-Host>org.apache.uima.ruta-core</Fragment-Host>
-            <Import-Package>
-              org.apache.uima.ruta.type;-split-package:=merge-first,
-              *
-            </Import-Package>
-            <Export-Package>
-              org.apache.uima.ruta.type;-split-package:=merge-first,
-              org.apache.uima.ruta.type.html,
-              org.apache.uima.ruta.engine;-split-package:=merge-first
-            </Export-Package>
-          </instructions>
-        </configuration>
-      </plugin>
       <plugin>
         <groupId>org.apache.uima</groupId>
         <artifactId>jcasgen-maven-plugin</artifactId>
@@ -157,22 +138,6 @@
           </sourceFileExcludes>
         </configuration>
       </plugin>
-
-      <plugin>
-        <groupId>org.apache.rat</groupId>
-        <artifactId>apache-rat-plugin</artifactId>
-        <executions>
-          <execution>
-            <id>default-cli</id>
-            <configuration>
-              <excludes combine.children="append">
-                
<exclude>src/main/resources/META-INF/services/org.apache.uima.spi.JCasClassProvider</exclude>
-                
<exclude>src/main/resources/META-INF/services/org.apache.uima.spi.TypeSystemDescriptionProvider</exclude>
-              </excludes>
-            </configuration>
-          </execution>
-        </executions>
-      </plugin>
     </plugins>
   </build>
 </project>
\ No newline at end of file
diff --git 
a/ruta-typesystem/src/main/resources/META-INF/services/org.apache.uima.spi.JCasClassProvider
 
b/ruta-typesystem/src/main/resources/META-INF/services/org.apache.uima.spi.JCasClassProvider
deleted file mode 100644
index fff89516..00000000
--- 
a/ruta-typesystem/src/main/resources/META-INF/services/org.apache.uima.spi.JCasClassProvider
+++ /dev/null
@@ -1 +0,0 @@
-org.apache.uima.ruta.type.spi.RutaTypeSystemDescriptionProvider
\ No newline at end of file

Reply via email to