最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

java - How to create Parameterized OpenRewrite Style - Stack Overflow

programmeradmin2浏览0评论

I would like to create a shared OpenRewrite Style that, among other things, defines the import order such that there is a variable in the layout. For example:

type: specs.openrewrite/v1beta/style
name: .example.ParameterizedStyle
styleConfigs:
  # .... more styles ...
  - .openrewrite.java.style.ImportLayoutStyle:
      classCountToUseStarImport: 999
      nameCountToUseStarImport: 999
      layout:
        - import java.*
        - <blank line>
        - import javax.*
        - <blank line>
        - import all other imports
        - <blank line>
        - import ${projectRootPackage}.*
        - <blank line>
        - import static all other imports

I'd like users of my shared style to be able to then use my shared style and provide the variable projectRootPackage.

Ideally, in Maven and Gradle projects, I'd also like to be able to default the projectRootPackage value to be the group without needing to write Maven or Gradle plugins (e.g. be able to pass the value through the existing DSL).

Does anyone have any hints as to how I can do this?

发布评论

评论列表(0)

  1. 暂无评论