defining the classpath for an ANT task in an ANT build file

Having trouble installing <oXygen/>? Got a bug to report? Post it all here.
Ron Van den Branden
Posts: 48

defining the classpath for an ANT task in an ANT build file

Wed Nov 09, 2016 5:44 pm

Hi,

I am maintaining a framework that defines an ANT transformation task that (among others) executes a FOP transformation. After an Oxygen update, I noticed the included FOP distribution had been updated, so I had to update the jar file references.

In order to improve future compatibility, I tried to generalize those jar file references by replacing the version numbers with asterisks. In Oxygen-18.1 it works perfectly if I pass following jars in the "libraries" section of the ANT scenario configuration:

Code: Select all

<field name="extensionURLs">
  <String-array>
    <String>${oxygenHome}/classes/</String>
    <String>${oxygenHome}/lib/oxygen.jar</String>
    <String>${oxygenHome}/lib/oxygenAuthor.jar</String>
    <String>${oxygenHome}/lib/oxygenDeveloper.jar</String>
    <String>${oxygenHome}/lib/oxygenEclipse.jar</String>
    <String>${oxygenHome}/lib/oxygenAuthorEclipse.jar</String>
    <String>${oxygenHome}/lib/oxygenDeveloperEclipse.jar</String>
    <String>${oxygenHome}/lib/resolver.jar</String>
    <String>${oxygenHome}/lib/xercesImpl.jar</String>
    <String>${oxygenHome}/lib/saxon9ee.jar</String>
    <String>${oxygenHome}/lib/saxon.jar</String>
    <String>${oxygenHome}/lib/xml-apis-ext.jar</String>
    <String>${oxygenHome}/lib/log4j.jar</String>
    <String>${oxygenHome}/lib/fop.jar</String>
    <String>${oxygenHome}/lib/batik-all-*.jar</String>
    <String>${oxygenHome}/lib/commons-logging-*.jar</String>
    <String>${oxygenHome}/lib/xmlgraphics-commons-*.jar</String>
    <String>${oxygenHome}/lib/commons-io-*.jar</String>
    <String>${oxygenHome}/lib/avalon-framework-*.jar</String>
  </String-array>
</field> 


Yet, the wildcard expansion for those "extension URLs" seems to be a recent feature introduced with Oxygen-18. In earlier versions this won't work, and hence this approach introduces a backward compatibility issue I would like to solve.

Therefore, I've tried by removing the wildcard-URLs from the "extensionURLs" section, and instead define them in the FOP task definition in the ANT build file that's being called:

Code: Select all

  <taskdef name="fop" classname="org.apache.fop.tools.anttasks.Fop">
    <classpath>
      <fileset dir="${oxygen.home}/lib">
        <include name="fop.jar"/>
        <include name="batik-all-*.jar"/>
        <include name="commons-logging-*.jar"/>
        <include name="xmlgraphics-commons-*.jar"/>
        <include name="commons-io-*.jar"/>
        <include name="avalon-framework-*.jar"/>
      </fileset>
    </classpath>
  </taskdef>


If I initialize the ANT scenario while passing ${oxygenInstallDir} for the ANT script's ${oxygen.home} property, that seems to work partially, but still failing with following error:

BUILD FAILED
C:\Users\ron\AppData\Roaming\com.oxygenxml\extensions\v18.1\frameworks\myframework\jtei-pdf.xml:6: taskdef A class needed by class org.apache.fop.tools.anttasks.Fop cannot be found: org/apache/fop/apps/FOPException
using the classloader AntClassLoader[C:\Program Files\Oxygen XML Editor 18\lib\avalon-framework-api-4.3.1.jar;C:\Program Files\Oxygen XML Editor 18\lib\avalon-framework-impl-4.3.1.jar;C:\Program Files\Oxygen XML Editor 18\lib\batik-all-1.8.jar;C:\Program Files\Oxygen XML Editor 18\lib\commons-io-1.3.1.jar;C:\Program Files\Oxygen XML Editor 18\lib\commons-logging-1.2.jar;C:\Program Files\Oxygen XML Editor 18\lib\fop.jar;C:\Program Files\Oxygen XML Editor 18\lib\xmlgraphics-commons-2.1.jar]


From this error message, I gather that the wildcards are correctly resolved to the matching file names. Yet, apparently the classpath is not set correctly, since the org/apache/fop/apps/FOPException class can't be found, even though it is present in C:\Program Files\Oxygen XML Editor 18\lib\fop.jar.

I have the feeling I'm really close to a future and backward compatible solution... Am I still missing anything in the classpath definition for this FOP task?

Kind regards,

Ron
Radu
Posts: 5585

Re: defining the classpath for an ANT task in an ANT build file

Wed Nov 09, 2016 6:20 pm

Hi Ron,

I answered you on the opened issue.
https://github.com/TEIC/oxygen-tei/pull/9#issuecomment-259438650

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com

Return to “Common Problems”

Who is online

Users browsing this forum: No registered users and 2 guests