Run a custom Maven goal without pom.xml

孤街浪徒 提交于 2020-01-03 08:26:09

问题


I have developed a Maven plugin. How to run custom Maven goal from a directory that does not contain a pom.xml?

E.g. mvn my.plugin:mygoal <- no pom.xml in this dir.


回答1:


You can set the requiresProject attribute of your MOJO to false:

Flags this Mojo to run inside of a project.

By default, it is true meaning that this MOJO requires a project (hence a POM). As such, you should have in your plugin:

@Mojo(requiresProject = false, ...)
public class MyMojo extends AbstractMojo  { ... }


来源:https://stackoverflow.com/questions/36860927/run-a-custom-maven-goal-without-pom-xml

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!