Execute Maven plugin goal on parent module, but not on children

前端 未结 5 1516
生来不讨喜
生来不讨喜 2020-12-08 01:47

We have a multi-module maven project that uses a profile that defines a buildnumber-maven-plugin to increment a build number and then check it into source control.

I

5条回答
  •  一整个雨季
    2020-12-08 02:31

    If the plugin is custom one and you have access to plugin MOJO code, you can mark the plugin as aggregator; if the expected behavior is applicable for all projects where plugin is to be used.

    As mentioned in Mojo API Specification ,

    Flags this Mojo to run it in a multi module way, i.e. aggregate the build with the set of projects listed as modules.

    Example,

    @Mojo(name = "createHF", inheritByDefault = false, aggregator = true)
    public class CreateHFMojo extends AbstractMojo {
    
    ..
    
    public void execute() throws MojoExecutionException, MojoFailureException {
     ....
    }
    
    ..
    
    }
    

    Detailed example on github.

提交回复
热议问题