[bug-62730] include all inner list classes in poi-ooxml-schemas.jar

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1841270 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
PJ Fanning 2018-09-18 22:09:15 +00:00
parent a7968aa5a0
commit 81a250495f
3 changed files with 47 additions and 9 deletions

View File

@ -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 {

View File

@ -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">

View File

@ -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)) {