You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tika.apache.org by ta...@apache.org on 2020/12/04 20:24:06 UTC

[tika] branch main updated: TIKA-3178 -- allow for other bundles in the future

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

tallison pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tika.git


The following commit(s) were added to refs/heads/main by this push:
     new 3173e12  TIKA-3178 -- allow for other bundles in the future
3173e12 is described below

commit 3173e12b40ead8065db6053118af23699c7748d9
Author: tallison <ta...@apache.org>
AuthorDate: Fri Dec 4 15:23:45 2020 -0500

    TIKA-3178 -- allow for other bundles in the future
---
 pom.xml                                            |   2 +-
 tika-bundles/pom.xml                               |  21 ++++++++
 .../tika-bundle-classic}/pom.xml                   |  44 ++++-------------
 .../src/main/appended-resources/META-INF/LICENSE   |   0
 .../src/main/resources/META-INF/MANIFEST.MF        |   0
 .../test/java/org/apache/tika/bundle/BundleIT.java |  39 ++++++++-------
 .../src/test/resources/log4j.properties            |   0
 .../src/test/resources/test-documents.zip          | Bin
 .../src/test/resources/testOCR.jpg                 | Bin
 .../src/test/resources/testPPT.pptx                | Bin
 .../tika-bundle-classic}/test-bundles.xml          |   2 +-
 tika-parsers/pom.xml                               |   6 +--
 .../org/apache/tika/parser/internal/Activator.java |  54 ---------------------
 13 files changed, 57 insertions(+), 111 deletions(-)

diff --git a/pom.xml b/pom.xml
index 30a3821..87328c4 100644
--- a/pom.xml
+++ b/pom.xml
@@ -38,7 +38,7 @@
     <module>tika-parent</module>
     <module>tika-core</module>
     <module>tika-parsers</module>
-    <module>tika-bundle</module>
+    <module>tika-bundles</module>
     <module>tika-xmp</module>
     <module>tika-serialization</module>
     <module>tika-batch</module>
diff --git a/tika-bundles/pom.xml b/tika-bundles/pom.xml
new file mode 100644
index 0000000..915f2c1
--- /dev/null
+++ b/tika-bundles/pom.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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">
+    <parent>
+        <artifactId>tika-parent</artifactId>
+        <groupId>org.apache.tika</groupId>
+        <version>2.0.0-SNAPSHOT</version>
+        <relativePath>../tika-parent/pom.xml</relativePath>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+
+    <artifactId>tika-bundles</artifactId>
+    <version>2.0.0-SNAPSHOT</version>
+
+    <packaging>pom</packaging>
+
+    <modules>
+        <module>tika-bundle-classic</module>
+    </modules>
+</project>
\ No newline at end of file
diff --git a/tika-bundle/pom.xml b/tika-bundles/tika-bundle-classic/pom.xml
similarity index 93%
rename from tika-bundle/pom.xml
rename to tika-bundles/tika-bundle-classic/pom.xml
index dc5d9cf..ab31e2b 100644
--- a/tika-bundle/pom.xml
+++ b/tika-bundles/tika-bundle-classic/pom.xml
@@ -22,16 +22,18 @@
 
   <parent>
     <groupId>org.apache.tika</groupId>
-    <artifactId>tika-parent</artifactId>
+    <artifactId>tika-bundles</artifactId>
     <version>2.0.0-SNAPSHOT</version>
-    <relativePath>../tika-parent/pom.xml</relativePath>
+    <relativePath>../pom.xml</relativePath>
   </parent>
 
-  <artifactId>tika-bundle</artifactId>
+  <artifactId>tika-bundle-classic</artifactId>
+  <version>2.0.0-SNAPSHOT</version>
   <packaging>bundle</packaging>
-  <name>Apache Tika OSGi bundle</name>
+  <name>Apache Tika OSGi classic bundle</name>
+
   <description>
-    OSGi bundle that contains the tika-parsers component and all its
+    OSGi bundle that contains the tika-parsers-classic component and all its
     upstream dependencies that aren't OSGI bundles by themselves. This
     bundle exports no packages, only the Parser and Detector services
     from the tika-parsers component.
