在没有pom.xml的情况下运行自定义Maven目标 [英] Run a custom Maven goal without pom.xml

查看:336
本文介绍了在没有pom.xml的情况下运行自定义Maven目标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经开发了一个Maven插件.如何从不包含pom.xml的目录中运行自定义Maven目标?

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

例如mvn my.plugin:mygoal<-此目录中没有pom.xml.

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

推荐答案

您可以设置

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

将这个Mojo标记为在项目内部运行.

Flags this Mojo to run inside of a project.

默认情况下为true,表示此MOJO需要一个项目(因此为POM).因此,您应该在插件中添加

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  { ... }

这篇关于在没有pom.xml的情况下运行自定义Maven目标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