5

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

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

Roger
  • 911
  • 2
  • 9
  • 15
  • See this post, I think it answers your question : http://stackoverflow.com/questions/2615002/how-to-generate-pdf-from-docbook-5-0 – Vincent Biragnet Nov 25 '11 at 22:03
  • Thanks for the link. I had seen this post before but didn't read it carefully. I will update as soon as I have tested it. – Roger Nov 25 '11 at 23:41
  • Ok, just double checked. It is useful information, however it doesn't say anything about gradle. I just found something in the gradle source files and am testing it, will post something if it worked. – Roger Nov 26 '11 at 00:12

1 Answers1

6

Ok, so finally I found the solution. In order to generate a PDF, you have to provide the following files :

You have to add after to build.gradle the line

apply from: "docbook.gradle"

after

apply plugin: "java"

Then, append to the end of build.gradle this:

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

Here, we've put the docbook.xml and docbook-style.xsl in rootDirectory/doc, and we put the generated PDF in rootDirectory/docs (/pdf).

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

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

gradle docbookPdf

if you named the task 'docbookPdf'.

That's it. It should work on any platform.

Roger
  • 911
  • 2
  • 9
  • 15