@@ -178,6 +180,7 @@
               org.apache.tika.parser.internal.Activator
             </Bundle-Activator>
             <Embed-Dependency>*;scope=compile;artifactId=tika-parsers-classic-package|
+              xerces|
               commons-compress|
               xz|
               commons-codec|
@@ -246,16 +249,13 @@
             <Export-Package>
               !org.apache.tika.parser,
               !org.apache.tika.parser.external,
-              org.apache.tika.parser.*,
-              org.apache.tika.exception,
-              org.apache.tika.fork,
-              org.apache.tika.io,
-              org.apache.tika.metadata.serialization.*,
+              org.apache.tika.parser.*
             </Export-Package>
             <Import-Package>
               !org.junit,
               !org.junit.*,
               !junit.*,
+              org.apache.tika.detect,
               org.apache.tika.mime,
               org.apache.tika.fork,
               android.util;resolution:=optional,
@@ -392,30 +392,6 @@
           <createDependencyReducedPom>true</createDependencyReducedPom>
         </configuration>
       </plugin>
-      <!-- TIKA-763: Workaround to avoid including LGPL classes -->
-      <plugin>
-        <artifactId>maven-dependency-plugin</artifactId>
-        <executions>
-          <execution>
-            <phase>prepare-package</phase>
-            <goals>
-              <goal>unpack-dependencies</goal>
-            </goals>
-            <configuration>
-              <includeArtifactIds>netcdf</includeArtifactIds>
-              <excludes>
-                ucar/nc2/iosp/fysat/Fysat*.class,
-                ucar/nc2/dataset/transform/VOceanSG1*class,
-                ucar/unidata/geoloc/vertical/OceanSG*.class,
-                META-INF/**,CHANGES,README
-              </excludes>
-              <outputDirectory>
-                ${project.build.directory}/classes
-              </outputDirectory>
-            </configuration>
-          </execution>
-        </executions>
-      </plugin>
 
       <!-- The Tika Bundle has no java code of its own, so no need to do -->
       <!--  any forbidden API checking against it (it gets confused...) -->
diff --git a/tika-bundle/src/main/appended-resources/META-INF/LICENSE b/tika-bundles/tika-bundle-classic/src/main/appended-resources/META-INF/LICENSE
similarity index 100%
rename from tika-bundle/src/main/appended-resources/META-INF/LICENSE
rename to tika-bundles/tika-bundle-classic/src/main/appended-resources/META-INF/LICENSE
diff --git a/tika-bundle/src/main/resources/META-INF/MANIFEST.MF b/tika-bundles/tika-bundle-classic/src/main/resources/META-INF/MANIFEST.MF
similarity index 100%
rename from tika-bundle/src/main/resources/META-INF/MANIFEST.MF
rename to tika-bundles/tika-bundle-classic/src/main/resources/META-INF/MANIFEST.MF
diff --git a/tika-bundle/src/test/java/org/apache/tika/bundle/BundleIT.java b/tika-bundles/tika-bundle-classic/src/test/java/org/apache/tika/bundle/BundleIT.java
similarity index 92%
rename from tika-bundle/src/test/java/org/apache/tika/bundle/BundleIT.java
rename to tika-bundles/tika-bundle-classic/src/test/java/org/apache/tika/bundle/BundleIT.java
index 4f18eae..7d066c4 100644
--- a/tika-bundle/src/test/java/org/apache/tika/bundle/BundleIT.java
+++ b/tika-bundles/tika-bundle-classic/src/test/java/org/apache/tika/bundle/BundleIT.java
@@ -77,9 +77,9 @@ import org.xml.sax.SAXException;
 @RunWith(PaxExam.class)
 @ExamReactorStrategy(PerMethod.class)
 public class BundleIT {
-	
-	private final File TARGET = new File("target");
-	
+
+    private final File TARGET = new File("target");
+
     @Inject
     private Parser defaultParser;
 
@@ -91,15 +91,18 @@ public class BundleIT {
 
     @Configuration
     public Option[] configuration() throws IOException, URISyntaxException, ClassNotFoundException {
-    	File base = new File(TARGET, "test-bundles");
-    	 return options(
-         		systemPackages("javax.xml.bind"),
-         		bundle(new File(base, "tika-core.jar").toURI().toURL().toString()),
-         		mavenBundle("org.ops4j.pax.logging", "pax-logging-api", "1.8.5"),
-         		mavenBundle("org.ops4j.pax.logging", "pax-logging-service", "1.8.5"),
-         		junitBundles(),
-         		bundle(new File(base, "tika-bundle.jar").toURI().toURL().toString())
-                 );
+        File base = new File(TARGET, "test-bundles");
+        return options(
+                systemPackages("javax.xml.bind"),
+                bundle(new File(base, "tika-core.jar").toURI().toURL().toString()),
+                //I couldn't find a way to get the build of bundle to work via imports
+                //for this one
+                mavenBundle("commons-io", "commons-io", "2.8.0"),
+                mavenBundle("org.ops4j.pax.logging", "pax-logging-api", "1.8.5"),
+                mavenBundle("org.ops4j.pax.logging", "pax-logging-service", "1.8.5"),
+                junitBundles(),
+                bundle(new File(base, "tika-bundle-classic.jar").toURI().toURL().toString())
+        );
     }
 
     @Test
@@ -110,7 +113,7 @@ public class BundleIT {
                 hasCore = true;
                 assertEquals("Core not activated", Bundle.ACTIVE, b.getState());
             }
-            if ("org.apache.tika.bundle".equals(b.getSymbolicName())) {
+            if ("org.apache.tika.bundle-classic".equals(b.getSymbolicName())) {
                 hasBundle = true;
                 assertEquals("Bundle not activated", Bundle.ACTIVE, b.getState());
             }
@@ -123,7 +126,7 @@ public class BundleIT {
     public void testManifestNoJUnit() throws Exception {
         File TARGET = new File("target");
         File base = new File(TARGET, "test-bundles");
-        File tikaBundle = new File(base, "tika-bundle.jar");
+        File tikaBundle = new File(base, "tika-bundle-classic.jar");
 
         JarInputStream jarIs = new JarInputStream(new FileInputStream(tikaBundle));
         Manifest mf = jarIs.getManifest();
@@ -210,7 +213,7 @@ public class BundleIT {
                 }
             } else {
                 //TODO: figure out how to get this loaded correctly from tika-core
-                if (! d.getClass().getName().equals("org.apache.tika.detect.OverrideDetector")) {
+                if (!d.getClass().getName().equals("org.apache.tika.detect.OverrideDetector")) {
                     rawDetectors.add(d.getClass().getName());
                 }
             }
@@ -294,7 +297,7 @@ public class BundleIT {
         assertTrue(content.contains("testXML.xml"));
         assertTrue(content.contains("Rida Benjelloun"));
     }
-    
+
     @Test
     public void testPoiTikaBundle() throws Exception {
         Tika tika = new Tika();
@@ -335,7 +338,7 @@ public class BundleIT {
             if (needToFix.contains(f.getName())) {
                 continue;
             }
-            System.out.println("about to parse "+f);
+            System.out.println("about to parse " + f);
             Metadata metadata = new Metadata();
             try (InputStream is = TikaInputStream.get(f)) {
                 parser.parse(is, handler, metadata, context);
@@ -344,7 +347,7 @@ public class BundleIT {
             } catch (SAXException e) {
                 //
             } catch (TikaException e) {
-                System.err.println("tika Exception "+f.getName());
+                System.err.println("tika Exception " + f.getName());
                 e.printStackTrace();
             }
         }
diff --git a/tika-bundle/src/test/resources/log4j.properties b/tika-bundles/tika-bundle-classic/src/test/resources/log4j.properties
similarity index 100%
rename from tika-bundle/src/test/resources/log4j.properties
rename to tika-bundles/tika-bundle-classic/src/test/resources/log4j.properties
diff --git a/tika-bundle/src/test/resources/test-documents.zip b/tika-bundles/tika-bundle-classic/src/test/resources/test-documents.zip
similarity index 100%
rename from tika-bundle/src/test/resources/test-documents.zip
rename to tika-bundles/tika-bundle-classic/src/test/resources/test-documents.zip
diff --git a/tika-bundle/src/test/resources/testOCR.jpg b/tika-bundles/tika-bundle-classic/src/test/resources/testOCR.jpg
similarity index 100%
rename from tika-bundle/src/test/resources/testOCR.jpg
rename to tika-bundles/tika-bundle-classic/src/test/resources/testOCR.jpg
diff --git a/tika-bundle/src/test/resources/testPPT.pptx b/tika-bundles/tika-bundle-classic/src/test/resources/testPPT.pptx
similarity index 100%
rename from tika-bundle/src/test/resources/testPPT.pptx
rename to tika-bundles/tika-bundle-classic/src/test/resources/testPPT.pptx
diff --git a/tika-bundle/test-bundles.xml b/tika-bundles/tika-bundle-classic/test-bundles.xml
similarity index 97%
rename from tika-bundle/test-bundles.xml
rename to tika-bundles/tika-bundle-classic/test-bundles.xml
index ce93f91..6038728 100644
--- a/tika-bundle/test-bundles.xml
+++ b/tika-bundles/tika-bundle-classic/test-bundles.xml
@@ -28,7 +28,7 @@
       <outputFileNameMapping>${artifact.artifactId}.jar</outputFileNameMapping>
       <includes>
         <include>org.apache.tika:tika-core</include>
-        <include>org.apache.tika:tika-bundle</include>
+        <include>org.apache.tika:tika-bundle-classic</include>
       </includes>
     </dependencySet>
     <dependencySet>
diff --git a/tika-parsers/pom.xml b/tika-parsers/pom.xml
index acb63fb..582a9d6 100644
--- a/tika-parsers/pom.xml
+++ b/tika-parsers/pom.xml
@@ -36,9 +36,9 @@
         <!-- basic parsers - avoid network dependent parsers, native code -->
         <module>tika-parsers-classic</module>
         <!-- allow network dependent parsers and native code  -->
-        <module>tika-parsers-extended</module>
-        <!-- potentially massive dependencies (e.g. dl4j)  -->
-        <module>tika-parsers-advanced</module>
+        <!--<module>tika-parsers-extended</module>
+        < ! - -  potentially massive dependencies (e.g. dl4j)   - - >
+        <module>tika-parsers-advanced</module> -->
     </modules>
 
 </project>
\ No newline at end of file
diff --git a/tika-parsers/src/main/java/org/apache/tika/parser/internal/Activator.java b/tika-parsers/src/main/java/org/apache/tika/parser/internal/Activator.java
deleted file mode 100644
index b436dd6..0000000
--- a/tika-parsers/src/main/java/org/apache/tika/parser/internal/Activator.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * 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.tika.parser.internal;
-
-import org.apache.tika.detect.DefaultDetector;
-import org.apache.tika.detect.Detector;
-import org.apache.tika.parser.DefaultParser;
-import org.apache.tika.parser.Parser;
-import org.osgi.framework.BundleActivator;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceRegistration;
-
-import java.util.Hashtable;
-
-public class Activator implements BundleActivator {
-
-    private ServiceRegistration detectorService;
-
-    private ServiceRegistration parserService;
-
-    @Override
-    public void start(BundleContext context) throws Exception {
-        detectorService = context.registerService(
-                Detector.class.getName(),
-                new DefaultDetector(Activator.class.getClassLoader()),
-                new Hashtable<>());
-        Parser parser = new DefaultParser(Activator.class.getClassLoader());
-        parserService = context.registerService(
-                Parser.class.getName(),
-                parser,
-                new Hashtable<>());
-    }
-
-    @Override
-    public void stop(BundleContext context) throws Exception {
-        parserService.unregister();
-        detectorService.unregister();
-    }
-
-}