Java Maven MOJO - getting information from project POM

后端 未结 5 785
醉话见心
醉话见心 2021-02-05 02:50

I am working on a maven plugin. I seem to have a hard time figuring out, what would be a good way to get POM information from project in which you execute the MOJO ?

For

5条回答
  •  旧时难觅i
    2021-02-05 03:30

    You can inject the current maven project into your mojo with a field declared like this:

    /**
     * @parameter default-value="${project}"
     * @required
     * @readonly
     */
    MavenProject project;
    

    The projects name is then available by simply calling project.getName(). To use this API, you need to add the maven-project artifact as a dependency:

    
        org.apache.maven
        maven-project
        2.0.6
    
    

提交回复
热议问题