Krzysztof Jabłoński
Krzysztof Jabłoński

Reputation: 1941

specify default goal for all plugin executions

I'm going to have multiple executions of my custom maven plugin written into my project's pom.xml. My config went like this:

...
<build>
  <plugins>
    <plugin>
      <groupId>myGroupId</groupId>
      <artifactId>pluginId</artifactId>
      <executions>
        <execution>
          <id>ex-1</id>
          <goals>
            <goal>goal-name</goal>
          </goals>
          <configuration>
            <option>value_1</option>
          </configuration>
        </execution>
        <execution>
          <id>ex-2</id>
          <goals>
            <goal>goal-name</goal>
          </goals>
          <configuration>
            <option>value_2</option>
          </configuration>
        </execution>
        <!-- quite plenty more executions here -->
      </executions>
      <configuration>
        <commonOption>common_value</commonOption>
      </configuration>
    </plugin>
  </plugins>
</build>
...

... all along with maven specs, just like in the examples and it works ok.

But there is quiet a lot of redundancy - every execution (about 20 of them) have own section of goals, and all of them have the exact same one goal specified. Thought to myself - I'd specify one default in plugin section. Looked into maven pom xml-schema and - hooray, there is an option for that. I've gone up to the following:

...
<build>
  <plugins>
    <plugin>
      <groupId>myGroupId</groupId>
      <artifactId>pluginId</artifactId>
      <executions>
        <execution>
          <id>ex-1</id>
          <configuration>
            <option>value_1</option>
          </configuration>
        </execution>
        <execution>
          <id>ex-2</id>
          <configuration>
            <option>value_2</option>
          </configuration>
        </execution>
        <!-- same plenty more executions changed likewise -->
      </executions>
      <goals>
        <goal>goal-name</goal>
      </goals>
      <configuration>
        <commonOption>common_value</commonOption>
      </configuration>
    </plugin>
  </plugins>
</build>
...

... and bam! it doesn't work. Pom is being parsed, project is built, but plugin is not executed - not even once. Why? Am I mistaken, or something? Lack of feature in maven? Bug?

Upvotes: 3

Views: 1699

Answers (1)

user944849
user944849

Reputation: 14951

According to the Maven Model documentation the goals element in plugin is deprecated and unused by Maven.

Upvotes: 4

Related Questions