-
Notifications
You must be signed in to change notification settings - Fork 302
'runOnlyOnce' coupled with Maven's --projects param makes plugin not run at all #387
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Hi, Based on the doc the plugin is somewhat behaving as desired:
I'm not sure yet if setting some variables (e.g. user variables) would be the most reliable way. Especially when you run maven in parallel (e.g. |
…t all This commit fixes git-commit-id#387
@TheSnoozer you're right regarding the parallel execution. However I feel like the risk is lower than the benefits but I totally understand your concerns. I'll be interested if there is a best way to correct this problem. |
I need to look into that more carefully. Seems our The article states that the mavenAssemblyPlugin has adopted that...however they 'cheated' and called the option |
Your link to the Sonatype blog reminded me that I already discussed this exact same problem on the Maven mailing-list ( http://maven.40175.n5.nabble.com/Make-custom-plugin-executed-only-once-in-multimodule-inherited-false-aggregator-td5921630.html ) and... it seems there is no real solution :/ |
I've just realized that during the build, the Mojo is instantiated multiple times (once per module) but it is always the same class so maybe we could have a thread-safe static instance of something preventing concurrent access. It would be better that user variables. |
Unfortunately I don't see any obvious solution either and a popular search engine didn't yield any obvious results. The issue is simply that maven has it's many pitfalls.
I truly can understand your thinking behind raising this issue and would be happy to integrate it in some (reliable) way into the plugin. However at this stage I'd rather tend to say that the actual Feel free to add further comments if you actually find a working solution, but messing around with different classloaders and all cases I listed above seems a bit unpredictable for me (feel free to convince me wrong). For now I would say, yes the option is badly worded, but does exactly what is described in the documentation. |
Hello @TheSnoozer , and thanks for your long reply. 1- I've exeprimented on a large project (100 Maven modules) with running 'mvn initialize' with runOnlyOnce=true/false. 2- I'd rather have the plugin also run when a developper runs 'mvn install --projects submodule'. If it does not run, with this standard Maven command (which is recommanded over running the command directly inside the submodule) the developpers will randomly have git properties not initialized which may lead to jars containing incomplete infos. 3- So my conclusion is we must do something for this classic use-case. 4- Problem is how to do it ?
4.2- synchronized static variable in Mojo implementation
5- the plugin is going toward it's 3.0 release so it seems to me like the right time a change a bit of a feature that may break something (even though I do not see how it could break stuffs but I acknowlege there are many edge cases). But Itotally understand that you may not want to take the risk to break stuffs. Regards update1: for info, here is how the buildnumber-maven-plugin does with its 'getRevisionOnlyOnce' param: https://github.com/mojohaus/buildnumber-maven-plugin/blob/7faf13a6a67c5e7762f7cf3609178fedfd47c8d3/src/main/java/org/codehaus/mojo/build/CreateMojo.java#L273 |
Thanks for the lengthy reply and your understanding :-)
Mhh 400 submodules sounds a bit excessive, but in theory there should be nothing preventing you to do that. Just out of curiosity do you have
Having no properties when they are desired is really the worst case. We don't want that to happen under any circumstances.
Agree, when anyone uses the option it must be very clear that this might screw things badly when someone has multiple repositories.
Trust me I love breaking stuff :-P
Altogether (mainly due to backward compatibility) I would not mess with the My current assumptions and thinking would be introduce a new option Just thinking out loud about some corner cases (just a braindump)
What do you think about such |
I just got reminded of this issue and I think a few of the runtime issues will be solved with the 3.0.0 release I'm currently preparing. The 3.0.0 comes with
For details refer to the PR (#414) that I'm currently testing for the release :-) Also for some inspiration: However for now I have scheduled this for 3.0.1 since I think there is quite a lot stuff already in 3.0.0 that i really want to get shipped for a while now :-) |
…e it work when maven's --projects param are specified)
#387: make runOnlyOnce run on the first project (and make it work when maven's --projects param are specified)
Fixed/Implemented via: #443 |
Extensions are always run only once, so use https://github.com/pascalgn/properties-maven-extension |
Describe the bug
In the case of a multi-module Maven project, when we use the 'runOnlyOnce=true' parameter coupled with 'injectAllReactorProjects=true', we expect the plugin to run once to calculate all git variables and we expect those variables to be available in children projects.
But this is not the case when we run Maven on a specific sub-project:
mvn install --projects mySubProject
neither when we use this command to resume from a specific sub-project:
mvn install -rf mySubProject
Steps to Reproduce
Expected behavior
mvn install --projects mySubProject
we expect to see the verbose logs of all the variables calculated.
But in fact we get this:
[INFO] --- git-commit-id-plugin:2.2.5:revision (get-the-git-infos) @ mySubProject ---
[INFO] runOnlyOnce is enabled and this project is not the top level project, skipping execution!
Additional context
version tested is the last released: 2.2.5
My analysis:
The code in GitCommitMojo looks like
=> so the code expects to run at least once from Maven's ExecutionRootDirectory. But there it does not happen.
My suggestion is to set a variable (user variable ?) the first time the plugin is ran and when this variable is already set, we bypass the execution in case 'runOnlyOnce=true'
I will provide a Pull Request soon.
The text was updated successfully, but these errors were encountered: