简体   繁体   English

Maven 从父 pom 中的命令行调用插件

[英]Maven calling plugin from command line in parent pom

My project sturcture:我的项目结构:

 - something-parent -- something-one -- something-two

something-parent -> pom.xml : something-parent -> pom.xml

 <packaging>pom</packaging> <modules> <module>something-one</module> <module>something-two</module> </modules> <build> <plugins> <plugin> <groupId>io.github.something</groupId> <artifactId>something-maven-plugin</artifactId> <version>1.0.0</version> </plugin> </plugins> </build>

Now I want to execute mvn something:help , but I can't: No plugin found for prefix 'something' .现在我想执行mvn something:help ,但我不能: No plugin found for prefix 'something'

If I remove modules section - it works.如果我删除modules部分 - 它有效。 It also works in other modules.它也适用于其他模块。

It just doesn't work in parent module with modules section.它只是在带有modules部分的父模块中不起作用。 I couldn't find any documentation or literally anything describing this, is this intended?我找不到任何文档或任何描述此内容的字面意思,这是故意的吗? Is there any workaround?有什么解决方法吗?

I know io.github.something:something-maven-plugin:1.0.0:help will work, but I need the shortcut version to work.我知道io.github.something:something-maven-plugin:1.0.0:help会工作,但我需要快捷方式版本才能工作。

//Edit1 - I know about settings.xml solution, but it requires manual edit by user, I would like something on a project level //Edit1 - 我知道settings.xml解决方案,但它需要用户手动编辑,我想要项目级别的东西

//Edit2 - found out another quirk, it works when I do mvn something:help -N //Edit2 - 发现了另一个怪癖,当我做mvn something:help -N时它起作用了

I understand that you want to use a short name to refer the plugin when calling it from the command line.我知道您想在从命令行调用插件时使用短名称来引用它。 To do that, you have to define a plugin group in your settings.xml, as of https://maven.apache.org/settings.html#plugin-groups In your case it would be:为此,您必须在 settings.xml 中定义一个插件组,截至https://maven.apache.org/settings.html#plugin-groups在您的情况下它将是:

<pluginGroups>
   <pluginGroup>io.github.something</pluginGroup>
</pluginGroups>

This allows you to call:这允许您调用:

mvn something:goal

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM