Re: Multiple executions of goals under generate-sources: How to avoid?
The approach that I used could be applied for any mojo. Below is an outline of the basic code I used in the mojo execute() method. I simply create a new property (generation.finished) that I can check for on subsequent executions of the mojo: -- Object generationFinished = this.mavenProject.getProperties().get(generation.finished); boolean generationIsFinished = (generationFinished == null) ? false: true; if (generationIsFinished) { getLog().info(skipping code generation ... source code is up to date); } else { getLog().info(Starting code generation ...); ... .. . // mark the code generation as complete: this.mavenProject.getProperties().put(generation.finished, true); } -- ZsJoska wrote: Do you have a sample for doing that? It's your solution generic? I have a web services client application where I generate the artifact sources during the generate-sources phase. In order to import the latest version of the wsdl I try to kick-up a jetty server with the war produced by another module. The second execution of the jetty stops the build with error Address already in use. Thanks, Jozsef stug23 wrote: Lacking any other solution I went ahead and incorporated an internal Maven property that gets set at the end of the first code generation in the lifecycle. That way subsequent checks of the property provide an indication to skip code generation. This seems kind of kludgy but it works -- View this message in context: http://www.nabble.com/Multiple-executions-of-goals-under-generate-sources%3A-How-to-avoid--tp20038097p25207750.html Sent from the Maven - Users mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@maven.apache.org For additional commands, e-mail: users-h...@maven.apache.org
Re: Multiple executions of goals under generate-sources: How to avoid?
Do you have a sample for doing that? It's your solution generic? I have a web services client application where I generate the artifact sources during the generate-sources phase. In order to import the latest version of the wsdl I try to kick-up a jetty server with the war produced by another module. The second execution of the jetty stops the build with error Address already in use. Thanks, Jozsef stug23 wrote: Lacking any other solution I went ahead and incorporated an internal Maven property that gets set at the end of the first code generation in the lifecycle. That way subsequent checks of the property provide an indication to skip code generation. This seems kind of kludgy but it works -- View this message in context: http://www.nabble.com/Multiple-executions-of-goals-under-generate-sources%3A-How-to-avoid--tp20038097p25188704.html Sent from the Maven - Users mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@maven.apache.org For additional commands, e-mail: users-h...@maven.apache.org
Re: Multiple executions of goals under generate-sources: How to avoid?
Lacking any other solution I went ahead and incorporated an internal Maven property that gets set at the end of the first code generation in the lifecycle. That way subsequent checks of the property provide an indication to skip code generation. This seems kind of kludgy but it works stug23 wrote: As a clarification, the execution that I am trying to avoid is the second execution of a code generator mojo that is bound to generate-sources phase. The second execution results from uses the maven-sources-plugin which states: Invokes the execution of the lifecycle phase generate-sources prior to executing itself. The information above is from the following reference: http://maven.apache.org/plugins/maven-source-plugin/jar-mojo.html So my question is: Is there a way to still produce a sources jar using the maven-source-plugin without invoking execution of the generate-sources phase? It doesn't make sense to me that this invocation cannot be switched off since the code generation has already taken place and it's not very efficient to perform code generation all over again in a subsequent lifecycle phase. Perhaps there are cases where this is needed, but mine is not one of them, so I am hoping that someone can help me to disable this feature of the maven-source-plugin. TIA stug23 wrote: I am working on a code generator plugin that ends up being executed multiple times when in fact I only want it to execute once in the generate-sources phase. According to this posting http://www.mail-archive.com/users@maven.apache.org/msg78484.html this is an expected behavior. How do I avoid multiple executions of my code generator which needs to run in the generate-sources phase? TIA -- View this message in context: http://www.nabble.com/Multiple-executions-of-goals-under-generate-sources%3A-How-to-avoid--tp20038097p20057662.html Sent from the Maven - Users mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Multiple executions of goals under generate-sources: How to avoid?
As a clarification, the execution that I am trying to avoid is the second execution of a code generator mojo that is bound to generate-sources phase. The second execution results from uses the maven-sources-plugin which states: Invokes the execution of the lifecycle phase generate-sources prior to executing itself. The information above is from the following reference: http://maven.apache.org/plugins/maven-source-plugin/jar-mojo.html So my question is: Is there a way to still produce a sources jar using the maven-source-plugin without invoking execution of the generate-sources phase? It doesn't make sense to me that this invocation cannot be switched off since the code generation has already taken place and it's not very efficient to perform code generation all over again in a subsequent lifecycle phase. Perhaps there are cases where this is needed, but mine is not one of them, so I am hoping that someone can help me to disable this feature of the maven-source-plugin. TIA stug23 wrote: I am working on a code generator plugin that ends up being executed multiple times when in fact I only want it to execute once in the generate-sources phase. According to this posting http://www.mail-archive.com/users@maven.apache.org/msg78484.html this is an expected behavior. How do I avoid multiple executions of my code generator which needs to run in the generate-sources phase? TIA -- View this message in context: http://www.nabble.com/Multiple-executions-of-goals-under-generate-sources%3A-How-to-avoid--tp20038097p20047618.html Sent from the Maven - Users mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Multiple executions of goals under generate-sources: How to avoid?
On Sat, Oct 18, 2008 at 11:00 AM, stug23 [EMAIL PROTECTED] wrote: So my question is: Is there a way to still produce a sources jar using the maven-source-plugin without invoking execution of the generate-sources phase? I am extremely interested in the answer to this question as well. Please Maven experts, help! :-) -jieryn - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Multiple executions of goals under generate-sources: How to avoid?
I am working on a code generator plugin that ends up being executed multiple times when in fact I only want it to execute once in the generate-sources phase. According to this posting http://www.mail-archive.com/users@maven.apache.org/msg78484.html this is an expected behavior. How do I avoid multiple executions of my code generator which needs to run in the generate-sources phase? TIA -- View this message in context: http://www.nabble.com/Multiple-executions-of-goals-under-generate-sources%3A-How-to-avoid--tp20038097p20038097.html Sent from the Maven - Users mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]