You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uima.apache.org by re...@apache.org on 2017/09/20 16:17:18 UTC
svn commit: r1809048 - in /uima/uimafit/trunk/uimafit-maven-plugin/src:
it/with-typesystem-in-descriptors/
it/with-typesystem-in-descriptors/reference/
it/with-typesystem-in-descriptors/src/
it/with-typesystem-in-descriptors/src/main/ it/with-typesyste...
Author: rec
Date: Wed Sep 20 16:17:18 2017
New Revision: 1809048
URL: http://svn.apache.org/viewvc?rev=1809048&view=rev
Log:
[UIMA-3346] "generate" goal should include type system imports
- Applied UIMA-3346.2.patch from Jacob Carter
- Removed changes in whitespace-only lines
- Renamed new parameter to "addTypeSystemDescriptions"
- Improved description of the new parameter for adding type system descriptions
- Added plugin integration test for embedding the type systems in the descriptor
- Removed option to add type systems by-name since it wasn't working when I tried setting up an integration test
Added:
uima/uimafit/trunk/uimafit-maven-plugin/src/it/with-typesystem-in-descriptors/
uima/uimafit/trunk/uimafit-maven-plugin/src/it/with-typesystem-in-descriptors/pom.xml (with props)
uima/uimafit/trunk/uimafit-maven-plugin/src/it/with-typesystem-in-descriptors/reference/
uima/uimafit/trunk/uimafit-maven-plugin/src/it/with-typesystem-in-descriptors/reference/TestAnnotator.xml (with props)
uima/uimafit/trunk/uimafit-maven-plugin/src/it/with-typesystem-in-descriptors/src/
uima/uimafit/trunk/uimafit-maven-plugin/src/it/with-typesystem-in-descriptors/src/main/
uima/uimafit/trunk/uimafit-maven-plugin/src/it/with-typesystem-in-descriptors/src/main/java/
uima/uimafit/trunk/uimafit-maven-plugin/src/it/with-typesystem-in-descriptors/src/main/java/AbstractAnnotator.java (with props)
uima/uimafit/trunk/uimafit-maven-plugin/src/it/with-typesystem-in-descriptors/src/main/java/TestAnnotator.java (with props)
uima/uimafit/trunk/uimafit-maven-plugin/src/it/with-typesystem-in-descriptors/src/main/resources/
uima/uimafit/trunk/uimafit-maven-plugin/src/it/with-typesystem-in-descriptors/src/main/resources/META-INF/
uima/uimafit/trunk/uimafit-maven-plugin/src/it/with-typesystem-in-descriptors/src/main/resources/META-INF/org.apache.uima.fit/
uima/uimafit/trunk/uimafit-maven-plugin/src/it/with-typesystem-in-descriptors/src/main/resources/META-INF/org.apache.uima.fit/types.txt (with props)
uima/uimafit/trunk/uimafit-maven-plugin/src/it/with-typesystem-in-descriptors/src/main/resources/org/
uima/uimafit/trunk/uimafit-maven-plugin/src/it/with-typesystem-in-descriptors/src/main/resources/org/apache/
uima/uimafit/trunk/uimafit-maven-plugin/src/it/with-typesystem-in-descriptors/src/main/resources/org/apache/uima/
uima/uimafit/trunk/uimafit-maven-plugin/src/it/with-typesystem-in-descriptors/src/main/resources/org/apache/uima/fit/
uima/uimafit/trunk/uimafit-maven-plugin/src/it/with-typesystem-in-descriptors/src/main/resources/org/apache/uima/fit/type/
uima/uimafit/trunk/uimafit-maven-plugin/src/it/with-typesystem-in-descriptors/src/main/resources/org/apache/uima/fit/type/Sentence.xml (with props)
uima/uimafit/trunk/uimafit-maven-plugin/src/it/with-typesystem-in-descriptors/src/main/resources/org/apache/uima/fit/type/Token.xml (with props)
uima/uimafit/trunk/uimafit-maven-plugin/src/it/with-typesystem-in-descriptors/verify.bsh (with props)
Modified:
uima/uimafit/trunk/uimafit-maven-plugin/src/main/java/org/apache/uima/fit/maven/GenerateDescriptorsMojo.java
Added: uima/uimafit/trunk/uimafit-maven-plugin/src/it/with-typesystem-in-descriptors/pom.xml
URL: http://svn.apache.org/viewvc/uima/uimafit/trunk/uimafit-maven-plugin/src/it/with-typesystem-in-descriptors/pom.xml?rev=1809048&view=auto
==============================================================================
--- uima/uimafit/trunk/uimafit-maven-plugin/src/it/with-typesystem-in-descriptors/pom.xml (added)
+++ uima/uimafit/trunk/uimafit-maven-plugin/src/it/with-typesystem-in-descriptors/pom.xml Wed Sep 20 16:17:18 2017
@@ -0,0 +1,69 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ 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">
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.apache.uima.fit.maven.it</groupId>
+ <artifactId>default</artifactId>
+ <version>1.0-SNAPSHOT</version>
+
+ <name>Test for default configuration</name>
+
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.uima</groupId>
+ <artifactId>uimafit-core</artifactId>
+ <version>@pom.version@</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.uima</groupId>
+ <artifactId>uimafit-maven-plugin</artifactId>
+ <version>@pom.version@</version>
+ <configuration>
+ <componentVendor>Apache UIMA</componentVendor>
+ <componentCopyright>Copyright by the respective authors.</componentCopyright>
+ </configuration>
+ <executions>
+ <execution>
+ <id>default</id>
+ <phase>process-classes</phase>
+ <goals>
+ <goal>enhance</goal>
+ <goal>generate</goal>
+ </goals>
+ <configuration>
+ <addTypeSystemDescriptions>EMBEDDED</addTypeSystemDescriptions>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
Propchange: uima/uimafit/trunk/uimafit-maven-plugin/src/it/with-typesystem-in-descriptors/pom.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: uima/uimafit/trunk/uimafit-maven-plugin/src/it/with-typesystem-in-descriptors/pom.xml
------------------------------------------------------------------------------
svn:mime-type = text/xml
Added: uima/uimafit/trunk/uimafit-maven-plugin/src/it/with-typesystem-in-descriptors/reference/TestAnnotator.xml
URL: http://svn.apache.org/viewvc/uima/uimafit/trunk/uimafit-maven-plugin/src/it/with-typesystem-in-descriptors/reference/TestAnnotator.xml?rev=1809048&view=auto
==============================================================================
--- uima/uimafit/trunk/uimafit-maven-plugin/src/it/with-typesystem-in-descriptors/reference/TestAnnotator.xml (added)
+++ uima/uimafit/trunk/uimafit-maven-plugin/src/it/with-typesystem-in-descriptors/reference/TestAnnotator.xml Wed Sep 20 16:17:18 2017
@@ -0,0 +1,96 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ 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.
+-->
+<analysisEngineDescription xmlns="http://uima.apache.org/resourceSpecifier">
+ <frameworkImplementation>org.apache.uima.java</frameworkImplementation>
+ <primitive>true</primitive>
+ <annotatorImplementationName>TestAnnotator</annotatorImplementationName>
+ <analysisEngineMetaData>
+ <name>TestAnnotator</name>
+ <version>1.0-SNAPSHOT</version>
+ <vendor>Apache UIMA</vendor>
+ <copyright>Copyright by the respective authors.</copyright>
+ <configurationParameters>
+ <configurationParameter>
+ <name>value1</name>
+ <description>Parameter value 1.</description>
+ <type>String</type>
+ <multiValued>false</multiValued>
+ <mandatory>true</mandatory>
+ </configurationParameter>
+ <configurationParameter>
+ <name>valueParent1</name>
+ <description>Parameter value 1 in parent.</description>
+ <type>String</type>
+ <multiValued>false</multiValued>
+ <mandatory>true</mandatory>
+ </configurationParameter>
+ </configurationParameters>
+ <configurationParameterSettings>
+ <nameValuePair>
+ <name>valueParent1</name>
+ <value>
+ <string>defaultValue</string>
+ </value>
+ </nameValuePair>
+ </configurationParameterSettings>
+ <typeSystemDescription>
+ <types>
+ <typeDescription>
+ <name>org.apache.uima.fit.type.Sentence</name>
+ <description/>
+ <supertypeName>uima.tcas.Annotation</supertypeName>
+ </typeDescription>
+ <typeDescription>
+ <name>org.apache.uima.fit.type.Token</name>
+ <description/>
+ <supertypeName>uima.tcas.Annotation</supertypeName>
+ <features>
+ <featureDescription>
+ <name>pos</name>
+ <description/>
+ <rangeTypeName>uima.cas.String</rangeTypeName>
+ </featureDescription>
+ <featureDescription>
+ <name>stem</name>
+ <description/>
+ <rangeTypeName>uima.cas.String</rangeTypeName>
+ </featureDescription>
+ </features>
+ </typeDescription>
+ </types>
+ </typeSystemDescription>
+ <typePriorities/>
+ <fsIndexCollection/>
+ <capabilities/>
+ <operationalProperties>
+ <modifiesCas>true</modifiesCas>
+ <multipleDeploymentAllowed>true</multipleDeploymentAllowed>
+ <outputsNewCASes>false</outputsNewCASes>
+ </operationalProperties>
+ </analysisEngineMetaData>
+ <externalResourceDependencies>
+ <externalResourceDependency>
+ <key>res</key>
+ <description>Documentation for resource</description>
+ <interfaceName>org.apache.uima.resource.Resource</interfaceName>
+ <optional>false</optional>
+ </externalResourceDependency>
+ </externalResourceDependencies>
+</analysisEngineDescription>
Propchange: uima/uimafit/trunk/uimafit-maven-plugin/src/it/with-typesystem-in-descriptors/reference/TestAnnotator.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: uima/uimafit/trunk/uimafit-maven-plugin/src/it/with-typesystem-in-descriptors/reference/TestAnnotator.xml
------------------------------------------------------------------------------
svn:mime-type = text/xml
Added: uima/uimafit/trunk/uimafit-maven-plugin/src/it/with-typesystem-in-descriptors/src/main/java/AbstractAnnotator.java
URL: http://svn.apache.org/viewvc/uima/uimafit/trunk/uimafit-maven-plugin/src/it/with-typesystem-in-descriptors/src/main/java/AbstractAnnotator.java?rev=1809048&view=auto
==============================================================================
--- uima/uimafit/trunk/uimafit-maven-plugin/src/it/with-typesystem-in-descriptors/src/main/java/AbstractAnnotator.java (added)
+++ uima/uimafit/trunk/uimafit-maven-plugin/src/it/with-typesystem-in-descriptors/src/main/java/AbstractAnnotator.java Wed Sep 20 16:17:18 2017
@@ -0,0 +1,33 @@
+/*
+ * 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.
+ */
+import org.apache.uima.analysis_component.JCasAnnotator_ImplBase;
+import org.apache.uima.analysis_engine.AnalysisEngineProcessException;
+import org.apache.uima.fit.descriptor.ConfigurationParameter;
+import org.apache.uima.jcas.JCas;
+
+public abstract class AbstractAnnotator extends JCasAnnotator_ImplBase {
+
+ /**
+ * Parameter value 1 in parent.
+ */
+ public static final String PARAM_VALUE_PARENT_1 = "valueParent1";
+
+ @ConfigurationParameter(name = PARAM_VALUE_PARENT_1, mandatory = true, defaultValue = "defaultValue")
+ private String valueParent1;
+}
Propchange: uima/uimafit/trunk/uimafit-maven-plugin/src/it/with-typesystem-in-descriptors/src/main/java/AbstractAnnotator.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: uima/uimafit/trunk/uimafit-maven-plugin/src/it/with-typesystem-in-descriptors/src/main/java/TestAnnotator.java
URL: http://svn.apache.org/viewvc/uima/uimafit/trunk/uimafit-maven-plugin/src/it/with-typesystem-in-descriptors/src/main/java/TestAnnotator.java?rev=1809048&view=auto
==============================================================================
--- uima/uimafit/trunk/uimafit-maven-plugin/src/it/with-typesystem-in-descriptors/src/main/java/TestAnnotator.java (added)
+++ uima/uimafit/trunk/uimafit-maven-plugin/src/it/with-typesystem-in-descriptors/src/main/java/TestAnnotator.java Wed Sep 20 16:17:18 2017
@@ -0,0 +1,46 @@
+/*
+ * 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.
+ */
+import org.apache.uima.analysis_component.JCasAnnotator_ImplBase;
+import org.apache.uima.analysis_engine.AnalysisEngineProcessException;
+import org.apache.uima.fit.descriptor.ConfigurationParameter;
+import org.apache.uima.fit.descriptor.ExternalResource;
+import org.apache.uima.jcas.JCas;
+import org.apache.uima.resource.Resource;
+
+public class TestAnnotator extends AbstractAnnotator {
+
+ /**
+ * Parameter value 1.
+ */
+ public static final String PARAM_VALUE_1 = "value1";
+ @ConfigurationParameter(name = PARAM_VALUE_1, mandatory=true)
+ private String value1;
+
+ /**
+ * Documentation for resource
+ */
+ public static final String RES_KEY = "res";
+ @ExternalResource(key = RES_KEY)
+ private Resource res;
+
+ @Override
+ public void process(JCas aJCas) throws AnalysisEngineProcessException {
+ // Nothing to do
+ }
+}
Propchange: uima/uimafit/trunk/uimafit-maven-plugin/src/it/with-typesystem-in-descriptors/src/main/java/TestAnnotator.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: uima/uimafit/trunk/uimafit-maven-plugin/src/it/with-typesystem-in-descriptors/src/main/resources/META-INF/org.apache.uima.fit/types.txt
URL: http://svn.apache.org/viewvc/uima/uimafit/trunk/uimafit-maven-plugin/src/it/with-typesystem-in-descriptors/src/main/resources/META-INF/org.apache.uima.fit/types.txt?rev=1809048&view=auto
==============================================================================
--- uima/uimafit/trunk/uimafit-maven-plugin/src/it/with-typesystem-in-descriptors/src/main/resources/META-INF/org.apache.uima.fit/types.txt (added)
+++ uima/uimafit/trunk/uimafit-maven-plugin/src/it/with-typesystem-in-descriptors/src/main/resources/META-INF/org.apache.uima.fit/types.txt Wed Sep 20 16:17:18 2017
@@ -0,0 +1 @@
+classpath*:org/apache/uima/fit/type/**/*.xml
Propchange: uima/uimafit/trunk/uimafit-maven-plugin/src/it/with-typesystem-in-descriptors/src/main/resources/META-INF/org.apache.uima.fit/types.txt
------------------------------------------------------------------------------
svn:eol-style = native
Added: uima/uimafit/trunk/uimafit-maven-plugin/src/it/with-typesystem-in-descriptors/src/main/resources/org/apache/uima/fit/type/Sentence.xml
URL: http://svn.apache.org/viewvc/uima/uimafit/trunk/uimafit-maven-plugin/src/it/with-typesystem-in-descriptors/src/main/resources/org/apache/uima/fit/type/Sentence.xml?rev=1809048&view=auto
==============================================================================
--- uima/uimafit/trunk/uimafit-maven-plugin/src/it/with-typesystem-in-descriptors/src/main/resources/org/apache/uima/fit/type/Sentence.xml (added)
+++ uima/uimafit/trunk/uimafit-maven-plugin/src/it/with-typesystem-in-descriptors/src/main/resources/org/apache/uima/fit/type/Sentence.xml Wed Sep 20 16:17:18 2017
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+<typeSystemDescription xmlns="http://uima.apache.org/resourceSpecifier">
+ <name>Sentence</name>
+ <description></description>
+ <version>1.0</version>
+ <vendor/>
+ <types>
+ <typeDescription>
+ <name>org.apache.uima.fit.type.Sentence</name>
+ <description/>
+ <supertypeName>uima.tcas.Annotation</supertypeName>
+ </typeDescription>
+ </types>
+</typeSystemDescription>
Propchange: uima/uimafit/trunk/uimafit-maven-plugin/src/it/with-typesystem-in-descriptors/src/main/resources/org/apache/uima/fit/type/Sentence.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: uima/uimafit/trunk/uimafit-maven-plugin/src/it/with-typesystem-in-descriptors/src/main/resources/org/apache/uima/fit/type/Sentence.xml
------------------------------------------------------------------------------
svn:mime-type = text/xml
Added: uima/uimafit/trunk/uimafit-maven-plugin/src/it/with-typesystem-in-descriptors/src/main/resources/org/apache/uima/fit/type/Token.xml
URL: http://svn.apache.org/viewvc/uima/uimafit/trunk/uimafit-maven-plugin/src/it/with-typesystem-in-descriptors/src/main/resources/org/apache/uima/fit/type/Token.xml?rev=1809048&view=auto
==============================================================================
--- uima/uimafit/trunk/uimafit-maven-plugin/src/it/with-typesystem-in-descriptors/src/main/resources/org/apache/uima/fit/type/Token.xml (added)
+++ uima/uimafit/trunk/uimafit-maven-plugin/src/it/with-typesystem-in-descriptors/src/main/resources/org/apache/uima/fit/type/Token.xml Wed Sep 20 16:17:18 2017
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+<typeSystemDescription xmlns="http://uima.apache.org/resourceSpecifier">
+ <name>Token</name>
+ <description></description>
+ <version>1.0</version>
+ <vendor/>
+ <types>
+ <typeDescription>
+ <name>org.apache.uima.fit.type.Token</name>
+ <description/>
+ <supertypeName>uima.tcas.Annotation</supertypeName>
+ <features>
+ <featureDescription>
+ <name>pos</name>
+ <description/>
+ <rangeTypeName>uima.cas.String</rangeTypeName>
+ </featureDescription>
+ <featureDescription>
+ <name>stem</name>
+ <description/>
+ <rangeTypeName>uima.cas.String</rangeTypeName>
+ </featureDescription>
+ </features>
+ </typeDescription>
+ </types>
+</typeSystemDescription>
Propchange: uima/uimafit/trunk/uimafit-maven-plugin/src/it/with-typesystem-in-descriptors/src/main/resources/org/apache/uima/fit/type/Token.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: uima/uimafit/trunk/uimafit-maven-plugin/src/it/with-typesystem-in-descriptors/src/main/resources/org/apache/uima/fit/type/Token.xml
------------------------------------------------------------------------------
svn:mime-type = text/xml
Added: uima/uimafit/trunk/uimafit-maven-plugin/src/it/with-typesystem-in-descriptors/verify.bsh
URL: http://svn.apache.org/viewvc/uima/uimafit/trunk/uimafit-maven-plugin/src/it/with-typesystem-in-descriptors/verify.bsh?rev=1809048&view=auto
==============================================================================
--- uima/uimafit/trunk/uimafit-maven-plugin/src/it/with-typesystem-in-descriptors/verify.bsh (added)
+++ uima/uimafit/trunk/uimafit-maven-plugin/src/it/with-typesystem-in-descriptors/verify.bsh Wed Sep 20 16:17:18 2017
@@ -0,0 +1,50 @@
+/*
+ * 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.
+ */
+
+import java.io.*;
+import java.util.*;
+import java.util.regex.*;
+import org.apache.commons.io.*;
+import org.custommonkey.xmlunit.Diff;
+import org.custommonkey.xmlunit.XMLUnit;
+
+try
+{
+ String reference = IOUtils.toString(new File(basedir,
+ "reference/TestAnnotator.xml").toURI().toURL());
+ String actual = IOUtils.toString(new File(basedir,
+ "target/classes/TestAnnotator.xml").toURI().toURL());
+
+ // In a local build, I get indented XML but on the Apache Jenkins I get non-indented XML. This
+ // settings tells XMLUnit to ignore this difference in whitespace - rec 2013-02-16
+ XMLUnit.setIgnoreWhitespace(true);
+ Diff diff = XMLUnit.compareXML(reference, actual);
+
+ if (!diff.identical()) {
+ System.out.println("Actual descriptor does not match expected descriptor: " + diff);
+ return false;
+ }
+}
+catch( Throwable t )
+{
+ t.printStackTrace();
+ return false;
+}
+
+return true;
Propchange: uima/uimafit/trunk/uimafit-maven-plugin/src/it/with-typesystem-in-descriptors/verify.bsh
------------------------------------------------------------------------------
svn:eol-style = native
Modified: uima/uimafit/trunk/uimafit-maven-plugin/src/main/java/org/apache/uima/fit/maven/GenerateDescriptorsMojo.java
URL: http://svn.apache.org/viewvc/uima/uimafit/trunk/uimafit-maven-plugin/src/main/java/org/apache/uima/fit/maven/GenerateDescriptorsMojo.java?rev=1809048&r1=1809047&r2=1809048&view=diff
==============================================================================
--- uima/uimafit/trunk/uimafit-maven-plugin/src/main/java/org/apache/uima/fit/maven/GenerateDescriptorsMojo.java (original)
+++ uima/uimafit/trunk/uimafit-maven-plugin/src/main/java/org/apache/uima/fit/maven/GenerateDescriptorsMojo.java Wed Sep 20 16:17:18 2017
@@ -23,7 +23,6 @@ import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.lang.reflect.Modifier;
-
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang.exception.ExceptionUtils;
import org.apache.maven.plugin.AbstractMojo;
@@ -34,12 +33,17 @@ import org.apache.maven.plugins.annotati
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.plugins.annotations.ResolutionScope;
import org.apache.maven.project.MavenProject;
+import org.apache.uima.analysis_engine.AnalysisEngineDescription;
+import org.apache.uima.collection.CollectionReaderDescription;
import org.apache.uima.fit.factory.AnalysisEngineFactory;
import org.apache.uima.fit.factory.CollectionReaderFactory;
+import org.apache.uima.fit.factory.TypeSystemDescriptionFactory;
import org.apache.uima.fit.maven.util.Util;
import org.apache.uima.resource.ResourceCreationSpecifier;
import org.apache.uima.resource.ResourceInitializationException;
import org.apache.uima.resource.ResourceSpecifier;
+import org.apache.uima.resource.metadata.ProcessingResourceMetaData;
+import org.apache.uima.resource.metadata.TypeSystemDescription;
import org.codehaus.plexus.util.FileUtils;
import org.sonatype.plexus.build.incremental.BuildContext;
import org.xml.sax.SAXException;
@@ -60,7 +64,7 @@ public class GenerateDescriptorsMojo ext
/**
* Path where the generated resources are written.
*/
- @Parameter(defaultValue="${project.build.directory}/classes", required=true)
+ @Parameter(defaultValue = "${project.build.directory}/classes", required = true)
private File outputDirectory;
/**
@@ -75,6 +79,17 @@ public class GenerateDescriptorsMojo ext
@Parameter(defaultValue = "${project.build.sourceEncoding}", required = true)
private String encoding;
+ enum TypeSystemSerialization {
+ NONE, EMBEDDED
+ }
+
+ /**
+ * Mode of adding type systems found on the classpath via the uimaFIT detection mechanism at
+ * compile time to the generated descriptor. By default, no type systems are added.
+ */
+ @Parameter(defaultValue = "NONE")
+ private TypeSystemSerialization addTypeSystemDescriptions;
+
@Override
public void execute() throws MojoExecutionException {
// add the generated sources to the build
@@ -106,24 +121,39 @@ public class GenerateDescriptorsMojo ext
}
ResourceCreationSpecifier desc = null;
+ ProcessingResourceMetaData metadata = null;
switch (Util.getType(componentLoader, clazz)) {
case ANALYSIS_ENGINE:
- desc = AnalysisEngineFactory.createEngineDescription(clazz);
+ AnalysisEngineDescription aeDesc = AnalysisEngineFactory.createEngineDescription(clazz);
+ metadata = aeDesc.getAnalysisEngineMetaData();
+ desc = aeDesc;
break;
case COLLECTION_READER:
- desc = CollectionReaderFactory.createReaderDescription(clazz);
+ CollectionReaderDescription crDesc = CollectionReaderFactory
+ .createReaderDescription(clazz);
+ metadata = crDesc.getCollectionReaderMetaData();
+ desc = crDesc;
default:
// Do nothing
}
if (desc != null) {
- File out = new File(outputDirectory, clazzPath+".xml");
+ switch (addTypeSystemDescriptions) {
+ case EMBEDDED:
+ embedTypeSystems(metadata);
+ break;
+ case NONE: // fall-through
+ default:
+ // Do nothing
+ }
+
+ File out = new File(outputDirectory, clazzPath + ".xml");
out.getParentFile().mkdirs();
toXML(desc, out.getPath());
countGenerated++;
// Remember component
- componentsManifest.append("classpath*:").append(clazzPath+".xml").append('\n');
+ componentsManifest.append("classpath*:").append(clazzPath + ".xml").append('\n');
}
} catch (SAXException e) {
getLog().warn("Cannot serialize descriptor for [" + clazzName + "]", e);
@@ -153,6 +183,19 @@ public class GenerateDescriptorsMojo ext
}
}
+ private void embedTypeSystems(ProcessingResourceMetaData metadata)
+ throws ResourceInitializationException {
+ ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
+ Thread.currentThread().setContextClassLoader(componentLoader);
+ try {
+ TypeSystemDescriptionFactory.forceTypeDescriptorsScan();
+ TypeSystemDescription tsDesc = TypeSystemDescriptionFactory.createTypeSystemDescription();
+ metadata.setTypeSystem(tsDesc);
+ } finally {
+ Thread.currentThread().setContextClassLoader(classLoader);
+ }
+ }
+
/**
* Save descriptor XML to file system.
*/