Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

maven plugin descriptor not getting generated

I'm creating a maven plugin, MVN clean install build succeeds but plugin.xml is not getting generated.

@Mojo( name = "cover",  defaultPhase = LifecyclePhase.POST_INTEGRATION_TEST)
public class RunCoverage extends AbstractMojo
{

    @Parameter( property = "cover.wadl", defaultValue = "test")
    private String wadl;

    @Parameter( property = "cover.endpoints",defaultValue = "test")
    private String endpoints;

    @Override
    public void execute() throws MojoExecutionException
    {
        <somecode>
    }
}

And the pom.xml is

<?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>

    <artifactId>end-point-test-coverage</artifactId>
    <version>1</version>
    <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>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-plugin-plugin</artifactId>
                <version>3.2</version>
                <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>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.0.2</version>
                <configuration>
                    <source>1.6</source>
                    <target>1.6</target>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

Maven clean install doesn't generate plugin.xml

When used in a dependent project, I'm getting the following error

Failed to parse plugin descriptor for it.gruppopam.common:end-point-test-coverage:1 (/home/d/.m2/repository/it/common/end-point-test-coverage/1/end-point-test-coverage-1.jar): No plugin descriptor found at META-INF/maven/plugin.xml -> [Help 1] [ERROR]

like image 380
deepak Avatar asked Jan 06 '14 14:01

deepak


People also ask

What is Maven plugin descriptor?

The Maven Plugin Plugin is used to create a Maven plugin descriptor for any Mojo's found in the source tree, to include in the JAR. It is also used to generate report files for the Mojos as well as the artifact metadata and generating a generic help goal.

What is plugin descriptor?

The plugin descriptor is an XML file that describes a plugin and the modules contained within it for the host application. In a plugin project, the file is resides in the resources directory. In a plugin submission, the descriptor is located at the root of the plugin's jar file.


2 Answers

First i would try to set the packaging type to maven-plugin instead of the default which is jar. Furthermore i would suggest to use more up-to-date versions of plugins (maven-compiler-plugin: 3.1) and use a more up-to-date version of maven-plugin-api (3.0? but not 2.0).

like image 150
khmarbaise Avatar answered Dec 29 '22 01:12

khmarbaise


you have to remember to change it in your pom.xml to:

<packaging>maven-plugin</packaging>

it is by default:

<packaging>jar</packaging>
like image 27
Quimby Avatar answered Dec 29 '22 01:12

Quimby