Hi, I'm currently creating a new Maven Reporting Plugin which integrate an
external tool used to generate a Javascript documentation in my Maven Web
Site.

My report Mojo is very simple and is declared using :

/**
 * @goal jsduck
 * @phase site
 */
public class JSDuckReportMojo extends AbstractMavenReport {
...
}

I encounter a file locking problem (i.e already opened elsewhere and not
closed) at the beginning of my 'executeReport' method :

*
protected void executeReport(Locale locale) throws MavenReportException {

    // JSDuck creates an 'index.html' file itself and crashes if one file
with this name already exist
    File jsduckIndex = new File("target/site/jsduck/index.html");

    if (jsduckIndex.exists() && !jsduckIndex.delete()) {
        throw new MavenReportException("Fail to delete the previously
generated index.html !"
);
    }

    // Use a document generator which absolutly need to have an empty
target directory
    ...
}
*

The tool I'm integrating is called 'jsduck' and absolutely needs to have an
empty target directory to work, its root index file is called 'index.html'.

So I've also implemented the 'getOutputName' function :

public String getOutputName() {
return "jsduck/index";
}

But, the file 'target/site/jsduck/index.html' has already been created
automagically by Maven.
In the 'executeReport' this file is there, empty and locked !

So, I can't delete this 'index.html' file and let JSDuck create itself :-(

Is it normal that Maven locks this 'index.html' file (because it has been
declared in the 'getOutputName()' ) ?
How can I unlock this file inside the 'executeReport' function to let
JSDuck generate my documentation ?

I've already tried to debug the 'AbstractMavenReport' class and only found
a 'PrintWriter' attached to the 'Sink' (in the 'execute' method) which
could cause this locking problem.
Calling the 'close' method at the beginning of the 'executeReport' method
seems to have no effect...

Thanks for you help,

Baptiste

Reply via email to