Creating a PDF from docbook XML when creating a Java project using Gradle

I need to create a PDF version of the docbook.xml (5.0) documentation when creating a java project using gradle (build.gradle file).

If someone can show an example script that will work on any platform (Mac OS X, Windows, Linux), this will be very helpful.

+4
source share
1 answer

So finally I found a solution. To create a PDF file, you must provide the following files:

You must add after that to build the .gradle line

apply from: "docbook.gradle" 

after

 apply plugin: "java" 

Then add this to the end of build.gradle:

 docbookPdf { sourceFileName = "docbook.xml" stylesheet = file("doc/docbook-style.xsl") sourceDirectory = file( "doc" ) docsDir = new File(project.getBuildDir(), "docs"); } 

Here we placed docbook.xml and docbook-style.xsl in the rootDirectory / doc directory, and we placed the generated PDF in the rootDirectory / docs (/ pdf) file.

Here is an example docbook stylesheet that you can use: http://cl.ly/2n1p3o0r1L3Z1d2U4345

To generate the PDF from the terminal, go to the directory where the build.gradle file is located and execute

 gradle docbookPdf 

if you named task docbookPdf.

What is it. It should work on any platform.

+5
source

Source: https://habr.com/ru/post/1383127/


All Articles