为什么Maven找不到我的自定义Mojo? [英] Why can Maven not find my custom Mojo?
本文介绍了为什么Maven找不到我的自定义Mojo?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有自己的Mojo课程。
I have an own Mojo class.
@Mojo(name="mojo", threadSafe=true)
public class MyMojo extends AbstractMojo
{
@Component
private MavenProject project;
public void execute() throws MojoExecutionException, MojoFailureException
{
getLog().info("Execute");
}
}
之后我将它安装在本地存储库中。
After that I install it in local repository.
[INFO] Applying mojo extractor for language: java-annotations
[INFO] Mojo extractor for language: java-annotations found 0 mojo descriptors.
[INFO] Applying mojo extractor for language: java
[INFO] Mojo extractor for language: java found 0 mojo descriptors.
[INFO] Applying mojo extractor for language: bsh
[INFO] Mojo extractor for language: bsh found 0 mojo descriptors.
....
[INFO] BUILD SUCCESS
但是当试图调用'mojo'目标我得到了错误
But when try to call 'mojo' goal I got en error
[ERROR] Could not find goal 'mojo' in plugin my.plugins:my-plugin:1.0-SNAPSHOT among available goals -> [Help 1]
what is the problem?
这是maven-plugin-plugin配置。
Here is maven-plugin-plugin configuration.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-plugin-plugin</artifactId>
<version>3.2</version>
<configuration>
<skipErrorNoDescriptorsFound>true</skipErrorNoDescriptorsFound>
</configuration>
</plugin>
使用javadoc注释的旧机制运行良好,但我想使用java注释。
Old mechanism with javadoc annotations works well, but i want to use java annotation.
<dependency>
<groupId>org.apache.maven.plugin-tools</groupId>
<artifactId>maven-plugin-annotations</artifactId>
<version>3.2</version>
</dependency>
[INFO] --- maven-plugin-plugin:3.2:descriptor (default-descriptor) @ bla-mvn-plugin
为什么启用默认描述符而不是mojo-descriptor?
Why default-descriptor is enabled instead of mojo-descriptor?
推荐答案
将此部分添加到插件的POM中:
Add this section to your plugin's POM:
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-plugin-plugin</artifactId>
<version>3.2</version>
<configuration>
<skipErrorNoDescriptorsFound>true</skipErrorNoDescriptorsFound>
</configuration>
<executions>
<execution>
<id>mojo-descriptor</id>
<phase>process-classes</phase>
<goals>
<goal>descriptor</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
</build>
PS。请参阅maven-compiler-plugin:3.0源代码,了解使用注释构建MOJO的完整工作示例
PS. See maven-compiler-plugin:3.0 sources for full working example of building MOJOs with annotations
这篇关于为什么Maven找不到我的自定义Mojo?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文