You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by stug23 <pa...@gmail.com> on 2009/08/30 03:03:16 UTC
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-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org