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 f6ee8eee866bac8111d66fd2c6cf60377afef75f Author: Richard Eckart de Castilho <[email protected]> AuthorDate: Mon Aug 29 15:25:08 2022 +0200 #100 - Enable type system discovery via SPI in OSGI - Added Apache SNAPSHOT repo - UIMA Parent POM 15 -> 16-SNAPSHOT - UIMA Java SDK 3.3.0 -> 3.4.0-SNAPSHOT - uimaFIT 3.3.0 -> 3.4.0-SNAPSHOT - spring 5.3.20 -> 5.3.21 - Added SPI to ruta-base-type module - Added SPI to ruta-typesystem module - Turned ruta-core module into an OSGI bundle - Turned ruta-base-type and ruta-typesystem into fragments attaching to ruta-core --- ruta-basic-type/.gitignore | 1 + .../marker-file-identifying-osgi-bundle | 0 ruta-basic-type/pom.xml | 161 +++--- .../uima/ruta/type/RutaBasicTypeProvider.java | 34 ++ .../services/org.apache.uima.spi.JCasClassProvider | 1 + ruta-core/.gitignore | 1 + ruta-core/marker-file-identifying-osgi-bundle | 0 ruta-core/pom.xml | 32 +- ruta-parent/pom.xml | 547 +++++++++++---------- ruta-typesystem/.gitignore | 1 + .../marker-file-identifying-osgi-bundle | 0 ruta-typesystem/pom.xml | 242 +++++---- .../spi/RutaTypeSystemDescriptionProvider.java | 104 ++++ .../services/org.apache.uima.spi.JCasClassProvider | 1 + ...g.apache.uima.spi.TypeSystemDescriptionProvider | 1 + 15 files changed, 693 insertions(+), 433 deletions(-) diff --git a/ruta-basic-type/.gitignore b/ruta-basic-type/.gitignore new file mode 100644 index 00000000..3385916d --- /dev/null +++ b/ruta-basic-type/.gitignore @@ -0,0 +1 @@ +/META-INF/ diff --git a/ruta-basic-type/marker-file-identifying-osgi-bundle b/ruta-basic-type/marker-file-identifying-osgi-bundle new file mode 100644 index 00000000..e69de29b diff --git a/ruta-basic-type/pom.xml b/ruta-basic-type/pom.xml index 22c340a2..9f641347 100644 --- a/ruta-basic-type/pom.xml +++ b/ruta-basic-type/pom.xml @@ -17,75 +17,104 @@ 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/xsd/maven-4.0.0.xsd"> - <modelVersion>4.0.0</modelVersion> - <artifactId>ruta-basic-type</artifactId> - <parent> - <groupId>org.apache.uima</groupId> - <artifactId>ruta-parent</artifactId> - <version>3.3.0-SNAPSHOT</version> - <relativePath>../ruta-parent/pom.xml</relativePath> - </parent> +<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/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> - <properties> - <uimaScmProject>${project.artifactId}</uimaScmProject> - </properties> + <parent> + <groupId>org.apache.uima</groupId> + <artifactId>ruta-parent</artifactId> + <version>3.3.0-SNAPSHOT</version> + <relativePath>../ruta-parent/pom.xml</relativePath> + </parent> - <url>${uimaWebsiteUrl}</url> - <description>The RutaBasic type provided by ruta-core.</description> - <name>Apache UIMA Ruta: ${project.artifactId}</name> + <artifactId>ruta-basic-type</artifactId> + <packaging>bundle</packaging> - <scm> - <connection>scm:git:https://github.com/apache/uima-ruta/</connection> - <developerConnection>scm:git:https://github.com/apache/uima-ruta/</developerConnection> - <url>https://github.com/apache/uima-ruta/</url> - <tag>HEAD</tag> - </scm> + <name>Apache UIMA Ruta: ${project.artifactId}</name> + <description>The RutaBasic type provided by ruta-core.</description> + <url>${uimaWebsiteUrl}</url> - <dependencies> - <dependency> - <groupId>org.apache.uima</groupId> - <artifactId>uimaj-core</artifactId> - <version>${uimaVersion}</version> - <scope>compile</scope> - </dependency> - <dependency> - <groupId>junit</groupId> - <artifactId>junit</artifactId> - <scope>test</scope> - </dependency> - </dependencies> + <properties> + <uimaScmProject>${project.artifactId}</uimaScmProject> + </properties> - <build> - <pluginManagement> - <plugins> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-javadoc-plugin</artifactId> - <configuration> - <excludePackageNames>org.apache.uima.ruta.type</excludePackageNames> - </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/org.apache.uima.fit/*.txt</exclude> - </excludes> - </configuration> - </execution> - </executions> - </plugin> - </plugins> - </pluginManagement> - <resources> - <resource> - <directory>src/main/resources</directory> - </resource> - </resources> - </build> + <scm> + <connection>scm:git:https://github.com/apache/uima-ruta/</connection> + <developerConnection>scm:git:https://github.com/apache/uima-ruta/</developerConnection> + <url>https://github.com/apache/uima-ruta/</url> + <tag>HEAD</tag> + </scm> + + <dependencies> + <dependency> + <groupId>org.apache.uima</groupId> + <artifactId>uimaj-core</artifactId> + <version>${uimaVersion}</version> + <scope>compile</scope> + </dependency> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <scope>test</scope> + </dependency> + </dependencies> + + <build> + <pluginManagement> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-javadoc-plugin</artifactId> + <configuration> + <excludePackageNames>org.apache.uima.ruta.type</excludePackageNames> + </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/org.apache.uima.fit/*.txt</exclude> + </excludes> + </configuration> + </execution> + </executions> + </plugin> + </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> + <Require-Capability> + osgi.extender;filter:="(osgi.extender=osgi.serviceloader.registrar)" + </Require-Capability> + <Provide-Capability> + osgi.serviceloader;osgi.serviceloader=org.apache.uima.spi.JCasClassProvider + </Provide-Capability> + </instructions> + </configuration> + </plugin> + + </plugins> + + <resources> + <resource> + <directory>src/main/resources</directory> + </resource> + </resources> + </build> </project> \ No newline at end of file diff --git a/ruta-basic-type/src/main/java/org/apache/uima/ruta/type/RutaBasicTypeProvider.java b/ruta-basic-type/src/main/java/org/apache/uima/ruta/type/RutaBasicTypeProvider.java new file mode 100644 index 00000000..61fb5ff6 --- /dev/null +++ b/ruta-basic-type/src/main/java/org/apache/uima/ruta/type/RutaBasicTypeProvider.java @@ -0,0 +1,34 @@ +/* + * 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; + +import static java.util.Arrays.asList; + +import java.util.List; + +import org.apache.uima.jcas.cas.TOP; +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-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 new file mode 100644 index 00000000..ec3d6cec --- /dev/null +++ b/ruta-basic-type/src/main/resources/META-INF/services/org.apache.uima.spi.JCasClassProvider @@ -0,0 +1 @@ +org.apache.uima.ruta.type.RutaBasicTypeProvider diff --git a/ruta-core/.gitignore b/ruta-core/.gitignore index 862d2767..33b796c7 100644 --- a/ruta-core/.gitignore +++ b/ruta-core/.gitignore @@ -1,2 +1,3 @@ input/ TypeSystem.xml +/META-INF/ diff --git a/ruta-core/marker-file-identifying-osgi-bundle b/ruta-core/marker-file-identifying-osgi-bundle new file mode 100644 index 00000000..e69de29b diff --git a/ruta-core/pom.xml b/ruta-core/pom.xml index 5709978a..2671b0a0 100644 --- a/ruta-core/pom.xml +++ b/ruta-core/pom.xml @@ -19,7 +19,6 @@ --> <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/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> - <artifactId>ruta-core</artifactId> <parent> <groupId>org.apache.uima</groupId> @@ -28,6 +27,9 @@ <relativePath>../ruta-parent/pom.xml</relativePath> </parent> + <artifactId>ruta-core</artifactId> + <packaging>bundle</packaging> + <properties> <uimaScmProject>${project.artifactId}</uimaScmProject> <postNoticeText>${uniWueNoticeText}</postNoticeText> @@ -45,7 +47,6 @@ </scm> <dependencies> - <dependency> <groupId>org.apache.uima</groupId> <artifactId>ruta-typesystem</artifactId> @@ -222,12 +223,39 @@ </plugin> </plugins> </pluginManagement> + <resources> <resource> <directory>src/main/resources</directory> </resource> </resources> + <plugins> + <plugin> + <groupId>org.apache.felix</groupId> + <artifactId>maven-bundle-plugin</artifactId> + <configuration> + <instructions> + <Bundle-RequiredExecutionEnvironment>JavaSE-1.8</Bundle-RequiredExecutionEnvironment> + <_dsannotations>*</_dsannotations> + <_metatypeannotations>*</_metatypeannotations> + <!-- + <Import-Package> + !com.apple.eio, + org.slf4j.impl;resolution:=optional, + org.apache.logging.log4j.*;resolution:=optional, + org.apache.logging.slf4j.*;resolution:=optional, + * + </Import-Package> + --> + <Export-Package> + org.apache.uima.ruta, + org.apache.uima.ruta.* + </Export-Package> + </instructions> + </configuration> + </plugin> + <!-- generate java code for antlr grammars --> <plugin> <groupId>org.antlr</groupId> diff --git a/ruta-parent/pom.xml b/ruta-parent/pom.xml index d3741716..058cdc44 100644 --- a/ruta-parent/pom.xml +++ b/ruta-parent/pom.xml @@ -17,35 +17,37 @@ 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"> - <modelVersion>4.0.0</modelVersion> +<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"> + <modelVersion>4.0.0</modelVersion> - <parent> - <groupId>org.apache.uima</groupId> - <artifactId>parent-pom</artifactId> - <version>15</version> - <relativePath /> - </parent> + <parent> + <groupId>org.apache.uima</groupId> + <artifactId>parent-pom</artifactId> + <version>16-SNAPSHOT</version> + <relativePath /> + </parent> - <artifactId>ruta-parent</artifactId> - <packaging>pom</packaging> - <version>3.3.0-SNAPSHOT</version> - <name>Apache UIMA Ruta: ${project.artifactId}</name> - <url>${uimaWebsiteUrl}</url> - <inceptionYear>2011</inceptionYear> - <description>The common parent pom for the UIMA Ruta</description> + <artifactId>ruta-parent</artifactId> + <packaging>pom</packaging> + <version>3.3.0-SNAPSHOT</version> + <name>Apache UIMA Ruta: ${project.artifactId}</name> + <url>${uimaWebsiteUrl}</url> + <inceptionYear>2011</inceptionYear> + <description>The common parent pom for the UIMA Ruta</description> <!-- Special inheritance note even though the <scm> element that follows is exactly the same as those in super poms, it cannot be inherited because there is some special code that computes the connection elements from the chain of parent poms, if this is omitted. Keeping this a bit factored allows cutting/pasting the <scm> element, and just changing the following two properties --> - <scm> - <connection>scm:git:https://github.com/apache/uima-ruta/</connection> - <developerConnection>scm:git:https://github.com/apache/uima-ruta/</developerConnection> - <url>https://github.com/apache/uima-ruta/</url> - <tag>HEAD</tag> - </scm> + <scm> + <connection>scm:git:https://github.com/apache/uima-ruta/</connection> + <developerConnection>scm:git:https://github.com/apache/uima-ruta/</developerConnection> + <url>https://github.com/apache/uima-ruta/</url> + <tag>HEAD</tag> + </scm> <!-- The repositories and pluginRepositories section is duplicated from the parent pom one, and adds the Apache Snapshot Nexus repository where UIMA @@ -53,256 +55,281 @@ on some new SNAPSHOT level of a build tool, where the users hasn't checked out the build tooling. This allows maven to find the snapshots when looking for the parent of this pom --> - <repositories> + <repositories> <!-- modify central repository access: Turn on checksum checking --> - <repository> - <id>central</id> - <name>Maven Repository Switchboard</name> - <layout>default</layout> - <url>https://repo1.maven.org/maven2</url> + <repository> + <id>central</id> + <name>Maven Repository Switchboard</name> + <layout>default</layout> + <url>https://repo1.maven.org/maven2</url> - <releases> - <enabled>true</enabled> - <checksumPolicy>fail</checksumPolicy> - <updatePolicy>never</updatePolicy> - </releases> + <releases> + <enabled>true</enabled> + <checksumPolicy>fail</checksumPolicy> + <updatePolicy>never</updatePolicy> + </releases> - <snapshots> - <enabled>false</enabled> - </snapshots> - </repository> - </repositories> + <snapshots> + <enabled>false</enabled> + </snapshots> + </repository> - <properties> - <uniWueNoticeText>Portions of UIMA Ruta were originally developed by - the Universität Würzburg. - Copyright (c) 2006, 2011 Universität - Würzburg.</uniWueNoticeText> - <postNoticeText>${uniWueNoticeText} + <repository> + <id>apache.snapshots</id> + <url>https://repository.apache.org/content/repositories/snapshots</url> + <releases> + <enabled>false</enabled> + </releases> + <snapshots> + <enabled>true</enabled> + </snapshots> + </repository> + </repositories> - This product contains icons - developed by Mark James - (http://www.famfamfam.com/lab/icons/silk/), licensed under the - Creative Commons Attribution 3.0 License. - </postNoticeText> + <!-- Only for testing --> + <pluginRepositories> + <pluginRepository> + <id>apache.snapshots</id> + <url>https://repository.apache.org/content/repositories/snapshots/</url> + <releases> + <enabled>false</enabled> + </releases> + <snapshots> + <enabled>true</enabled> + </snapshots> + </pluginRepository> + </pluginRepositories> - <uimaVersion>3.3.0</uimaVersion> - <uimafit-version>3.3.0</uimafit-version> - <spring-version>5.3.20</spring-version> - <junit-version>4.13.2</junit-version> - <slf4j-version>1.7.36</slf4j-version> + <properties> + <uniWueNoticeText>Portions of UIMA Ruta were originally developed by + the Universität Würzburg. + Copyright (c) 2006, 2011 Universität + Würzburg.</uniWueNoticeText> + <postNoticeText>${uniWueNoticeText} - <antlr-version>3.5.3</antlr-version> - <htmlparser-version>1.6</htmlparser-version> - <commons-collections-version>3.2.2</commons-collections-version> - <commons-collections4-version>4.4</commons-collections4-version> - <commons-text-version>1.9</commons-text-version> - <commons-lang3-version>3.12.0</commons-lang3-version> - <commons-io-version>2.11.0</commons-io-version> - <commons-math3-version>3.6.1</commons-math3-version> - <commons-logging-version>1.1.1</commons-logging-version> - <commons-logging-api-version>1.1</commons-logging-api-version> - <caffeine-version>2.9.3</caffeine-version> + This product contains icons + developed by Mark James + (http://www.famfamfam.com/lab/icons/silk/), licensed under the + Creative Commons Attribution 3.0 License. + </postNoticeText> - <api_check_oldVersion>3.2.0</api_check_oldVersion> + <uimaVersion>3.4.0-SNAPSHOT</uimaVersion> + <uimafit-version>3.4.0-SNAPSHOT</uimafit-version> + <spring-version>5.3.21</spring-version> + <junit-version>4.13.2</junit-version> + <slf4j-version>1.7.36</slf4j-version> - <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> - <maven.compiler.target>1.8</maven.compiler.target> - <maven.compiler.source>1.8</maven.compiler.source> - </properties> + <antlr-version>3.5.3</antlr-version> + <htmlparser-version>1.6</htmlparser-version> + <commons-collections-version>3.2.2</commons-collections-version> + <commons-collections4-version>4.4</commons-collections4-version> + <commons-text-version>1.9</commons-text-version> + <commons-lang3-version>3.12.0</commons-lang3-version> + <commons-io-version>2.11.0</commons-io-version> + <commons-math3-version>3.6.1</commons-math3-version> + <commons-logging-version>1.1.1</commons-logging-version> + <commons-logging-api-version>1.1</commons-logging-api-version> + <caffeine-version>2.9.3</caffeine-version> - <dependencyManagement> - <dependencies> - <dependency> - <groupId>org.antlr</groupId> - <artifactId>antlr-runtime</artifactId> - <version>${antlr-version}</version> - </dependency> - <dependency> - <groupId>org.htmlparser</groupId> - <artifactId>htmlparser</artifactId> - <version>${htmlparser-version}</version> - </dependency> - <dependency> - <groupId>commons-collections</groupId> - <artifactId>commons-collections</artifactId> - <version>${commons-collections-version}</version> - </dependency> - <dependency> - <groupId>org.apache.commons</groupId> - <artifactId>commons-collections4</artifactId> - <version>${commons-collections4-version}</version> - </dependency> - <dependency> - <groupId>org.apache.commons</groupId> - <artifactId>commons-text</artifactId> - <version>${commons-text-version}</version> - </dependency> - <dependency> - <groupId>org.apache.commons</groupId> - <artifactId>commons-lang3</artifactId> - <version>${commons-lang3-version}</version> - </dependency> - <dependency> - <groupId>org.apache.uima</groupId> - <artifactId>uimafit-core</artifactId> - <version>${uimafit-version}</version> - </dependency> - <dependency> - <groupId>commons-io</groupId> - <artifactId>commons-io</artifactId> - <version>${commons-io-version}</version> - </dependency> - <dependency> - <groupId>org.apache.commons</groupId> - <artifactId>commons-math3</artifactId> - <version>${commons-math3-version}</version> - </dependency> - <dependency> - <groupId>commons-logging</groupId> - <artifactId>commons-logging</artifactId> - <version>${commons-logging-version}</version> - </dependency> - <dependency> - <groupId>commons-logging</groupId> - <artifactId>commons-logging-api</artifactId> - <version>${commons-logging-api-version}</version> - </dependency> - <dependency> - <groupId>org.springframework</groupId> - <artifactId>spring-core</artifactId> - <version>${spring-version}</version> - </dependency> - <dependency> - <groupId>org.springframework</groupId> - <artifactId>spring-context</artifactId> - <version>${spring-version}</version> - </dependency> - <dependency> - <groupId>org.springframework</groupId> - <artifactId>spring-expression</artifactId> - <version>${spring-version}</version> - </dependency> - <dependency> - <groupId>org.springframework</groupId> - <artifactId>spring-beans</artifactId> - <version>${spring-version}</version> - </dependency> + <api_check_oldVersion>3.2.0</api_check_oldVersion> - <dependency> - <groupId>com.github.ben-manes.caffeine</groupId> - <artifactId>caffeine</artifactId> - <version>${caffeine-version}</version> - </dependency> + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> + <maven.compiler.target>1.8</maven.compiler.target> + <maven.compiler.source>1.8</maven.compiler.source> + </properties> - <dependency> - <groupId>junit</groupId> - <artifactId>junit</artifactId> - <version>${junit-version}</version> - </dependency> - <dependency> - <groupId>org.slf4j</groupId> - <artifactId>slf4j-jdk14</artifactId> - <version>${slf4j-version}</version> - <scope>test</scope> - </dependency> - </dependencies> - </dependencyManagement> + <dependencyManagement> + <dependencies> + <dependency> + <groupId>org.antlr</groupId> + <artifactId>antlr-runtime</artifactId> + <version>${antlr-version}</version> + </dependency> + <dependency> + <groupId>org.htmlparser</groupId> + <artifactId>htmlparser</artifactId> + <version>${htmlparser-version}</version> + </dependency> + <dependency> + <groupId>commons-collections</groupId> + <artifactId>commons-collections</artifactId> + <version>${commons-collections-version}</version> + </dependency> + <dependency> + <groupId>org.apache.commons</groupId> + <artifactId>commons-collections4</artifactId> + <version>${commons-collections4-version}</version> + </dependency> + <dependency> + <groupId>org.apache.commons</groupId> + <artifactId>commons-text</artifactId> + <version>${commons-text-version}</version> + </dependency> + <dependency> + <groupId>org.apache.commons</groupId> + <artifactId>commons-lang3</artifactId> + <version>${commons-lang3-version}</version> + </dependency> + <dependency> + <groupId>org.apache.uima</groupId> + <artifactId>uimafit-core</artifactId> + <version>${uimafit-version}</version> + </dependency> + <dependency> + <groupId>commons-io</groupId> + <artifactId>commons-io</artifactId> + <version>${commons-io-version}</version> + </dependency> + <dependency> + <groupId>org.apache.commons</groupId> + <artifactId>commons-math3</artifactId> + <version>${commons-math3-version}</version> + </dependency> + <dependency> + <groupId>commons-logging</groupId> + <artifactId>commons-logging</artifactId> + <version>${commons-logging-version}</version> + </dependency> + <dependency> + <groupId>commons-logging</groupId> + <artifactId>commons-logging-api</artifactId> + <version>${commons-logging-api-version}</version> + </dependency> + <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-core</artifactId> + <version>${spring-version}</version> + </dependency> + <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-context</artifactId> + <version>${spring-version}</version> + </dependency> + <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-expression</artifactId> + <version>${spring-version}</version> + </dependency> + <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-beans</artifactId> + <version>${spring-version}</version> + </dependency> - <build> - <pluginManagement> - <plugins> - <plugin> - <groupId>org.apache.uima</groupId> - <artifactId>uima-build-helper-maven-plugin</artifactId> - <version>7</version> - </plugin> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-compiler-plugin</artifactId> - <configuration> - <source>${maven.compiler.source}</source> - <target>${maven.compiler.target}</target> - </configuration> - </plugin> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-javadoc-plugin</artifactId> - <executions> - <execution> - <id>attach-javadocs</id> - <configuration> - <source>${maven.compiler.source}</source> - </configuration> - </execution> - </executions> - <configuration> - <source>${maven.compiler.source}</source> - </configuration> - </plugin> - </plugins> - </pluginManagement> - <plugins> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-toolchains-plugin</artifactId> - <executions> - <execution> - <goals> - <goal>toolchain</goal> - </goals> - </execution> - </executions> - <configuration> - <toolchains> - <jdk> - <version>${maven.compiler.target}</version> - </jdk> - </toolchains> - </configuration> - </plugin> - <plugin> - <artifactId>maven-resources-plugin</artifactId> - <executions> - <execution> - <id>copy customized bin LICENSE file</id> - <phase>prepare-package</phase> - <goals> - <goal>copy-resources</goal> - </goals> - <configuration> - <outputDirectory>${project.build.directory}/classes/META-INF</outputDirectory> - <resources> - <resource> - <directory>src/main/readme_bin</directory> - <includes> - <include>LICENSE</include> - <include>NOTICE</include> - </includes> - <filtering>true</filtering> - </resource> - </resources> - </configuration> - </execution> - </executions> - </plugin> - </plugins> - </build> - - <profiles> - <profile> - <id>spotbugs</id> - <build> - <pluginManagement> - <plugins> - <plugin> - <groupId>com.github.spotbugs</groupId> - <artifactId>spotbugs-maven-plugin</artifactId> - <version>4.7.0.0</version> - </plugin> - </plugins> - </pluginManagement> - </build> - </profile> - </profiles> + <dependency> + <groupId>com.github.ben-manes.caffeine</groupId> + <artifactId>caffeine</artifactId> + <version>${caffeine-version}</version> + </dependency> + + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>${junit-version}</version> + </dependency> + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-jdk14</artifactId> + <version>${slf4j-version}</version> + <scope>test</scope> + </dependency> + </dependencies> + </dependencyManagement> + + <build> + <pluginManagement> + <plugins> + <plugin> + <groupId>org.apache.uima</groupId> + <artifactId>uima-build-helper-maven-plugin</artifactId> + <version>7</version> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-compiler-plugin</artifactId> + <configuration> + <source>${maven.compiler.source}</source> + <target>${maven.compiler.target}</target> + </configuration> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-javadoc-plugin</artifactId> + <executions> + <execution> + <id>attach-javadocs</id> + <configuration> + <source>${maven.compiler.source}</source> + </configuration> + </execution> + </executions> + <configuration> + <source>${maven.compiler.source}</source> + </configuration> + </plugin> + </plugins> + </pluginManagement> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-toolchains-plugin</artifactId> + <executions> + <execution> + <goals> + <goal>toolchain</goal> + </goals> + </execution> + </executions> + <configuration> + <toolchains> + <jdk> + <version>${maven.compiler.target}</version> + </jdk> + </toolchains> + </configuration> + </plugin> + <plugin> + <artifactId>maven-resources-plugin</artifactId> + <executions> + <execution> + <id>copy customized bin LICENSE file</id> + <phase>prepare-package</phase> + <goals> + <goal>copy-resources</goal> + </goals> + <configuration> + <outputDirectory>${project.build.directory}/classes/META-INF</outputDirectory> + <resources> + <resource> + <directory>src/main/readme_bin</directory> + <includes> + <include>LICENSE</include> + <include>NOTICE</include> + </includes> + <filtering>true</filtering> + </resource> + </resources> + </configuration> + </execution> + </executions> + </plugin> + </plugins> + </build> + + <profiles> + <profile> + <id>spotbugs</id> + <build> + <pluginManagement> + <plugins> + <plugin> + <groupId>com.github.spotbugs</groupId> + <artifactId>spotbugs-maven-plugin</artifactId> + <version>4.7.0.0</version> + </plugin> + </plugins> + </pluginManagement> + </build> + </profile> + </profiles> </project> diff --git a/ruta-typesystem/.gitignore b/ruta-typesystem/.gitignore new file mode 100644 index 00000000..3385916d --- /dev/null +++ b/ruta-typesystem/.gitignore @@ -0,0 +1 @@ +/META-INF/ diff --git a/ruta-typesystem/marker-file-identifying-osgi-bundle b/ruta-typesystem/marker-file-identifying-osgi-bundle new file mode 100644 index 00000000..e69de29b diff --git a/ruta-typesystem/pom.xml b/ruta-typesystem/pom.xml index 96fe1754..0383f9ce 100644 --- a/ruta-typesystem/pom.xml +++ b/ruta-typesystem/pom.xml @@ -17,118 +17,150 @@ 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/xsd/maven-4.0.0.xsd"> - <modelVersion>4.0.0</modelVersion> - <artifactId>ruta-typesystem</artifactId> - <parent> - <groupId>org.apache.uima</groupId> - <artifactId>ruta-parent</artifactId> - <version>3.3.0-SNAPSHOT</version> - <relativePath>../ruta-parent/pom.xml</relativePath> - </parent> +<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/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> - <url>${uimaWebsiteUrl}</url> - <description>The type systems provided by ruta-core.</description> - <name>Apache UIMA Ruta: ${project.artifactId}</name> + <parent> + <groupId>org.apache.uima</groupId> + <artifactId>ruta-parent</artifactId> + <version>3.3.0-SNAPSHOT</version> + <relativePath>../ruta-parent/pom.xml</relativePath> + </parent> - <properties> - <uimaScmProject>${project.artifactId}</uimaScmProject> - </properties> + <artifactId>ruta-typesystem</artifactId> + <packaging>bundle</packaging> - <scm> - <connection>scm:git:https://github.com/apache/uima-ruta/</connection> - <developerConnection>scm:git:https://github.com/apache/uima-ruta/</developerConnection> - <url>https://github.com/apache/uima-ruta/</url> - <tag>HEAD</tag> - </scm> + <name>Apache UIMA Ruta: ${project.artifactId}</name> + <description>The type systems provided by ruta-core.</description> + <url>${uimaWebsiteUrl}</url> - <dependencies> - <dependency> - <groupId>org.apache.uima</groupId> - <artifactId>ruta-basic-type</artifactId> - <version>${project.version}</version> - </dependency> + <properties> + <uimaScmProject>${project.artifactId}</uimaScmProject> + </properties> - <dependency> - <groupId>org.apache.uima</groupId> - <artifactId>uimaj-core</artifactId> - <version>${uimaVersion}</version> - <scope>compile</scope> - </dependency> - <dependency> - <groupId>junit</groupId> - <artifactId>junit</artifactId> - <scope>test</scope> - </dependency> - </dependencies> + <scm> + <connection>scm:git:https://github.com/apache/uima-ruta/</connection> + <developerConnection>scm:git:https://github.com/apache/uima-ruta/</developerConnection> + <url>https://github.com/apache/uima-ruta/</url> + <tag>HEAD</tag> + </scm> - <build> - <pluginManagement> - <plugins> - <plugin> - <groupId>org.apache.rat</groupId> - <artifactId>apache-rat-plugin</artifactId> - <executions> - <execution> - <id>default-cli</id> - <configuration> - <excludes> - <exclude>src/main/resources/META-INF/org.apache.uima.fit/*.txt</exclude> - <exclude>issuesFixed/**</exclude> <!-- generated --> - <exclude>marker-file-identifying-*</exclude> - </excludes> - </configuration> - </execution> - </executions> - </plugin> - </plugins> - </pluginManagement> - <resources> - <resource> - <directory>src/main/resources</directory> - </resource> - </resources> - <plugins> - <plugin> - <groupId>org.apache.uima</groupId> - <artifactId>jcasgen-maven-plugin</artifactId> - <version>${uimaVersion}</version> - <executions> - <execution> - <goals> - <goal>generate</goal> - </goals> + <dependencies> + <dependency> + <groupId>org.apache.uima</groupId> + <artifactId>ruta-basic-type</artifactId> + <version>${project.version}</version> + </dependency> + + <dependency> + <groupId>org.apache.uima</groupId> + <artifactId>uimaj-core</artifactId> + <version>${uimaVersion}</version> + <scope>compile</scope> + </dependency> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <scope>test</scope> + </dependency> + </dependencies> + + <build> + <pluginManagement> + <plugins> + <plugin> + <groupId>org.apache.rat</groupId> + <artifactId>apache-rat-plugin</artifactId> + <executions> + <execution> + <id>default-cli</id> + <configuration> + <excludes> + <exclude>src/main/resources/META-INF/org.apache.uima.fit/*.txt</exclude> + <exclude>issuesFixed/**</exclude> <!-- generated --> + <exclude>marker-file-identifying-*</exclude> + </excludes> + </configuration> + </execution> + </executions> + </plugin> + </plugins> + </pluginManagement> + + <resources> + <resource> + <directory>src/main/resources</directory> + </resource> + </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> + <Require-Capability> + osgi.extender;filter:="(osgi.extender=osgi.serviceloader.registrar)" + </Require-Capability> + <Provide-Capability> + osgi.serviceloader;osgi.serviceloader=org.apache.uima.spi.TypeSystemDescriptionProvider, + osgi.serviceloader;osgi.serviceloader=org.apache.uima.spi.JCasClassProvider + </Provide-Capability> + </instructions> + </configuration> + </plugin> + <plugin> + <groupId>org.apache.uima</groupId> + <artifactId>jcasgen-maven-plugin</artifactId> + <version>${uimaVersion}</version> + <executions> + <execution> + <goals> + <goal>generate</goal> + </goals> <!-- runs in phase process-resources by default --> - <configuration> + <configuration> <!-- one or more ant-like file patterns identifying top level descriptors --> - <typeSystemIncludes> - <typeSystemInclude>src/main/resources/org/apache/uima/ruta/engine/RutaInternalTypeSystem.xml</typeSystemInclude> - <typeSystemInclude>src/main/resources/org/apache/uima/ruta/engine/DefaultSeederTypeSystem.xml</typeSystemInclude> - <typeSystemInclude>src/main/resources/org/apache/uima/ruta/engine/HtmlTypeSystem.xml</typeSystemInclude> - <typeSystemInclude>src/main/resources/org/apache/uima/ruta/engine/PlainTextTypeSystem.xml</typeSystemInclude> - </typeSystemIncludes> - <limitToProject>true</limitToProject> - </configuration> - </execution> - </executions> - </plugin> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-surefire-plugin</artifactId> - <configuration> - <argLine>-Xmx650M</argLine> - </configuration> - </plugin> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-javadoc-plugin</artifactId> - <configuration> + <typeSystemIncludes> + <typeSystemInclude>src/main/resources/org/apache/uima/ruta/engine/RutaInternalTypeSystem.xml</typeSystemInclude> + <typeSystemInclude>src/main/resources/org/apache/uima/ruta/engine/DefaultSeederTypeSystem.xml</typeSystemInclude> + <typeSystemInclude>src/main/resources/org/apache/uima/ruta/engine/HtmlTypeSystem.xml</typeSystemInclude> + <typeSystemInclude>src/main/resources/org/apache/uima/ruta/engine/PlainTextTypeSystem.xml</typeSystemInclude> + </typeSystemIncludes> + <limitToProject>true</limitToProject> + </configuration> + </execution> + </executions> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-surefire-plugin</artifactId> + <configuration> + <argLine>-Xmx650M</argLine> + </configuration> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-javadoc-plugin</artifactId> + <configuration> <!-- Exclude generated jcas classes --> - <sourceFileExcludes> - <sourceFileExclude>**/org/apache/uima/ruta/type/*.java</sourceFileExclude> - </sourceFileExcludes> - </configuration> - </plugin> - </plugins> - </build> + <sourceFileExcludes> + <sourceFileExclude>**/org/apache/uima/ruta/type/*.java</sourceFileExclude> + </sourceFileExcludes> + </configuration> + </plugin> + </plugins> + </build> </project> \ No newline at end of file diff --git a/ruta-typesystem/src/main/java/org/apache/uima/ruta/type/spi/RutaTypeSystemDescriptionProvider.java b/ruta-typesystem/src/main/java/org/apache/uima/ruta/type/spi/RutaTypeSystemDescriptionProvider.java new file mode 100644 index 00000000..1edb9ef7 --- /dev/null +++ b/ruta-typesystem/src/main/java/org/apache/uima/ruta/type/spi/RutaTypeSystemDescriptionProvider.java @@ -0,0 +1,104 @@ +/* + * 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 java.io.IOException; +import java.net.URL; +import java.util.ArrayList; +import java.util.List; + +import org.apache.uima.UIMAFramework; +import org.apache.uima.jcas.cas.TOP; +import org.apache.uima.resource.ResourceManager; +import org.apache.uima.resource.impl.ResourceManager_impl; +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; +import org.apache.uima.util.InvalidXMLException; +import org.apache.uima.util.XMLInputSource; + +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"); + } + + @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; + } + + public static List<TypeSystemDescription> loadTypeSystemDescriptionsFromClasspath( + Class<?> aContext, String... typeSystemDescriptionFiles) { + + ResourceManager resMgr = new ResourceManager_impl(aContext.getClassLoader()); + try { + List<TypeSystemDescription> typeSystemDescriptions = new ArrayList<>(); + + for (String typeSystem : typeSystemDescriptionFiles) { + URL resource = aContext.getResource(typeSystem); + if (resource == null) { + UIMAFramework.getLogger() + .error("Unable to locate type system description as a resource [{}]", typeSystem); + continue; + } + + try { + TypeSystemDescription tsd = UIMAFramework.getXMLParser() + .parseTypeSystemDescription(new XMLInputSource(resource)); + tsd.resolveImports(resMgr); + typeSystemDescriptions.add(tsd); + } catch (InvalidXMLException | IOException e) { + UIMAFramework.getLogger().error("Error loading type system description [{}] from [{}]", + typeSystem, resource, e); + } + } + + return typeSystemDescriptions; + } finally { + resMgr.destroy(); + } + } +} 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 new file mode 100644 index 00000000..fff89516 --- /dev/null +++ b/ruta-typesystem/src/main/resources/META-INF/services/org.apache.uima.spi.JCasClassProvider @@ -0,0 +1 @@ +org.apache.uima.ruta.type.spi.RutaTypeSystemDescriptionProvider \ No newline at end of file diff --git a/ruta-typesystem/src/main/resources/META-INF/services/org.apache.uima.spi.TypeSystemDescriptionProvider b/ruta-typesystem/src/main/resources/META-INF/services/org.apache.uima.spi.TypeSystemDescriptionProvider new file mode 100644 index 00000000..9bfd15ab --- /dev/null +++ b/ruta-typesystem/src/main/resources/META-INF/services/org.apache.uima.spi.TypeSystemDescriptionProvider @@ -0,0 +1 @@ +org.apache.uima.ruta.type.spi.RutaTypeSystemDescriptionProvider
