A plugin for DITA Open Toolkit that provides enhanced dependency management for DITA-OT plugins.
- Check for dependencies defined in various sources with a clear precedence.
- Support for
<?depends-on ...?>processing instructions within a plugin'splugin.xmlfor self-contained dependency declarations. - Support for a global
dependency-config.xmlfile for site-wide or overriding dependency rules. - Differentiate between required and preferred dependencies.
- Version checking for dependencies with flexible version requirements (>=, >, <=, <, =).
- Check for:
- Other plugins
- Installed executable software
- Java versions
- Java JAR files
- Generate HTML and XML dependency reports.
- Warning logs for missing dependencies.
- Build the plugin using Maven:
mvn clean package. This creates the plugin ZIP in thetarget/directory (e.g.,dep-checker-1.0.0-plugin.zip). - Install the plugin into your DITA-OT instance using the DITA-OT integrator tool:
Alternatively, you can copy the plugin contents to the
dita --install /path/to/your/target/dep-checker-1.0.0-plugin.zip
pluginsdirectory of your DITA-OT installation and run the integrator.
Dependencies are determined based on the following sources, in order of precedence (highest to lowest):
- Global Configuration for a Specific Plugin: Rules in the main
dependency-config.xml(located at the project rootdependency-config.xmlduring development, or incom.android606.dep-checker/config/after installation) that target a specific plugin (e.g.,<plugin id="some.other.plugin">...</plugin>). - Plugin's Own Declarations in
plugin.xml:- Standard
<require>elements. <?depends-on ...?>processing instructions. These are effectively evaluated together for the plugin being checked if no overriding global configuration for that specific plugin is found.
- Standard
Additionally, Universal Global Dependencies (defined with <plugin id="*">...</plugin>) from the main dependency-config.xml are applied to EVERY plugin being checked, in addition to its specific dependencies.
Your plugin.xml is the primary place for self-contained dependency declarations.
DITA-OT's standard mechanism for plugin dependencies.
<plugin id="your.plugin.id" version="1.0.0">
<require plugin="org.dita.base" importance="required" version=">=3.0.0"/>
<require plugin="org.dita.pdf2" importance="optional" version="<4.0.0"/>
<!-- ... -->
</plugin>For more detailed or varied dependency types (software, JARs, specific Java versions, or more nuanced plugin checks), use processing instructions directly under the root <plugin> element.
<?xml version="1.0" encoding="UTF-8"?>
<plugin id="your.plugin.id" version="1.0.0">
<require plugin="org.dita.base"/>
<?depends-on id="com.example.another-plugin" type="PLUGIN" version="^1.2.0" required="true" message="Needs this for cool feature X." ?>
<?depends-on id="ghostscript" type="SOFTWARE" version=">=9.50" required="false" message="Ghostscript is preferred for enhanced PDF processing." ?>
<?depends-on id="my-custom-library" type="JAR" required="true" message="Core library for this plugin." ?>
<?depends-on id="java" type="JAVA_VERSION" version=">=11" message="Requires Java 11 or newer." ?>
<!-- Other plugin elements like features, templates, etc. -->
</plugin>Attributes for <?depends-on ...?>:
id: The identifier of the dependency (plugin ID, software name, JAR name, or "java"). (Required)type: The type of dependency:PLUGIN,JAR,SOFTWARE,JAVA_VERSION. (Defaults toPLUGINif omitted)version: The version requirement string (see "Version Requirements" below). (Optional)required:trueorfalse. (Defaults totrueif omitted)message: A descriptive message explaining the dependency or the consequence of it being missing. (Optional; a default message is generated if omitted)
This file is located at the project root (dependency-config.xml) during development. When the plugin is packaged, it is placed into the config/ subdirectory (e.g., DITA-OT/plugins/com.android606.dep-checker/config/dependency-config.xml). It's used for site-wide rules or to override/supplement definitions from individual plugin.xml files.
Example Structure:
<dependency-config>
<!-- Rules for a specific plugin (e.g., org.dita.pdf2), will override its plugin.xml declarations -->
<plugin id="org.dita.pdf2">
<depend id="org.apache.fop" type="JAR" version=">=2.3" required="true"
message="Apache FOP 2.3 or higher is strictly required for PDF generation by site policy." />
</plugin>
<!-- Universal global rules, applied to ALL plugins -->
<plugin id="*">
<depend id="java" type="JAVA_VERSION" version=">=1.8" required="true"
message="Site policy: Java 8 or higher is required for all DITA-OT processing." />
</plugin>
</dependency-config>The <depend> elements within this file have the same attributes as the <?depends-on ...?> processing instructions.
The plugin supports the following version requirement formats in the version attribute:
3.0.0- Exact version match.=3.0.0- Explicit exact version match.>=3.0.0- Version 3.0.0 or higher.>3.0.0- Version higher than 3.0.0.<=3.0.0- Version 3.0.0 or lower.<3.0.0- Version lower than 3.0.0.>=3.0.0,<4.0.0- Version 3.0.0 or higher, AND lower than 4.0.0 (range). (Note: use<for<in XML attributes if usingdependency-config.xml. Processing instructions can use<directly).
The dependency checker is integrated into DITA-OT's preprocessing pipeline. When DITA-OT builds documents, the checker will automatically analyze installed plugins based on the configured rules.
If dependencies are not met:
- Warnings will be logged to the console.
- The build may fail if a required dependency is missing and the checker is configured to
failOnError="true"(default behavior of the Ant task may vary). - An HTML and XML report will be generated.
The plugin provides an Ant task that can be called directly, though it's primarily designed to be invoked by DITA-OT.
Parameters for the Ant task:
pluginDir: Path to the DITA-OT plugins directory. (Required)configFile: Path to the globaldependency-config.xmlfile (e.g.,plugins/com.android606.dep-checker/config/dependency-config.xmlin an installed DITA-OT, or simplydependency-config.xmlif running tests from the project root where the Ant task can find it). (Optional)reportDir: Directory where the HTML and XML reports will be generated. (Required)failOnError: Whether to fail the Ant build if required dependencies are missing. (trueorfalse, defaults tofalseif not set, but DITA-OT's invocation might set this).logLevel: Logging verbosity (error,warn,info,verbose,debug. Defaults toinfo).
Example Ant task usage in a build script:
<taskdef name="check-dependencies"
classname="com.android606.dita.dependencychecker.CheckDependenciesTask"
classpath="path/to/dep-checker.jar"/>
<target name="run-dependency-check">
<check-dependencies pluginDir="${dita.ot.dir}/plugins"
configFile="dependency-config.xml"
reportDir="${output.dir}/dependency-reports"
failOnError="true"
logLevel="verbose"/>
</target>An HTML report of dependency issues is generated (e.g., in out/dependency-reports/dependency-report.html). This report includes:
- Summary of scanned plugins and issues found.
- Details for each issue:
- The plugin that has the unmet dependency.
- The missing dependency's ID, type, and required version.
- Whether the dependency was required or optional.
- The original message associated with the dependency rule.
An XML report (dependencies.xml) is also generated in the same directory, suitable for automated parsing.
The project uses Maven. To build the plugin JAR and the distributable plugin ZIP:
mvn clean packageThe JAR will be in target/dep-checker-1.0.0.jar (and copied to lib/dependency-checker.jar).
The plugin ZIP will be in target/dep-checker-1.0.0-plugin.zip.
The project includes an Ant build script (integration_test_build.xml) for running integration tests. These tests will:
- Download a specific version of DITA-OT (if not already cached in
test/dita-ot-downloads/). - Build the
com.android606.dep-checkerplugin using Maven (invokesmvn clean package). - Install the main plugin and dummy test plugins into the downloaded DITA-OT instance. Dummy plugins use
<?depends-on ...?>PIs to test the new mechanism. - Run a DITA build on a sample project to trigger the dependency checker.
- Verify that the dependency reports are generated and check for expected outcomes.
To run the integration tests:
ant -f integration_test_build.xmlThe main test output will be in the test-output/ directory, and the DITA-OT test instance will be in dita-ot-test-instance/.
This plugin is designed to be cross-platform and works with Ant and Java.