Writing a Maven Plugin/Mojo: how do you make a goal force the execution of other goals?

后端 未结 1 1167
轻奢々
轻奢々 2021-01-18 09:48

Note: this thread is about writing a custom Mojo, not using a plugin.

I maintain a testing plugin for Maven. Unfortunately, for almost a year now, I\'ve let

1条回答
  •  一整个雨季
    2021-01-18 10:31

    You could have something like the below (taken from the CompilerMojo):

    /**
     * @author Jason van Zyl 
     * @version $Id: CompilerMojo.java 941498 2010-05-05 21:24:11Z krosenvold $
     * @since 2.0
     * @goal compile
     * @phase compile
     * @threadSafe
     * @requiresDependencyResolution compile
     */
    

    By setting this over your class, it will execute during the compile phase (in this example). The compile phase requires all the previous phases to have executed first (validate, generate-sources, process-sources, generate-resources, process-resources...).

    Basically, pick a phase after the one you need (or even the same one) and it should work.

    0 讨论(0)
提交回复
热议问题