Re: File lock problem in custom Maven Reporting Plugin
Hi Olivier, I've created a JIRA issue here http://jira.codehaus.org/browse/MSHARED-269with two project used to reproduce the problem. Thanks for the help guys, Baptiste 2012/12/19 Olivier Lamy ol...@apache.org Can you create a jira entry with a sample ? 2012/12/18 Baptiste Gaillard baptiste.gaill...@gomoob.com: Hi and thanks for the response, My Mojo already overwrites the isExternalReport() function and returns true into it. To deep a little more I've tried to debug the execution of the Mojo when running a 'mvn site' command using that Mojo. It seems that the function 'executeReport' associated to a reporting Mojo is called before 'isExternalReport' is used. The 'execute' method associated to the 'AbstractMavenReport' (I'm using 'maven-reporting-impl' version 2.2) class contains the following lines : Writer writer = null; try { File outputDirectory = new File( getOutputDirectory() ); String filename = getOutputName() + .html; Locale locale = Locale.getDefault(); SiteRenderingContext siteContext = new SiteRenderingContext(); siteContext.setDecoration( new DecorationModel() ); siteContext.setTemplateName( org/apache/maven/doxia/siterenderer/resources/default-site.vm ); siteContext.setLocale( locale ); RenderingContext context = new RenderingContext( outputDirectory, filename ); SiteRendererSink sink = new SiteRendererSink( context ); generate( sink, null, locale ); ... The 'generate' function then calls the reporting mojo 'executeReport' function, so I think my locking problems comes from one of the following calls : - 'new RenderingContext' - 'new SiteRendererSink' Do you have any other ideas ? Perhaps I should post this message on the developer Mailing List, my problems seems to be linked to what Maven (or the 'maven-reporting-impl plugin executes internally ? Thanks, Baptiste 2012/12/16 Robert Scholte rfscho...@apache.org 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 tttrue/tt if this report is external, ttfalse/tt otherwise. * Default should be ttfalse/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-unsubscribe@maven.**apache.org users-unsubscr...@maven.apache.org For additional commands,
Re: File lock problem in custom Maven Reporting Plugin
Can you create a jira entry with a sample ? 2012/12/18 Baptiste Gaillard baptiste.gaill...@gomoob.com: Hi and thanks for the response, My Mojo already overwrites the isExternalReport() function and returns true into it. To deep a little more I've tried to debug the execution of the Mojo when running a 'mvn site' command using that Mojo. It seems that the function 'executeReport' associated to a reporting Mojo is called before 'isExternalReport' is used. The 'execute' method associated to the 'AbstractMavenReport' (I'm using 'maven-reporting-impl' version 2.2) class contains the following lines : Writer writer = null; try { File outputDirectory = new File( getOutputDirectory() ); String filename = getOutputName() + .html; Locale locale = Locale.getDefault(); SiteRenderingContext siteContext = new SiteRenderingContext(); siteContext.setDecoration( new DecorationModel() ); siteContext.setTemplateName( org/apache/maven/doxia/siterenderer/resources/default-site.vm ); siteContext.setLocale( locale ); RenderingContext context = new RenderingContext( outputDirectory, filename ); SiteRendererSink sink = new SiteRendererSink( context ); generate( sink, null, locale ); ... The 'generate' function then calls the reporting mojo 'executeReport' function, so I think my locking problems comes from one of the following calls : - 'new RenderingContext' - 'new SiteRendererSink' Do you have any other ideas ? Perhaps I should post this message on the developer Mailing List, my problems seems to be linked to what Maven (or the 'maven-reporting-impl plugin executes internally ? Thanks, Baptiste 2012/12/16 Robert Scholte rfscho...@apache.org 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 tttrue/tt if this report is external, ttfalse/tt otherwise. * Default should be ttfalse/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-unsubscribe@maven.**apache.orgusers-unsubscr...@maven.apache.org For additional commands, e-mail: users-h...@maven.apache.org -- *Baptiste GAILLARD* *Mobile : +33(6) 85 12 81 26 http://+33%286%29%2085%2012%2081%2026%20/* *Mail :* *baptiste.gaill...@gomoob.com* *http://www.gomoob.com* * * ** * * -- Olivier Lamy Talend: http://coders.talend.com http://twitter.com/olamy | http://linkedin.com/in/olamy
Re: File lock problem in custom Maven Reporting Plugin
Hi and thanks for the response, My Mojo already overwrites the isExternalReport() function and returns true into it. To deep a little more I've tried to debug the execution of the Mojo when running a 'mvn site' command using that Mojo. It seems that the function 'executeReport' associated to a reporting Mojo is called before 'isExternalReport' is used. The 'execute' method associated to the 'AbstractMavenReport' (I'm using 'maven-reporting-impl' version 2.2) class contains the following lines : Writer writer = null; try { File outputDirectory = new File( getOutputDirectory() ); String filename = getOutputName() + .html; Locale locale = Locale.getDefault(); SiteRenderingContext siteContext = new SiteRenderingContext(); siteContext.setDecoration( new DecorationModel() ); siteContext.setTemplateName( org/apache/maven/doxia/siterenderer/resources/default-site.vm ); siteContext.setLocale( locale ); RenderingContext context = new RenderingContext( outputDirectory, filename ); SiteRendererSink sink = new SiteRendererSink( context ); generate( sink, null, locale ); ... The 'generate' function then calls the reporting mojo 'executeReport' function, so I think my locking problems comes from one of the following calls : - 'new RenderingContext' - 'new SiteRendererSink' Do you have any other ideas ? Perhaps I should post this message on the developer Mailing List, my problems seems to be linked to what Maven (or the 'maven-reporting-impl plugin executes internally ? Thanks, Baptiste 2012/12/16 Robert Scholte rfscho...@apache.org 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 tttrue/tt if this report is external, ttfalse/tt otherwise. * Default should be ttfalse/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-unsubscribe@maven.**apache.orgusers-unsubscr...@maven.apache.org For additional commands, e-mail: users-h...@maven.apache.org -- *Baptiste GAILLARD* *Mobile : +33(6) 85 12 81 26 http://+33%286%29%2085%2012%2081%2026%20/* *Mail :* *baptiste.gaill...@gomoob.com* *http://www.gomoob.com* * * ** * *
Re: File lock problem in custom Maven Reporting Plugin
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 tttrue/tt if this report is external, ttfalse/tt otherwise. * Default should be ttfalse/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