openrewrite / openrewrite/rewrite

Allow partial update of maven plugin configuration

Open
#3,810 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement maven
Dominant language
Java
Stars
3.7k
Forks
570
Avg merge
13h 12m
Merged PRs (30d)
261

Description

What problem are you trying to solve?

Partial update of maven plugin configuration

What precondition(s) should be checked before applying this recipe?

N/A

Describe the situation before applying the recipe

<plugin>
  <groupId>io.swagger</groupId>
  <artifactId>swagger-codegen-maven-plugin</artifactId>
  <version>${swagger-codegen-maven-plugin-version}</version>
  <configuration>
    <inputSpec>${project.basedir}/src/main/resources/yaml/yamlfilename.yaml</inputSpec>
    <language>com.my.package.for.v1.GeneratorLanguage</language>
    <templateDirectory>myTemplateDir</templateDirectory>
    <output>${project.build.directory}/generated-sources</output>
    <apiPackage>${default.package}.handler</apiPackage>
    <modelPackage>${default.package}.model</modelPackage>
    <invokerPackage>${default.package}.handler</invokerPackage>
  </configuration>
</plugin>

Describe the situation after applying the recipe

<plugin>
  <groupId>io.swagger</groupId>
  <artifactId>swagger-codegen-maven-plugin</artifactId>
  <version>${swagger-codegen-maven-plugin-version}</version>
  <configuration>
    <inputSpec>${project.basedir}/src/main/resources/yaml/yamlfilename.yaml</inputSpec>
    <language>com.my.package.for.v2.GeneratorLanguage</language>
    <templateDirectory>myTemplateDir</templateDirectory>
    <output>${project.build.directory}/generated-sources</output>
    <apiPackage>${default.package}.handler</apiPackage>
    <modelPackage>${default.package}.model</modelPackage>
    <invokerPackage>${default.package}.handler</invokerPackage>
  </configuration>
</plugin>

Have you considered any alternatives or workarounds?

Reuse existing ChangePluginConfiguration recipe for straightforward/static configuration.

Any additional context

The tag hierarchy could change between plugin releases or when migrating from one to another plugin. So configuration elements could be customized by the teams and should be untouched. Looking for simple add/remove capabilities for tags under plugin configuration, so partial xml can be injected/removed.

Are you interested in contributing this recipe to OpenRewrite?

yes

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the existing ChangePluginConfiguration recipe and its tests, then compare how plugin configuration elements are selected and changed. The work is done when a partial configuration can update the language element in the example while preserving the other customized elements, with tests covering the requested add/remove behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
build-system
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.