FlexDoc/XML - Maven Integration
It is included in FlexDoc/XML ready for downloads now.
FlexDoc/XML Maven Plugin
This is a very simple plugin. Basically, it does little more than calling the FlexDoc/XML Generator's main class and passing to it an array of the same arguments as in the case of Java command-line.
However, our plugin both extends
org.apache.maven.plugin.AbstractMojo
class and implements
org.apache.maven.reporting.MavenReport
interface. So, it can be used both as a normal and reporting plugin simultaneously.
Note also, that although it is a simple Maven plugin, at the same time, it is a very powerful one because it does all FlexDoc/XML Generator can do. In particular:
- Running XSDDoc/WSDLDoc and generating your XML schema / WSDL documentation.
-
Generating along that any XSD diagrams inserted automatically in the documentation.
That is possible because DiagramKit, which generates those diagrams, is equally a part of FlexDoc/XML. For further details, please see:
Installation
The Java source of FlexDoc/XML Maven Plugin consists of only'FlexDocXMLMojo.java'
class found at:
{flexdoc-xml}/integrations/maven/plugin/src/
'{flexdoc-xml}'
designates FlexDoc/XML installation directory.
To install the plugin into Maven repository, please follow these steps:
-
Since FlexDoc/XML Maven Plugin stores no FlexDoc/XML Java libraries in the Maven repository,
it uses everything directly from the FlexDoc/XML installation whose location must be provided in the plugin POM file:
{flexdoc-xml}/integrations/maven/plugin/pom.xml
-
<properties> <!-- The absolute pathname of FlexDoc/XML home directory --> <flexdoc.xml.home>C:/flexdoc-xml-1.13</flexdoc.xml.home> ... </properties>
-
In
{flexdoc-xml}/integrations/maven/plugin/
directory, depending on your OS, edit either-
install.bat / install.command / install.sh
Run that command file.
LinuxIf everything is correct, the FlexDoc/XML Maven Plugin will be compiled and installed.First, you should set the «Permission» property of
install.sh
file to allow its execution under Linux.macOS
Since macOS has extremely tight security control, to be able running
install.command
, you need to do the following:-
First, open
install.command
with TextEdit (confirm in the warning box that it is OK to open it). Then, simply resave that file via «File | Save» menu. With that procedure, you will signinstall.command
as its owner/creator, which is a precondition to be able running it! -
Additionally, you need to assign
install.command
with the executable privilege: Run the Terminal and type in it'chmod u+x'
followed by a space and the full pathname of the script file (instead of typing it, just draginstall.command
from the Finder into the Terminal window). Then, press Enter.
install.command
from the Finder just by clicking twice on it. -
-
To test the plugin, in the same directory depending on your OS, edit either of
-
test.bat / test.command / test.sh
-
Installation with DiagramKit
To install FlexDoc/XML Maven Plugin with the support of DiagramKit, all steps are the same as described above, but instead ofpom.xml
install.(bat|sh|command)
pom_with_DiagramKit.xml
install_with_DiagramKit.(bat|sh|command)
pom_with_DiagramKit.xml
is different from pom.xml
in that
-
It adds the dependency to the Java implementation of DiagramKit:
{flexdoc-xml}/lib/flexdoc-xml-diagramkit.jar
- It also adds the automatic installation of JavaFX Maven plugins, which provide JavaFX modules necessary to run DiagramKit
-
The plugin artifactId is
"plugin-with-diagramkit"
(instead of simply"default-plugin"
, as in the case ofpom.xml
)
Usage
FlexDoc/XML Maven Plugin processes only three parameters:- <generatorParams>
-
The array of all command-line
arguments passed to the FlexDoc/XML generator (except those controlled by other two parameters).
Each command-line argument (which is either a generator option name, the option value or an input XML file) should be specified with a nested <param> element in the same order as on the FlexDoc/XML generator command-line.
- <outputFolder>
- Specifies the output directory name.
The plugin will convert the specified value into the absolute pathname of the output directory, which is passed further both to Maven and to FlexDoc/XML Generator (via -d option).
- <outputFile>
- Specifies the name of the main output file.
The plugin will pass the specified value directly to FlexDoc/XML Generator (via -f option). It will be also converted into the absolute pathname and passed to Maven (exactly that pathname will be linked from the Maven-generated “Project Reports” page).
'generator'
,
which launches the FlexDoc/XML Generator.
Memory Heap Size
Since FlexDoc/XML Generator requires a lot of memory (especially when processing big template applications) and it will be executed by the same JVM as Maven, you need to ensure that the Maven's JVM maximum memory heap size is large enough.
You can specify this by setting 'MAVEN_OPTS'
variable in a Windows command file
that starts the Maven. For example:
-
MAVEN_OPTS=-Xms1024m -Xmx2048m
-
export MAVEN_OPTS="-Xms1024m -Xmx2048m"
The lack of memory may cause the FlexDoc/XML Generator to slow down very much
(especially, when processing a big template application like XSDDoc)
and lead eventually to java.lang.OutOfMemoryError
exception!
Example 1
This example shows how to configure the FlexDoc/XML Maven Plugin in a project POM file so as to generate using XSDDoc template set the XML schema documentation by XML Schemas for WSDL 1.1 that would appear on the “Project Reports” page of a Maven-generated project site.pom.xml
Reporting section.
All reports for "Project Reports" page of the Maven-generated site should be specified here.
-->
Specifying the data source XML files to be processed.
The following files will be loaded directly from Internet by the given URLs.
-->
Specify the output directory name.
The plugin will convert it into the absolute pathname of the output directory,
which is passed further both to Maven and to FlexDoc/XML Generator (via -d option).
-->
This complete working example is included in FlexDoc/XML archive prepared for downloads.
Example 2
In this example we show how to configure the FlexDoc/XML Maven Plugin to generate with it simultaneously two reports:- The “Sales Report”, which is described in FlexDoc/XML | Samples | Sales Report.
-
The XML schema documentation (using XSDDoc templates) for the XML schema
sales.xsd
that describes the structure ofsales.xml
, the data source file for the first report.
pom.xml
Reporting section (where all reports for "Project Reports" page are specified)
-->
Specifying the FIRST REPORT: "Sales Report".
(The name of the <reportSet> element is actualy misleading here.
Only one report we can define within this element.)
-->
The <id> element must be always specified and unique!
Otherwise, only one report will be generated by the plugin.
-->
Specify the output directory name.
The plugin will convert it into the absolute pathname of the report's
output directory, which will be passed both to Maven and to FlexDoc/XML
Generator (via -d option).
-->
Specify the name of the main output file.
The plugin will pass it directly to FlexDoc/XML Generator (via -f option).
It will be also converted into the absolute pathname and passed to Maven
(exactly that pathname will be linked from the project-reports page).
-->
Specifying the plugin's goal.
(It is necessary here. Otherwise, nothing will be generated.)
-->
Now, we specify the generation of the SECOND REPORT.
This will be the XSDDoc (XML schema documentation) generated for the XML schema
that describes the 'sales.xml' file used in the first report. (The 'sales.tpl'
template, which actually generates the first report, is based on that schema.)
-->
The input XML file to process (i.e. the XML schema to be documented)
-->
This complete working example is included in FlexDoc/XML archive prepared for downloads.