This is probably what you need:
from org.apache.maven.reporting.MavenReport.isExternalReport()

    /**
* An external report is a report which calls a third party program which generates some reports too.
     * A good example is javadoc tool.
     *
* @return <tt>true</tt> if this report is external, <tt>false</tt> otherwise.
     * Default should be <tt>false</tt>.
     */
    boolean isExternalReport();


Op Tue, 11 Dec 2012 23:42:43 +0100 schreef Baptiste Gaillard <baptiste.gaill...@gomoob.com>:

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

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@maven.apache.org
For additional commands, e-mail: users-h...@maven.apache.org

Reply via email to