From 4166350488e31b421deb4b01f48763bd93938e10 Mon Sep 17 00:00:00 2001 From: PJ Fanning Date: Fri, 11 Jul 2025 13:05:52 +0100 Subject: [PATCH] try to remove batik-script build hack (#839) * try to remove batik-script build hack * Update build.gradle * Update build.gradle --- poi-ooxml/build.gradle | 42 ++++++++++-------------------------------- 1 file changed, 10 insertions(+), 32 deletions(-) diff --git a/poi-ooxml/build.gradle b/poi-ooxml/build.gradle index a09056cfdb..8a9309799b 100644 --- a/poi-ooxml/build.gradle +++ b/poi-ooxml/build.gradle @@ -28,7 +28,6 @@ configurations { exclude group: 'xml-apis', module: 'xml-apis' } - broken tests javadocs } @@ -89,6 +88,10 @@ dependencies { exclude group: 'xalan', module: 'xalan' exclude group: 'xml-apis', module: 'xml-apis' } + renderImplementation("org.apache.xmlgraphics:batik-script:${batikVersion}") { + exclude group: 'xalan', module: 'xalan' + exclude group: 'xml-apis', module: 'xml-apis' + } rendersignImplementation "org.apache.pdfbox:pdfbox:${pdfboxVersion}" rendersignImplementation "de.rototor.pdfbox:graphics2d:${graphics2dVersion}" @@ -105,7 +108,10 @@ dependencies { exclude group: 'xalan', module: 'xalan' exclude group: 'xml-apis', module: 'xml-apis' } - + rendersignImplementation("org.apache.xmlgraphics:batik-script:${batikVersion}") { + exclude group: 'xalan', module: 'xalan' + exclude group: 'xml-apis', module: 'xml-apis' + } if (!NO_SCRATCHPAD) { testImplementation project(':poi-scratchpad') @@ -126,29 +132,20 @@ dependencies { testImplementation "org.apache.logging.log4j:log4j-slf4j2-impl:${log4jVersion}" testImplementation 'org.slf4j:slf4j-simple:2.0.17' - broken("org.apache.xmlgraphics:batik-script:${batikVersion}"){ - exclude group: 'xalan', module: 'xalan' - exclude group: 'xml-apis', module: 'xml-apis' - } - javadocs project(':poi') javadocs project(':poi-scratchpad') } final String MODULE_NAME = 'org.apache.poi.ooxml' -final Pattern MODULE_NOT_REGEX = ~'(poi[/\\\\][^/\\\\]+$|batik-script)' +final Pattern MODULE_NOT_REGEX = ~'(poi[/\\\\][^/\\\\]+$)' final Pattern MODULE_REGEX = ~'\\.jar$' final List MAIN_MODULE_PATH = sourceSets.main.runtimeClasspath.findAll{ it.path =~ MODULE_REGEX }.collect{ it.parent }.unique() -final List TEST_MODULE_PATH = sourceSets.test.runtimeClasspath.findAll{ it.path =~ MODULE_REGEX && !(it.path =~ MODULE_NOT_REGEX) }.collect{ it.parent }.unique() + files("build/brokenJars") +final List TEST_MODULE_PATH = sourceSets.test.runtimeClasspath.findAll{ it.path =~ MODULE_REGEX && !(it.path =~ MODULE_NOT_REGEX) }.collect{ it.parent }.unique() final String OOXML_LITE_AGENT = "../build/dist/maven/poi-ooxml-lite-agent/poi-ooxml-lite-agent-${project.version}.jar" final String OOXML_LITE_REPORT = '../src/resources/ooxml-lite-report' final String OOXML_LITE_INCLUDES = "^(com/microsoft/schemas|org/(etsi|openxmlformats|w3/)|org/apache/poi/schemas)" -compileJava { - dependsOn 'fixBatik', 'cleanupBatik' -} - tasks.register('compileJava9', JavaCompile) { dependsOn 'compileJava', ':poi:jar' @@ -208,25 +205,6 @@ task testJar(type: Jar, dependsOn: testClasses) { } } -// based on https://github.com/moditect/moditect-gradle-plugin/issues/12 -tasks.register('fixBatik', Zip) { - ant.mkdir(dir: "${buildDir}/brokenJars") - archiveFileName = "batik-script-${batikVersion}.jar" - destinationDirectory = file("${buildDir}/brokenJars") - from zipTree(configurations.broken.files.find { f -> f.name.startsWith("batik-script") }) - filesMatching("**/org.apache.batik.script.InterpreterFactory") { - it.filter { it2 -> it2.contains("Rhino") ? "#" + it2 : it2 } - } -} - -tasks.register('cleanupBatik', Delete) { - // remove older files to avoid build failures because of duplicate modules - delete fileTree("${buildDir}/brokenJars/").matching { - include "*.jar" - exclude "batik*-${batikVersion}.jar" - } -} - javadoc { failOnError = true doFirst {