Skip to content

Latest commit

 

History

History
163 lines (135 loc) · 4.82 KB

changepluginexecutions.md

File metadata and controls

163 lines (135 loc) · 4.82 KB

Change Maven plugin executions

org.openrewrite.maven.ChangePluginExecutions

Apply the specified executions to a Maven plugin. Will not add the plugin if it does not already exist in the pom.

Source

GitHub, Issue Tracker, Maven Central

  • groupId: org.openrewrite
  • artifactId: rewrite-maven
  • version: 8.1.3

Options

Type Name Description
String groupId The first part of a dependency coordinate 'org.openrewrite.maven:rewrite-maven-plugin:VERSION'.
String artifactId The second part of a dependency coordinate 'org.openrewrite.maven:rewrite-maven-plugin:VERSION'.
String executions Optional. Plugin goal executions provided as raw XML. Supplying null will remove any existing executions.

Example

Parameters
Parameter Value
groupId org.openrewrite.maven
artifactId rewrite-maven-plugin
executions null

{% tabs %} {% tab title="pom.xml" %}

Before

{% code title="pom.xml" %}

<project>
    <groupId>org.example</groupId>
    <artifactId>foo</artifactId>
    <version>1.0</version>

    <build>
        <plugins>
            <plugin>
                <groupId>org.openrewrite.maven</groupId>
                <artifactId>rewrite-maven-plugin</artifactId>
                <version>4.1.5</version>
                <executions>
                    <execution>
                        <phase>validate</phase>
                        <goals><goal>dryRun</goal></goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>

{% endcode %}

After

{% code title="pom.xml" %}

<project>
    <groupId>org.example</groupId>
    <artifactId>foo</artifactId>
    <version>1.0</version>

    <build>
        <plugins>
            <plugin>
                <groupId>org.openrewrite.maven</groupId>
                <artifactId>rewrite-maven-plugin</artifactId>
                <version>4.1.5</version>
            </plugin>
        </plugins>
    </build>
</project>

{% endcode %}

{% endtab %} {% tab title="Diff" %} {% code %}

--- pom.xml
+++ pom.xml
@@ -12,6 +12,0 @@
                <artifactId>rewrite-maven-plugin</artifactId>
                <version>4.1.5</version>
-               <executions>
-                   <execution>
-                       <phase>validate</phase>
-                       <goals><goal>dryRun</goal></goals>
-                   </execution>
-               </executions>
            </plugin>

{% endcode %} {% endtab %} {% endtabs %}

Usage

This recipe has required configuration parameters. Recipes with required configuration parameters cannot be activated directly. To activate this recipe you must create a new recipe which fills in the required parameters. In your rewrite.yml create a new recipe with a unique name. For example: com.yourorg.ChangePluginExecutionsExample. Here's how you can define and customize such a recipe within your rewrite.yml:

{% code title="rewrite.yml" %}

---
type: specs.openrewrite.org/v1beta/recipe
name: com.yourorg.ChangePluginExecutionsExample
displayName: Change Maven plugin executions example
recipeList:
  - org.openrewrite.maven.ChangePluginExecutions:
      groupId: org.openrewrite.maven
      artifactId: rewrite-maven-plugin
      executions: <execution><phase>validate</phase><goals><goal>dryRun</goal></goals></execution>

{% endcode %}

Now that com.yourorg.ChangePluginExecutionsExample has been defined activate it in your build file: {% tabs %}

{% tab title="Maven" %} {% code title="pom.xml" %}

<project>
  <build>
    <plugins>
      <plugin>
        <groupId>org.openrewrite.maven</groupId>
        <artifactId>rewrite-maven-plugin</artifactId>
        <version>5.2.4</version>
        <configuration>
          <activeRecipes>
            <recipe>com.yourorg.ChangePluginExecutionsExample</recipe>
          </activeRecipes>
        </configuration>
      </plugin>
    </plugins>
  </build>
</project>

{% endcode %} {% endtab %} {% endtabs %}

Contributors

See how this recipe works across multiple open-source repositories

Moderne Link Image

The community edition of the Moderne platform enables you to easily run recipes across thousands of open-source repositories.

Please contact Moderne for more information about safely running the recipes on your own codebase in a private SaaS.