-
Notifications
You must be signed in to change notification settings - Fork 56
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
[MPLUGIN-450] Require goalPrefix to be valid #240
Conversation
5b4168e
to
0b27ea3
Compare
maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/AbstractGeneratorMojo.java
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change then deserves a new minor version
@gnodet Please go ahead: squash, rebase and merge. I will take care of the next minor release. |
Updating to the last version breaks my plugin builds and I don't know what needs to be specified for goalPrefix. I also can not find good documentation for it. |
Same with me - apache/creadur-rat#190 |
https://maven.apache.org/plugin-tools/maven-plugin-plugin/helpmojo-mojo.html#goalPrefix In short, just add this to maven-plugin-plugin configuration:
|
I guess @ottlinger will use now:
|
mmmmh - I thought apache-rat or do I misinterpret what the goal-prefix is? I thought it is a fully qualified name? |
According to doco it is |
@gnodet the JIRA mentions
but it seems there is no such option as far as I can see? Can the "heuristics" maybe be enhanced to also accept e.g in Tycho there are several plugins named e.g. I also see some risk that different plugins now they are forced to, choose some prefix that clashes in the name. |
You should file a JIRA issue for any request which we can explore together... |
AFAIK it always had been the case, the heuristic always had been considered bad but put there by compatibility when it got realized. |
I have now created: I don't see any issue that can arise from the default (beside that the prefix is maybe longer than one wants) but why enforce it to specify what the plugin was able to decide for years without a problem? Also not that there is a lot of plugins that will never really be called from cli .... so it is not true that before there was no prefix, it has always chosen one that seem to fit most purposes. |
We got issues with plugins wrongly naming the artifactId (not respecting
All plugins can be called at some point from the cli. |
All this can happen with a configured prefix as well... And as said if one is "surprised" can still configure it already but not it fails for all "non surprising" cases as well. |
@laeubi well I'm not sure cause no it cant happen. You can get conflicts but no surprise nor wrong behavior if explicit compared to an almost random heuristic. |
Until now no one could give an example of "random" behavior, so can you show where this random part happen? For me it was (and is) completely deterministic as for each given input it always gives the same output. Especially it seems that two projects ( It was simply assumed (what obviously is wrong) that:
So obviously the assumption that anything that do not matches |
s/random/uncontrolled or unknown/ and this is the issue, when then the plugin wants to take control cause you don't want to type my-plugin-foo or anything else then you break backward compat of the runtime so better to adjust the tooling (build only, note there is no breaking change for the runtime).
No, you can review the previous code, if the artifactId does not follow maven convention then the heuristic is just failing and returns null leading to no prefix in plugin.xml. Indeed we can relax a bit the fix Guillaume did to keep the heuristic and warn the user it should be set explicitly to ensure it is under control but I guess the best is just current code which is the most straight forward for anyone, once the error message is explicit the fix is trivial for anyone and there wouldn't be much discussion I think. That said I would be ok if we do this change only for maven 4 and keep maven 3 as this but I think it goes in the right direction enhancing the quality of the built plugins and the warning would just be as bothering as an error so let's keep it an error for the final deliverable. Side note: if you don't know the prefix you were using you can also rely on the doc, as of today, since it is explicit there, you can review https://tycho.eclipseprojects.io/doc/latest/tycho-compiler-plugin/plugin-info.html for example. |
This recommendation together with this fact
confuses me... so how can I lookup something that isn't there? So I think the error is correct if it is truly empty... but not for cases where it has something else, then one might warn that the prefix is probably not as expected (where its a bit unclear what users will expect, maybe nothing much if they never checked the prefix...). |
@laeubi ok, so if I rephrase the questions are IMHO:
So discussion is mainly about 1, I think a warning wouldnt help and an error is the right thing to do - warnings tend to be ignored or avoided as an error so both cases make it useless so it is either considered ok - half of the cases are not as mentionned - so I think error is better for that reason even if it means some people will have to explicit the prefix even if the heuristic was ok-ish for them (note that rat is one example it was not ok, the Hope it helps to follow my reasoning a bit. |
As mentioned, I never used that prefix, and no one has ever complained it is wrong/to long / ... so it simply wasn't an issue before. I now learned it shows up in the docs, and I probably could have omitted some infos in the rare cases where I called a mojo from CLI. So for (1) it seems a lot of users where happy with that, for (2) as said it seams reasonable to give an error as it is obviously not getting anything useful here.
But why don't these user ever complained so the prefix was added before this change? why is Also the shorter the higher the risk of name-clashes can maven handle this if two plugins use the same prefix or will it make these two plugins incompatible to be used in the same build? Or will it even be "random" (maybe by some ordering in the pom) what is chosen? |
I assume you mean for tycho case but it is really done under the carpet so 50-50 IMHO (implicit case is actually rare from what I saw so not sure it is numerous enough to do stats :D).
You mix two things there: the producer and consumer sides. There is no change for consumers (users), it only changes the way the producer sets the prefix.
Don't think it is what you mean but didn't say
This is not true, not sure why you say that.
Only if referenced from the prefix, not in all other cases. |
I don't mix anything, but that's actually the point, now the producer is forced to set something so it stays as before, because consumers before have never complained obviously that they want some change. So neither producer nor consumer requested for such feature / change, but now are facing to take actions e.g. producer needs to replicate previously automatic info, consumer might need to change because producer has decided to if setting the prefix it should be changed to something else (like for rat vs apache-rat).... e.g. for the tycho case I now need to add 24 useless duplication in the config that was previously perfectly derived without a problem and users never where unhappy enough to open an issue > 10 years: and code does not seems become "better" from that change. |
I don't understand what you mean, I read it like "because [consumers] are not impacted they would have to be impacted", so not sure the point.
Isn't it always the case when there was a design issue in a tool and it gets fixed? Nobody asked to configure a filter for RMI serialization, it is the same there.
on the user point please see previous comment, it is normal they never complained since this fix does not impact them
Looks good and now you control your produced plugin and you will not break your command lines (ci) even if you refactor your gav to comply to maven recommended pattern (x-maven-plugin, not x-plugin), this sounds way better to me. |
JIRA issue: https://issues.apache.org/jira/browse/MPLUGIN-450