2

I'm playing around with writing a maven plugin for the first time. I've written a simple plugin with a goal that writes a hello world message to the output. I've also used the @phase annotation to create a default binding to the install lifecycle phase. This shows up in my plugin.xml as install element of my mojo element.

My understanding is that I can now simply add this to my build.plugins section, without specifying any execution, and my plugin goal will execute during the install phase. This doesn't happen though. Here's the configuration that doesn't create any exeuction of my goal:

<build>

    <plugins>
        <plugin>
            <groupId>com.emc.chad</groupId>
            <artifactId>hello-plugin</artifactId>
            <version>0.0.1-SNAPSHOT</version>
        </plugin>
    </plugins>
</build>  

However, if I change this to specify an execution explicitly, it works:

         <plugin>
            <groupId>com.emc.chad</groupId>
            <artifactId>hello-plugin</artifactId>
            <version>0.0.1-SNAPSHOT</version>
            <executions>
                <execution>
                    <id>test</id>
                    <phase>install</phase>
                    <goals>
                        <goal>hello</goal>
                    </goals>
                    <configuration>
                    </configuration>
                </execution>
            </executions>
        </plugin>

I understand why this works of course, but shouldn't the first work as well, considering my plugin.xml phase specification?

chad
  • 7,369
  • 6
  • 37
  • 56

0 Answers0