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

leginee pushed a commit to branch backport/pdfimport-pdfbox
in repository https://gitbox.apache.org/repos/asf/openoffice.git

commit 040ebbdac0d5474ad01ef29a641a0c1e74a989c3
Author: Peter <[email protected]>
AuthorDate: Wed Sep 9 00:26:00 2026 +0200

    build: build the PDF import helper with ant
    
    Uses the ant framework in solenv/ant rather than dmake's 
JAVAFILES/JARTARGET,
    matching how every other Java component here is built (connectivity/java/*,
    swext/mediawiki).  It also removes hand-rolled work: externals.xml already
    resolves a third-party jar to $(OUTDIR)/bin and onto the compile classpath, 
so
    the module no longer has to assemble a classpath itself.
    
      solenv/ant/externals.xml
          The four PDFBox jars, declared like every other external.  They are
          always internal: these are official ASF release artifacts fetched by
          external_deps.lst, and there is no system-pdfbox configure switch, so
          system-test can never match.
    
      pdfboxwrapper/build.xml
          Imports aoo-ant.xml.  jar.classpath becomes the Class-Path of the 
helper
          jar, which is how `java -jar` reaches the four alongside it in the
          extension; main.classpath is the compile-time equivalent.
    
      pdfboxwrapper/src -> src/main/java
          aoo-ant.xml expects the Maven layout.
    
      pdfboxwrapper/makefile.mk
          Drives ant, and places the downloaded jars twice over -- once in
          $(OUTDIR)/bin, where externals.xml points the compile classpath, and 
once
          in $(BIN), which is where the extension packaging in ../makefile.mk
          copies from.  Neither is optional and they are not the same directory.
    
      pdfboxwrapper/manifest.mf
          Main-Class only; aoo-ant.xml contributes Class-Path from 
jar.classpath.
    
    Co-Authored-By: Claude Opus 5 <[email protected]>
    Claude-Session: https://claude.ai/code/session_01CH5PJJyJfirMStqJEZTxBD
---
 .../sdext/source/pdfimport/pdfboxwrapper/build.xml | 52 +++++++++++++++++++++
 .../source/pdfimport/pdfboxwrapper/makefile.mk     | 54 +++++++++++-----------
 .../source/pdfimport/pdfboxwrapper/manifest.mf     |  1 -
 .../org/apache/openoffice/pdfimport/Main.java      |  0
 .../apache/openoffice/pdfimport/PdfiEngine.java    |  0
 .../apache/openoffice/pdfimport/PdfiWriter.java    |  0
 main/solenv/ant/externals.xml                      | 28 +++++++++++
 7 files changed, 107 insertions(+), 28 deletions(-)

diff --git a/main/sdext/source/pdfimport/pdfboxwrapper/build.xml 
b/main/sdext/source/pdfimport/pdfboxwrapper/build.xml
new file mode 100644
index 0000000000..2d0e9c472c
--- /dev/null
+++ b/main/sdext/source/pdfimport/pdfboxwrapper/build.xml
@@ -0,0 +1,52 @@
+<?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.
+ *
+ ***********************************************************-->
+
+<!-- The PDF Import extension's parsing backend.
+
+     This is a plain program, not a UNO component: it is spawned as its own
+     process and speaks the protocol in ../PROTOCOL.md over stdout, so it links
+     no UNO and needs none of the office jars on its classpath.  Keeping it out
+     of process is what lets an Apache-licensed office use any engine, and what
+     confines a fault in it to one document. -->
+
+<project name="pdfimport-pdfbox" default="main" basedir=".">
+
+    <property file="../../../../ant.properties"/>
+    <import file="${SRC_ROOT}/solenv/ant/aoo-ant.xml"/>
+
+    <target name="init-project">
+        <!-- Started as `java -jar`, so the four PDFBox jars have to be
+             reachable from this jar's own Class-Path.  They are packed beside
+             it in the extension, so plain filenames resolve. -->
+        <property name="jar.classpath"
+                  value="${external.pdfbox.jarclasspath} 
${external.pdfbox-io.jarclasspath} ${external.fontbox.jarclasspath} 
${external.commons-logging.jarclasspath}"/>
+        <property name="jar.manifest" location="manifest.mf"/>
+
+        <path id="main.classpath">
+            <pathelement location="${external.pdfbox.path}"/>
+            <pathelement location="${external.pdfbox-io.path}"/>
+            <pathelement location="${external.fontbox.path}"/>
+            <pathelement location="${external.commons-logging.path}"/>
+        </path>
+    </target>
+
+</project>
diff --git a/main/sdext/source/pdfimport/pdfboxwrapper/makefile.mk 
b/main/sdext/source/pdfimport/pdfboxwrapper/makefile.mk
index d590f53bc4..d6d281969f 100644
--- a/main/sdext/source/pdfimport/pdfboxwrapper/makefile.mk
+++ b/main/sdext/source/pdfimport/pdfboxwrapper/makefile.mk
@@ -23,7 +23,6 @@ PRJ=..$/..$/..
 
 PRJNAME=sdext
 TARGET=pdfimport-pdfbox
-PACKAGE=org$/apache$/openoffice$/pdfimport
 
 # --- Settings -----------------------------------------------------
 
@@ -36,47 +35,48 @@ all:
 
 .ELSE
 
-# The four jars are downloaded by external_deps.lst into $(TARFILE_LOCATION).
-# They are needed twice over: on the compile classpath here, and in the
-# extension at run time, since the helper is started as `java -jar` and reaches
-# them through the Class-Path in its own manifest.
+ANT_BUILDFILE=build.xml
+.INCLUDE : antsettings.mk
+
+# external_deps.lst downloads the four jars into $(TARFILE_LOCATION).  They are
+# needed in two places and neither is optional: solenv/ant/externals.xml
+# resolves external.<name>.path to $(OUTDIR)/bin, which is what puts them on
+# ant's compile classpath, and the extension packs them beside the helper jar
+# so that `java -jar` can follow the Class-Path in its manifest.
+#
+# Unlike apache-commons, which fetches source and builds it, these are official
+# ASF release artifacts, so there is nothing to build -- only to place.
 PDFBOX_JARNAMES= \
        pdfbox-3.0.8.jar \
        pdfbox-io-3.0.8.jar \
        fontbox-3.0.8.jar \
        commons-logging-1.4.0.jar
 
-PDFBOX_JARS=$(foreach,i,$(PDFBOX_JARNAMES) $(TARFILE_LOCATION)$/$(i))
+SOLVER_JARS=$(foreach,i,$(PDFBOX_JARNAMES) $(OUTDIR)$/bin$/$(i))
 DELIVERED_JARS=$(foreach,i,$(PDFBOX_JARNAMES) $(BIN)$/$(i))
 
-# --- Files --------------------------------------------------------
-
-JAVAFILES= \
-       src$/$(PACKAGE)$/Main.java \
-       src$/$(PACKAGE)$/PdfiEngine.java \
-       src$/$(PACKAGE)$/PdfiWriter.java
-
-JAVACLASSFILES=$(foreach,i,$(JAVAFILES) $(CLASSDIR)$/$(PACKAGE)$/$(i:b).class)
-
-# javac needs PDFBox on the classpath; the office's own jars are irrelevant
-# here, as the helper is a plain process and links no UNO.
-XCLASSPATH!:=$(XCLASSPATH)$(PATH_SEPERATOR)$(PDFBOX_JARS:t"$(PATH_SEPERATOR)")
-
-JARCLASSDIRS=org
-JARTARGET=$(TARGET).jar
-JARCOMPRESS=TRUE
-CUSTOMMANIFESTFILE=manifest.mf
-
 # --- Targets ------------------------------------------------------
 
 .INCLUDE : target.mk
 
-# Stage the downloaded jars beside the built one, because the extension's
-# packaging rule in ../makefile.mk copies every CONVERTER_FILE out of $(BIN).
-ALLTAR : $(DELIVERED_JARS)
+# The solver copies must exist before ant runs, or the compile classpath points
+# at nothing; the $(BIN) copies are what ../makefile.mk packs into the .oxt.
+ANTBUILD : $(SOLVER_JARS)
+
+ALLTAR : $(DELIVERED_JARS) $(BIN)$/$(TARGET).jar
+
+$(SOLVER_JARS) : $(TARFILE_LOCATION)$/$$(@:f)
+       @@-$(MKDIRHIER) $(@:d)
+       $(COPY) $< $@
 
 $(DELIVERED_JARS) : $(TARFILE_LOCATION)$/$$(@:f)
        @@-$(MKDIRHIER) $(@:d)
        $(COPY) $< $@
 
+# aoo-ant.xml writes the jar to $(WORKDIR)/Ant; bring it where the extension
+# packaging expects to find it.
+$(BIN)$/$(TARGET).jar : ANTBUILD
+       @@-$(MKDIRHIER) $(@:d)
+       $(COPY) $(WORKDIR)$/Ant$/$(TARGET).jar $@
+
 .ENDIF # ENABLE_PDFIMPORT
diff --git a/main/sdext/source/pdfimport/pdfboxwrapper/manifest.mf 
b/main/sdext/source/pdfimport/pdfboxwrapper/manifest.mf
index f36a85c4b8..ee18ac6df7 100644
--- a/main/sdext/source/pdfimport/pdfboxwrapper/manifest.mf
+++ b/main/sdext/source/pdfimport/pdfboxwrapper/manifest.mf
@@ -1,2 +1 @@
 Main-Class: org.apache.openoffice.pdfimport.Main
-Class-Path: pdfbox-3.0.8.jar pdfbox-io-3.0.8.jar fontbox-3.0.8.jar 
commons-logging-1.4.0.jar
diff --git 
a/main/sdext/source/pdfimport/pdfboxwrapper/src/org/apache/openoffice/pdfimport/Main.java
 
b/main/sdext/source/pdfimport/pdfboxwrapper/src/main/java/org/apache/openoffice/pdfimport/Main.java
similarity index 100%
rename from 
main/sdext/source/pdfimport/pdfboxwrapper/src/org/apache/openoffice/pdfimport/Main.java
rename to 
main/sdext/source/pdfimport/pdfboxwrapper/src/main/java/org/apache/openoffice/pdfimport/Main.java
diff --git 
a/main/sdext/source/pdfimport/pdfboxwrapper/src/org/apache/openoffice/pdfimport/PdfiEngine.java
 
b/main/sdext/source/pdfimport/pdfboxwrapper/src/main/java/org/apache/openoffice/pdfimport/PdfiEngine.java
similarity index 100%
rename from 
main/sdext/source/pdfimport/pdfboxwrapper/src/org/apache/openoffice/pdfimport/PdfiEngine.java
rename to 
main/sdext/source/pdfimport/pdfboxwrapper/src/main/java/org/apache/openoffice/pdfimport/PdfiEngine.java
diff --git 
a/main/sdext/source/pdfimport/pdfboxwrapper/src/org/apache/openoffice/pdfimport/PdfiWriter.java
 
b/main/sdext/source/pdfimport/pdfboxwrapper/src/main/java/org/apache/openoffice/pdfimport/PdfiWriter.java
similarity index 100%
rename from 
main/sdext/source/pdfimport/pdfboxwrapper/src/org/apache/openoffice/pdfimport/PdfiWriter.java
rename to 
main/sdext/source/pdfimport/pdfboxwrapper/src/main/java/org/apache/openoffice/pdfimport/PdfiWriter.java
diff --git a/main/solenv/ant/externals.xml b/main/solenv/ant/externals.xml
index f6bb8470a2..9ba7dfb3c1 100644
--- a/main/solenv/ant/externals.xml
+++ b/main/solenv/ant/externals.xml
@@ -49,6 +49,34 @@
         </sequential>
     </macrodef>
 
+    <!-- Apache PDFBox: the PDF Import extension's parsing backend, run as a
+         helper process.  Always internal, because these are official ASF
+         release jars fetched by external_deps.lst and there is no
+         system-pdfbox configure switch, so system-test can never match. -->
+    <define-external
+        name="pdfbox"
+        system-test="NO"
+        system-path=""
+        internal-filename="pdfbox-3.0.8.jar"/>
+
+    <define-external
+        name="pdfbox-io"
+        system-test="NO"
+        system-path=""
+        internal-filename="pdfbox-io-3.0.8.jar"/>
+
+    <define-external
+        name="fontbox"
+        system-test="NO"
+        system-path=""
+        internal-filename="fontbox-3.0.8.jar"/>
+
+    <define-external
+        name="commons-logging"
+        system-test="NO"
+        system-path=""
+        internal-filename="commons-logging-1.4.0.jar"/>
+
     <define-external
         name="hsqldb"
         system-test="${SYSTEM_HSQLDB}"

Reply via email to