问题
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