当前位置: 首页 > news >正文

openrewrite 的rewrite.yml 编写注意事项

1发布给其它project使用,必须存放在META-INF/rewrite下

1.1

2Best practices

2.1A file may contain any number of recipes and styles, separated by —.
2.2必须full qualified,即包括完整的namespace/package
2.3自定义recipes不能放在org.openrewrite namespace下

3基本概念

3.1定义recipe和style

4Format

4.1

5Preconditions

5.1Preconditions only apply to files that already exist in the source set. They cannot prevent the creation of new files.
5.2Preconditions are used to limit which source files a recipe is allowed to make edits to
5.3可以是检查条件
5.3.1preconditions:

  • org.openrewrite.text.Find:
    find: 1
    5.4常见conditions
    5.4.1org.openrewrite.FindSourceFiles - limits the recipe to only run on files whose path matches a glob pattern
    5.4.2org.openrewrite.text.Find - limits the recipe to only run on files that contain a given string
    5.4.3org.openrewrite.java.search.FindTypes - limits the recipe to run only on source code which contain a given type
    5.4.4org.openrewrite.java.search.HasJavaVersion - limits the recipe to run only on Java source code with the specified source or target compatibility versions. Allowing a recipe to be targeted only at Java 8, 11, 17, etc., code.
    5.4.5org.openrewrite.java.search.IsLikelyTest - limits the recipe to run only on source code which is likely to be test code.
    5.4.6org.openrewrite.java.search.IsLikelyNotTest - limits the recipe to run only on source code which is likely to be production code.
    5.5自定义组合-or/and
    5.5.1example of or
type: specs.openrewrite.org/v1beta/recipe
name: org.sample.DoSomething
displayName: Do Something
preconditions:- org.sample.FindAnyJson
recipeList:- org.openrewrite.json.ChangeKey:oldKeyPath: $.foonewKey: bar
---
type: specs.openrewrite.org/v1beta/recipe
name: org.sample.FindAnyJson
recipeList:- org.openrewrite.FindSourceFiles:filePattern: "**/my.json"- org.openrewrite.FindSourceFiles:filePattern: "**/your.json"- org.openrewrite.FindSourceFiles:filePattern: "**/our.json"

6Style

6.1type: specs.openrewrite.org/v1beta/style
6.2example
6.2.1—

type: specs.openrewrite.org/v1beta/style
name: com.yourorg.YesTabsNoStarImports
styleConfigs:- org.openrewrite.java.style.TabsAndIndentsStyle:useTabCharacter: true- org.openrewrite.java.style.ImportLayoutStyle:classCountToUseStarImport: 9999

7dependency
7.1注意需要将相关recipe 归属artificial 加入到dependency
7.2example

 ---
type: specs.openrewrite.org/v1beta/recipe
name: com.radish.gz.MyStaticAnalysis
displayName: Test Common static analysis issues
description: Test of Resolve common static analysis issues (also known as SAST issues).
recipeList:- org.openrewrite.staticanalysis.AbstractClassPublicConstructor- org.openrewrite.staticanalysis.AtomicPrimitiveEqualsUsesGet- org.openrewrite.staticanalysis.BigDecimalDoubleConstructorRecipe- org.openrewrite.staticanalysis.BigDecimalRoundingConstantsToEnums
 <dependency>
<groupId>org.openrewrite.recipe</groupId>
<artifactId>rewrite-static-analysis</artifactId>
<scope>runtime</scope>
</dependency>

8运行态
8.1运行时候体系为composited recipe
8.2注意composite其实用到很多地方,在配置了多个recipe的运行时候,openrewrite会通过composited 来控制执行次序

http://www.dtcms.com/a/482013.html

相关文章:

  • 系统架构的平衡之道
  • 考研10.2笔记
  • Linux:传输层协议
  • 北京做网站建设的公司有哪些优化网站哪个好
  • 搭建网站工具抚州公司做网站
  • RK3588 + 银河麒麟部署 swarm 集群指南-续(自己应用程序部署)
  • 为什么我选择用 Rust 构建全栈后台管理系统?
  • 一篇文章讲清 UPD协议 与 TCP协议
  • 武邑网站建设价格wordpress 8小时
  • SSM高校职称申报系统337gs(程序+源码+数据库+调试部署+开发环境)带论文文档1万字以上,文末可获取,系统界面在最后面。
  • 深度解析:Linux sudo权限配置中的 %wheel ALL=(ALL:ALL) ALL 到底是什么意思?
  • d3.js:学习积累
  • ESLint
  • 大米CMS支付漏洞复现报告
  • SAP MM采购申请审批接口分享
  • 自定义类型:结构体、联合和枚举
  • iOS 是开源的吗?苹果系统的封闭与开放边界全解析(含开发与开心上架(Appuploader)实战)
  • 网站建设费 项目经费通用网址通用网站查询
  • 知道网站域名怎么联系wordpress插件的安装目录下
  • 网站建设价格与方案wordpress抓取别人网站
  • 服务网格 Service Mesh:微服务通信的终极进化
  • 计算机理论学习Day14
  • Spring Cloud OpenFeign + Nacos 实战教程:像调用本地方法一样调用远程微服务
  • Java求职面试: 互联网医疗场景中的缓存技术与监控运维应用
  • 【论文精读】InstanceCap:通过实例感知提升文本到视频生成效果
  • 如何将 iPhone 同步到新电脑而不会丢失数据
  • yolov8 检测
  • 男女性直接做的视频网站石家庄市城乡建设局网站
  • 有什么网站可以做婚庆视频素材平面设计公司企业logo设计
  • Python爬虫绕过Google reCAPTCHA终极指南