Search code examples
javamavensvnjavadocmaven-javadoc-plugin

How to create Javadoc on the target (SVN-) server using Maven?


I want to create the Javadoc files of my project on the SVN-server right after I commited it, meaning that I want the server to do the work.

I already looked in the maven-javadoc-plugin examples section, but I could not find a suitable solution. (Maybe I just didn't understand it, I am new to Maven. If so, please be lenient and explain it to me)

It is important to notice, that I do not want Maven to generate the Javadoc on every build as it would be a big perfomance loss. I could just figure out, that <reporting/> should be the correct location.

I am using eclipse IDE for Java EE developers and Maven 3.

Thank you in advance


Solution

  • A possible solution would be to create a post-commit hook that invokes the javadoc utility directly on the command line.

    A post-commit hook is a script that is executed by the SVN server right after a successful commit. To create a post-commit hook, please refer to this question (or this blog). Basically, it comes down to modifying the post-commit.tmpl template script that is located in the hooks directory of your SVN server.

    The script will need to execute the javadoc utility. It will depend on your current OS and SVN repository directory structure, but assuming Linux and a project called myProject with parent package com, it could be:

    #!/bin/sh
    
    REPOS="$1"
    REV="$2"
    
    /path/to/jdk/bin/javadoc -d ${REPOS}/myProject/target/javadoc -sourcepath "${REPOS}/myProject/src/main/java" -subpackages com
    

    In this script, REPOS refers to the location of the SVN repository. This hook will invoke javadoc and tells it to store the generated Javadoc inside the target folder of myProject of all the classes inside src/main/java with common subpackage com.