Niels Basjes created MNG-8659:
---------------------------------

             Summary: Allow maven plugins to automatically run a Mojo without 
an explicit execution.
                 Key: MNG-8659
                 URL: https://issues.apache.org/jira/browse/MNG-8659
             Project: Maven
          Issue Type: Improvement
          Components: Plugin API
            Reporter: Niels Basjes


As discussed here 
[https://the-asf.slack.com/archives/C7Q9JB404/p1743258198334339]

Currently an externally developed Maven plugin NEEDS an explicit execution to 
be specified by the end user. In some cases this explicit execution definition 
makes things needlessly complex.

The idea is to allow the author of a maven plugin to specify which Mojos are to 
be run automatically if the plugin is included in a project.

So for example something like this should automatically run a subset of the 
available Mojos during their assigned defaultPhase.
{code:java}
<plugin>
  <groupId>nl.basjes.maven</groupId>
  <artifactId>my-special-maven-plugin</artifactId>
  <version>1.0.0</version>
  <configuration>
    <something>foo</something>
    <somemore>bar</somemore>
  </configuration>
</plugin> {code}
My proposal is to add an extra optional flag (default should be false) to the 
Mojo annotation that allows the developer to automatically have the Mojo 
started.

I propose a boolean named   {{autoExecution}}
With the meaning: 
{quote}If set to true then this Mojo will have an implied execution that will 
run the Mojo during the configured defaultPhase. This requires the defaultPhase 
to be configured!
{quote}
Then an author can do something like this:
{code:java}
@Mojo(name = "generate-main", defaultPhase = LifecyclePhase.GENERATE_SOURCES, 
threadSafe = true, autoExecution = true) {code}
 

I think this should use the execution ids already documented as the "implied 
execution ids" 
https://maven.apache.org/guides/mini/guide-default-execution-ids.html



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

Reply via email to