DITA-OT Custom jars

Post here questions and problems related to oXygen frameworks/document types.
msambasiva
Posts: 48
Joined: Tue Jul 17, 2018 6:57 am

DITA-OT Custom jars

Post by msambasiva » Thu May 21, 2020 11:53 am

Hi,

DITA-OT 2.4.6

We have developed a DITA-OT plugin which is using custom jar. The custom jar itself using some other third party jars. So to make it work, I am copying the custom jar & dependent jars into <DITA-OT>/lib.
How best we can avoid manually copy the custom jar & dependent jars into <DITA-OT>/lib.
How to maintain the custom jars of lib folder with DITA-OT version changes? i.e if we migrate or reinstall DITA-OT, how best we can get the custom jars.
I am not sure if I am correct, here is what I am thinking, maintain the custom/dependent jar at repository and checkout. Finally add the custom path to CLASSPATH variable.

Thanks,
Samba.

Radu
Posts: 7026
Joined: Fri Jul 09, 2004 5:18 pm

Re: DITA-OT Custom jars

Post by Radu » Thu May 21, 2020 12:07 pm

Hi Samba,

You can contribute the JAR library directly from your DITA OT plugin's plugin.xml:

https://www.dita-ot.org/dev/topics/plugin-javalib.html
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com

msambasiva
Posts: 48
Joined: Tue Jul 17, 2018 6:57 am

Re: DITA-OT Custom jars

Post by msambasiva » Tue May 26, 2020 6:39 am

Thanks Radu!
There are some dependent jars like log4j-api-2.13.2.jar, log4j-core-2.13.2.jar,commons-codec-1.10.jar etc which are not part of default DITA-OT installation. Can we use the same extension dita.conductor.lib.import for number of times to include all the dependent jar? Could you suggest best way to manage the jars and dependent jars on re/installation of DITA OT?

Radu
Posts: 7026
Joined: Fri Jul 09, 2004 5:18 pm

Re: DITA-OT Custom jars

Post by Radu » Tue May 26, 2020 6:47 am

Hi,

In the plugin.xml you can add references to multiple jar libraries, like for example:

https://github.com/jelovirt/org.lwdita/ ... plugin.xml

This is the portable way of doing things as the plugin will include everything inside.

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

msambasiva
Posts: 48
Joined: Tue Jul 17, 2018 6:57 am

Re: DITA-OT Custom jars

Post by msambasiva » Wed Jun 03, 2020 10:05 am

Hi,

We have created a separate plugin uae.dita.resources to have resources like libraries and xml. Below is the feature element having reference to resources plugin.
<feature extension="dita.conductor.lib.import" file="${dita.plugin.uae.dita.resources.dir}/resources/lib/log4j-api-2.13.2.jar"/>

Some how, getting exception in the plugin installation process as below,
DITA> /scratch/uae/src/dita-ot-2.4.6/resources/env.sh: line 27: $CLASSPATH:$DITA_HOME/plugins/uae.dita.analytics/${dita.plugin.uae.dita.resources.dir}/resources/lib/log4j-api-2.13.2.jar: bad substitution
DITA> /scratch/uae/src/dita-ot-2.4.6/resources/env.sh: line 28: $CLASSPATH:$DITA_HOME/plugins/uae.dita.analytics/${dita.plugin.uae.dita.resources.dir}/resources/lib/log4j-core-2.13.2.jar: bad substitution


Please correct me if Iam wrong at referencing resources of other plugin in my plugin.xml

Thanks,
Samba.

Radu
Posts: 7026
Joined: Fri Jul 09, 2004 5:18 pm

Re: DITA-OT Custom jars

Post by Radu » Wed Jun 03, 2020 12:49 pm

Hi Samba,

Editor variables like "${dita.plugin.uae.dita.resources.dir}/" are not expanded in library paths when the JAR libraries are gathered by the DITA OT engine.
The references to the JAR libraries should be relative to the plugin.xml where they are defined, in your case, they should probably be:

Code: Select all

<feature extension="dita.conductor.lib.import" file="resources/lib/log4j-api-2.13.2.jar"/>
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com

msambasiva
Posts: 48
Joined: Tue Jul 17, 2018 6:57 am

Re: DITA-OT Custom jars

Post by msambasiva » Tue Jun 09, 2020 12:23 pm

Hi,

I got struck with importing jars present in <our-plugin>/lib folder.

Below is the url of having similar problem

https://stackoverflow.com/questions/588 ... -classpath

I finally nailed what was wrong with my DITA OT configuration.

I was using an ant build script to run DITA OT and when doing this, the plugin JARs are not automatically added to the classpath.

I switched to using the DITA OT command line. Now my JARs are seen by the ant scripts and my extension functions are accessible from the XSLT.

In addition, if someone else has a classpath problem like this, you can also check the file [DITA-OT]/config/env.bat (env.sh for lunix users). After installing a plugin that provides its own JAR libraries, the JAR files shall be present in this file:

set "CLASSPATH=%CLASSPATH%;%DITA_HOME%\plugins\org.dita.pdf2\lib\fo.jar"
set "CLASSPATH=%CLASSPATH%;%DITA_HOME%\plugins\com.infotel.orlando.pdf\.\xslt-extension.jar"
set "CLASSPATH=%CLASSPATH%;%DITA_HOME%\plugins\org.dita.eclipsehelp\lib\eclipsehelp.jar"
...



As of now, we are using below ant command to run the plugin to convert xmls of a folder to dita files,

bin\ant -Dtranstype=analyticsdita -Dargs.input.dir="analytics\input\deck_cards" -Doutput.dir="analytics\out"

Some how I don't find option to pass folder as an argument to dita command.. Could you suggest dita command similar to above ant cmd?

Thanks,
Samba.

Radu
Posts: 7026
Joined: Fri Jul 09, 2004 5:18 pm

Re: DITA-OT Custom jars

Post by Radu » Tue Jun 09, 2020 12:37 pm

Hi Samba,

Right, you should always use the "dita" command to perform the processing in order to properly load all JAR libraries.
The "dita" command only takes a single DITA Map or topic as argument but you could try to call it multiple times, once for each file. You can also call the "dita" command from an ANT build file:

https://www.dita-ot.org/dev/topics/migr ... -dita.html

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

msambasiva
Posts: 48
Joined: Tue Jul 17, 2018 6:57 am

Re: DITA-OT Custom jars

Post by msambasiva » Thu Jun 25, 2020 11:29 am

Thanks Radu!

We found that, even ANT command also able to load the jars placed within the plugin (instead of DITA-OT\lib) by setting refid="dost.class.path" of classpath element as below.

<java classname="com.mycompany.exceltoxml.EntryPoint">
<classpath refid="dost.class.path"/>
<arg value="${inputMap}${file.separator}"/>
<arg value="${xmlOutputDir}${file.separator}"/>
</java>

Regards,
Samba.

Radu
Posts: 7026
Joined: Fri Jul 09, 2004 5:18 pm

Re: DITA-OT Custom jars

Post by Radu » Thu Jun 25, 2020 11:48 am

HI Samba,

Yes, right, the "dost.class.path" should have references to all Jars and you can set it as a classpath to an ANT "java" task.

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

Post Reply