Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 315
Krzysztof Jabłoński Avatar asked Jan 25 '26 13:01

Krzysztof Jabłoński


1 Answers

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

like image 108
user944849 Avatar answered Jan 28 '26 12:01

user944849



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!