[ 
https://issues.apache.org/jira/browse/MPLUGIN-450?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17806668#comment-17806668
 ] 

ASF GitHub Bot commented on MPLUGIN-450:
----------------------------------------

rmannibucau commented on PR #240:
URL: 
https://github.com/apache/maven-plugin-tools/pull/240#issuecomment-1891500550

   > Especially it seems that two projects (tycho+apache-rat) that are using 
the convention <projectname>-plugin getting the same resulting prefix (== 
<projectname> ) so it can't be that random....
   
   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).
   The fix is *always* trivial: grab your last release read your plugin.xml and 
just configure it to be aligned.
   
   > So obviously the assumption that anything that do not matches 
*-maven-plugin *-maven-plugin got no prefix is wrong, you never get an empty 
prefix as claimed in the ticket.
   
   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.
   A common pattern I saw was to name the maven plugin "maven-plugin", then, 
due to the `Pattern.compile("-?(maven|plugin)-?").replaceAll("")` usage in the 
heuristic it was leading to no prefix.
   
   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.




> Make goal prefix mandatory by default
> -------------------------------------
>
>                 Key: MPLUGIN-450
>                 URL: https://issues.apache.org/jira/browse/MPLUGIN-450
>             Project: Maven Plugin Tools
>          Issue Type: Improvement
>          Components: Plugin Plugin
>            Reporter: Tamas Cservenak
>            Assignee: Guillaume Nodet
>            Priority: Major
>             Fix For: 3.11.0
>
>
> The goal prefix currently is not mandatory, and plugin uses heuristic to 
> figure it out, if possible (xxx-maven-plugin or maven-xxx-plugin, latter for 
> org.apache.maven plugins ONLY).
> In general, goal prefix is optional, but "good to have", and usually is 
> present.
> Cases when is not present, is when heuristics fails (so plugin module is not 
> named as "xxx-maven-plugin" or "maven-xxx-plugin") and user did not provide 
> one either. The cases when prefix is not present is mostly unintentional, but 
> maven-plugin-plugin leaves this without any remark or warning.
> IMHO, the maven-plugin-plugin should either warn, or even fail the build in 
> case when goal prefix is not present, but we may want to have some option to 
> turn off this feature (for me unknown reasons, where it would be expected to 
> NOT have goal prefix for a reason).
> TL;DR Am pretty much sure that in most of the cases when plugin developer 
> ends up with plugin without prefix, that it was unintentional (and causes 
> surprise later, not to mention refactoring the module name or POM change to 
> configure it), while there MAY be cases where goal prefix is not desired for 
> some reason (ie. plugin not mentioned for manual/CLI invocation). Simply put, 
> the out of the box defaults should enforce presence of it, while advanced 
> users still can produce prefix-less plugins with some extra configuration. 
> This would make things more explicit as well: even if plugin is named as 
> xxx-maven-plugin, configuration would be clear I do not want prefix for it.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to