You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by fa...@apache.org on 2018/09/18 22:09:15 UTC

svn commit: r1841270 - in /poi/trunk: ./ build.gradle build.xml src/ooxml/testcases/org/apache/poi/ooxml/util/OOXMLLite.java

Author: fanningpj
Date: Tue Sep 18 22:09:15 2018
New Revision: 1841270

URL: http://svn.apache.org/viewvc?rev=1841270&view=rev
Log:
[bug-62730] include all inner list classes in poi-ooxml-schemas.jar

Modified:
    poi/trunk/   (props changed)
    poi/trunk/build.gradle
    poi/trunk/build.xml
    poi/trunk/src/ooxml/testcases/org/apache/poi/ooxml/util/OOXMLLite.java

Propchange: poi/trunk/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Tue Sep 18 22:09:15 2018
@@ -1,26 +1 @@
-classes
-workbook.xls
-bak
-*.iws
-build.number
-*.el
-TEST-org.apache.poi*.xml
-build
-.settings
-scripts
-*.ipr
-untitled1.jpx
-*.iml
-log*.*
-dist
-*.log
-bin
-.ant-targets-build.xml
-out
-.idea
-.gradle
-gradle
-gradlew
-gradlew.bat
-tmp
-
+ooxml-testlib

Modified: poi/trunk/build.gradle
URL: http://svn.apache.org/viewvc/poi/trunk/build.gradle?rev=1841270&r1=1841269&r2=1841270&view=diff
==============================================================================
--- poi/trunk/build.gradle (original)
+++ poi/trunk/build.gradle Tue Sep 18 22:09:15 2018
@@ -187,6 +187,7 @@ project('main') {
         compile 'javax.activation:activation:1.1.1'
 
         testCompile 'junit:junit:4.12'
+        testCompile 'org.reflections:reflections:0.9.11'
     }
 
     jar {

Modified: poi/trunk/build.xml
URL: http://svn.apache.org/viewvc/poi/trunk/build.xml?rev=1841270&r1=1841269&r2=1841270&view=diff
==============================================================================
--- poi/trunk/build.xml (original)
+++ poi/trunk/build.xml Tue Sep 18 22:09:15 2018
@@ -52,6 +52,7 @@ under the License.
 
     <property name="main.lib" location="lib"/>
     <property name="ooxml.lib" location="ooxml-lib"/>
+    <property name="ooxml.test.lib" location="ooxml-testlib"/>
     <property name="compile.lib" location="compile-lib"/>
 
     <!-- compiler options options -->
@@ -208,7 +209,7 @@ under the License.
     <property name="dsig.sl4j-api.jar" location="${compile.lib}/slf4j-api-1.7.25.jar"/>
     <property name="dsig.sl4j-api.url" value="${repository.m2}/maven2/org/slf4j/slf4j-api/1.7.25/slf4j-api-1.7.25.jar"/>
 
-    <!-- jars in the lib-ooxml directory, see the fetch-ooxml-jars target-->
+    <!-- jars in the ooxml-lib directory, see the fetch-ooxml-jars target-->
     <property name="ooxml.curvesapi.jar" location="${ooxml.lib}/curvesapi-1.05.jar"/>
     <property name="ooxml.curvesapi.url"
               value="${repository.m2}/maven2/com/github/virtuald/curvesapi/1.05/curvesapi-1.05.jar"/>
@@ -219,6 +220,17 @@ under the License.
     <property name="ooxml.commons-compress.url"
               value="${repository.m2}/maven2/org/apache/commons/commons-compress/1.18/commons-compress-1.18.jar"/>
 
+    <!-- jars in the ooxml-test-lib directory, see the fetch-ooxml-jars target-->
+    <property name="ooxml.test.reflections.jar" location="${ooxml.test.lib}/reflections.jar"/>
+    <property name="ooxml.test.reflections.url"
+              value="${repository.m2}/maven2/org/reflections/reflections/0.9.11/reflections-0.9.11.jar"/>
+    <property name="ooxml.test.guava.jar" location="${ooxml.test.lib}/guava.jar"/>
+    <property name="ooxml.test.guava.url"
+              value="${repository.m2}/maven2/com/google/guava/guava/20.0/guava-20.0.jar"/>
+    <property name="ooxml.test.javassist.jar" location="${ooxml.test.lib}/javassist.jar"/>
+    <property name="ooxml.test.javassist.url"
+              value="${repository.m2}/maven2/org/javassist/javassist/3.21.0-GA/javassist-3.21.0-GA.jar"/>
+
     <!-- coverage libs -->
     <property name="jacoco.zip" location="${main.lib}/jacoco-0.8.2.zip"/>
     <property name="jacoco.url" value="${repository.m2}/maven2/org/jacoco/jacoco/0.8.2/jacoco-0.8.2.zip"/>
@@ -420,6 +432,9 @@ under the License.
         <path refid="ooxml.classpath"/>
         <path refid="ooxml.xmlsec.classpath"/>
         <path refid="test.jar.classpath"/>
+        <pathelement location="${ooxml.test.reflections.jar}"/>
+        <pathelement location="${ooxml.test.guava.jar}"/>
+        <pathelement location="${ooxml.test.javassist.jar}"/>
         <pathelement location="${ooxml.output.dir}"/>
         <pathelement location="${ooxml.output.test.dir}"/>
         <pathelement location="${main.output.test.dir}"/>
@@ -582,6 +597,7 @@ under the License.
         <mkdir dir="${main.lib}"/>
         <mkdir dir="${compile.lib}"/>
         <mkdir dir="${ooxml.lib}"/>
+        <mkdir dir="${ooxml.test.lib}"/>
         <delete verbose="true">
             <fileset dir="${main.lib}">
                 <include name="ant-1.8*"/>
@@ -753,6 +769,9 @@ under the License.
                     <available file="${ooxml.curvesapi.jar}"/>
                     <available file="${ooxml.xmlbeans.jar}"/>
                     <available file="${ooxml.commons-compress.jar}"/>
+                    <available file="${ooxml.test.reflections.jar}"/>
+                    <available file="${ooxml.test.guava.jar}"/>
+                    <available file="${ooxml.test.javassist.jar}"/>
                 </and>
                 <isset property="disconnected"/>
             </or>
@@ -760,9 +779,13 @@ under the License.
     </target>
     <target name="fetch-ooxml-jars" depends="check-ooxml-jars" unless="ooxml.jars.present">
         <mkdir dir="${ooxml.lib}"/>
+        <mkdir dir="${ooxml.test.lib}"/>
         <downloadfile src="${ooxml.curvesapi.url}" dest="${ooxml.curvesapi.jar}"/>
         <downloadfile src="${ooxml.xmlbeans.url}" dest="${ooxml.xmlbeans.jar}"/>
         <downloadfile src="${ooxml.commons-compress.url}" dest="${ooxml.commons-compress.jar}"/>
+        <downloadfile src="${ooxml.test.reflections.url}" dest="${ooxml.test.reflections.jar}"/>
+        <downloadfile src="${ooxml.test.guava.url}" dest="${ooxml.test.guava.jar}"/>
+        <downloadfile src="${ooxml.test.javassist.url}" dest="${ooxml.test.javassist.jar}"/>
     </target>
     <target name="check-svn-jars">
         <condition property="svn.jars.present">

Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/ooxml/util/OOXMLLite.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/ooxml/util/OOXMLLite.java?rev=1841270&r1=1841269&r2=1841270&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/ooxml/util/OOXMLLite.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/ooxml/util/OOXMLLite.java Tue Sep 18 22:09:15 2018
@@ -48,6 +48,7 @@ import org.junit.internal.TextListener;
 import org.junit.runner.Description;
 import org.junit.runner.JUnitCore;
 import org.junit.runner.Result;
+import org.reflections.Reflections;
 
 /**
  * Build a 'lite' version of the ooxml-schemas.jar
@@ -194,19 +195,25 @@ public final class OOXMLLite {
         //see what classes from the ooxml-schemas.jar are loaded
         System.out.println("Copying classes to " + _destDest);
         Map<String, Class<?>> classes = getLoadedClasses(_ooxmlJar.getName());
+        Set<String> packages = new HashSet<>();
         for (Class<?> cls : classes.values()) {
-            String className = cls.getName();
-            String classRef = className.replace('.', '/') + ".class";
-            File destFile = new File(_destDest, classRef);
-            IOUtils.copy(cls.getResourceAsStream('/' + classRef), destFile);
+            copyFile(cls);
+            packages.add(cls.getPackage().getName());
 
             if(cls.isInterface()){
                 /// Copy classes and interfaces declared as members of this class
                 for(Class<?> fc : cls.getDeclaredClasses()){
-                    className = fc.getName();
-                    classRef = className.replace('.', '/') + ".class";
-                    destFile = new File(_destDest, classRef);
-                    IOUtils.copy(fc.getResourceAsStream('/' + classRef), destFile);
+                    copyFile(fc);
+                }
+            }
+        }
+        for (String pkg : packages) {
+            Reflections reflections = new Reflections(pkg);
+            for (Class listClass : reflections.getSubTypesOf(List.class)) {
+                for (Class<?> compare : classes.values()){
+                    if (listClass.getName().startsWith(compare.getName())) {
+                        copyFile(listClass);
+                    }
                 }
             }
         }
@@ -224,6 +231,13 @@ public final class OOXMLLite {
         }
     }
 
+    private void copyFile(Class<?> cls) throws IOException {
+        String className = cls.getName();
+        String classRef = className.replace('.', '/') + ".class";
+        File destFile = new File(_destDest, classRef);
+        IOUtils.copy(cls.getResourceAsStream('/' + classRef), destFile);
+    }
+
     private static boolean checkForTestAnnotation(Class<?> testclass) {
         for (Method m : testclass.getDeclaredMethods()) {
             if(m.isAnnotationPresent(Test.class)) {



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org