基本maven插件项目无法正常工作,Mojo插件描述符无法生成 [英] Basic maven plugin project not working, Mojo plugin descriptors not generating

查看:269
本文介绍了基本maven插件项目无法正常工作,Mojo插件描述符无法生成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在关注创建maven插件的教程,但无法运行安装mvn而不会出错。信息抱怨说,当注释应该为我生成时,我没有所需的mojo描述符。我正在运行maven 3.0.5并使用intellij作为我的ide。这是我的主类:

I am following the tutorial for creating a maven plugin and cannot run mvn install without getting errors. The info complains that i don't have the required mojo descriptors when the annotations should be generating them for me. I am running maven 3.0.5 and using intellij as my ide. here is my Main class:

@Mojo(name = "modify-connector")
public class ComplianceMojo extends AbstractMojo {

    @Parameter
    private String artifactId;

    @Parameter
    private String version;

    @Override
    public void execute() throws MojoExecutionException, MojoFailureException {
        File jar = new File(getPluginContext().get("project.build.directory") + "/"
                + getPluginContext().get("project.build.finalname") + "/" + artifactId + "-" + version);
        if(jar.exists()){
            getLog().info("The file exists! " + jar.getAbsolutePath());
        } else {
            getLog().info("The file does not exist: " + jar.getAbsolutePath());
        }
    }
}

这是我的pom。 xml

And here is my pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>mysql-jdbc-compliance-maven-plugin</groupId>
    <artifactId>mysql-jdbc-compliance-maven-plugin</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>maven-plugin</packaging>

    <dependencies>
        <dependency>
            <groupId>org.apache.maven</groupId>
            <artifactId>maven-plugin-api</artifactId>
            <version>2.0</version>
        </dependency>
        <dependency>
            <groupId>org.apache.maven.plugin-tools</groupId>
            <artifactId>maven-plugin-annotations</artifactId>
            <version>3.2</version>
            <scope>provided</scope>
        </dependency>
    </dependencies>

</project>

注意:我必须单独添加注释依赖项作为主插件api不包含这些类。当我在我的项目上运行mvn install时,输出如下:

Note: I had to separately add the annotations dependency as the main plugin api did not contain these classes. when i run mvn install on my project, the output is as follows:

[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.867s
[INFO] Finished at: Wed Sep 25 17:45:55 EST 2013
[INFO] Final Memory: 8M/244M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-plugin-plugin:2.9:descriptor (default-descriptor) on project mysql-jdbc-compliance-maven-plugin: Error extracting plugin descriptor: 'No mojo definitions were found for plugin: mysql-jdbc-compliance-maven-plugin:mysql-jdbc-compliance-maven-plugin.' -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException


推荐答案

阅读完之后 Gyro发布的Jira问题,我将以下几行添加到我的pom和所有内容中很好地编译。

after reading the Jira Issue that Gyro posted, i added the following lines to my pom and everything compiled nicely.

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-plugin-plugin</artifactId>
            <version>3.2</version>
            <configuration>
                <goalPrefix>mysql-jdbc-compliance</goalPrefix>
            </configuration>
            <executions>
                <execution>
                    <id>default-descriptor</id>
                    <goals>
                        <goal>descriptor</goal>
                    </goals>
                    <phase>process-classes</phase>
                </execution>
                <execution>
                    <id>help-descriptor</id>
                    <goals>
                        <goal>helpmojo</goal>
                    </goals>
                    <phase>process-classes</phase>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

这篇关于基本maven插件项目无法正常工作,Mojo插件描述符无法生成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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