Skip to content

Commit 95e24f3

Browse files
committed
[Auto] Latest versions as of 2025-12-26T0105
1 parent a691a74 commit 95e24f3

File tree

9 files changed

+467
-61
lines changed

9 files changed

+467
-61
lines changed

docs/recipes/java/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ _Basic building blocks for transforming Java code._
88

99
## Categories
1010

11-
* [AI tools](/recipes/java/ai)
11+
* [Ai](/recipes/java/ai)
1212
* [Camel](/recipes/java/camel)
1313
* [Dependencies](/recipes/java/dependencies)
1414
* [Dropwizard](/recipes/java/dropwizard)
@@ -22,7 +22,7 @@ _Basic building blocks for transforming Java code._
2222
* [Micronaut](/recipes/java/micronaut)
2323
* [Modernize](/recipes/java/migrate)
2424
* [Netty](/recipes/java/netty)
25-
* [OpenRewrite best practices](/recipes/java/recipes)
25+
* [Recipes](/recipes/java/recipes)
2626
* [Search](/recipes/java/search)
2727
* [Security](/recipes/java/security)
2828
* [Spring](/recipes/java/spring)

docs/recipes/java/ai/README.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
---
2-
description: AI tools OpenRewrite recipes.
2+
description: Ai OpenRewrite recipes.
33
---
44

5-
# AI tools
6-
7-
_Tools for researching AI integrations._
5+
# AI
86

97
## Recipes
108

docs/recipes/java/recipes/README.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
---
2-
description: OpenRewrite best practices OpenRewrite recipes.
2+
description: Recipes OpenRewrite recipes.
33
---
44

5-
# OpenRewrite best practices
6-
7-
_Apply best practices to OpenRewrite recipes._
5+
# Recipes
86

97
## Composite Recipes
108

docs/recipes/json/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ _Basic building blocks for transforming JSON._
1616
* [Add value to JSON Object](./addkeyvalue.md)
1717
* [Change key](./changekey.md)
1818
* [Change value](./changevalue.md)
19+
* [Copy JSON value](./copyvalue.md)
1920
* [Create JSON file](./createjsonfile.md)
2021
* [Delete key](./deletekey.md)
2122

docs/recipes/json/copyvalue.md

Lines changed: 193 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,193 @@
1+
---
2+
sidebar_label: "Copy JSON value"
3+
---
4+
5+
import Tabs from '@theme/Tabs';
6+
import TabItem from '@theme/TabItem';
7+
8+
# Copy JSON value
9+
10+
**org.openrewrite.json.CopyValue**
11+
12+
_Copies a JSON value from one key to another. The existing key/value pair remains unaffected by this change. Attempts to create the new key if it does not exist._
13+
14+
## Recipe source
15+
16+
[GitHub](https://github.com/openrewrite/rewrite/blob/main/rewrite-json/src/main/java/org/openrewrite/json/CopyValue.java),
17+
[Issue Tracker](https://github.com/openrewrite/rewrite/issues),
18+
[Maven Central](https://central.sonatype.com/artifact/org.openrewrite/rewrite-json/)
19+
20+
This recipe is available under the [Apache License Version 2.0](https://www.apache.org/licenses/LICENSE-2.0).
21+
22+
## Options
23+
24+
| Type | Name | Description | Example |
25+
| --- | --- | --- | --- |
26+
| `String` | sourceKeyPath | A [JSONPath](https://www.rfc-editor.org/rfc/rfc9535.html) expression to locate a JSON value to copy. | `$.source.kind` |
27+
| `String` | sourceFilePath | *Optional*. The file path to the JSON file to copy the value from. If `null` then the value will be copied from any JSON file it appears within. | `src/main/resources/application.json` |
28+
| `String` | destinationKeyPath | A [JSONPath](https://www.rfc-editor.org/rfc/rfc9535.html) expression to locate the *parent* JSON entry. | `'$.subjects.*' or '$.' or '$.x[1].y.*' etc.` |
29+
| `String` | destinationKey | The key to create. | `myKey` |
30+
| `String` | destinationFilePath | *Optional*. The file path to the JSON file to copy the value to. If `null` then the value will be copied only into the same file it was found in. | `src/main/resources/application.json` |
31+
32+
33+
## Usage
34+
35+
This recipe has required configuration parameters. Recipes with required configuration parameters cannot be activated directly (unless you are running them via the Moderne CLI). 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.CopyValueExample`.
36+
Here's how you can define and customize such a recipe within your rewrite.yml:
37+
```yaml title="rewrite.yml"
38+
---
39+
type: specs.openrewrite.org/v1beta/recipe
40+
name: com.yourorg.CopyValueExample
41+
displayName: Copy JSON value example
42+
recipeList:
43+
- org.openrewrite.json.CopyValue:
44+
sourceKeyPath: $.source.kind
45+
sourceFilePath: src/main/resources/application.json
46+
destinationKeyPath: '$.subjects.*' or '$.' or '$.x[1].y.*' etc.
47+
destinationKey: myKey
48+
destinationFilePath: src/main/resources/application.json
49+
```
50+
51+
Now that `com.yourorg.CopyValueExample` has been defined, activate it in your build file:
52+
<Tabs groupId="projectType">
53+
<TabItem value="gradle" label="Gradle">
54+
55+
1. Add the following to your `build.gradle` file:
56+
```groovy title="build.gradle"
57+
plugins {
58+
id("org.openrewrite.rewrite") version("latest.release")
59+
}
60+
61+
rewrite {
62+
activeRecipe("com.yourorg.CopyValueExample")
63+
setExportDatatables(true)
64+
}
65+
66+
repositories {
67+
mavenCentral()
68+
}
69+
```
70+
2. Run `gradle rewriteRun` to run the recipe.
71+
</TabItem>
72+
<TabItem value="maven" label="Maven">
73+
74+
1. Add the following to your `pom.xml` file:
75+
76+
```xml title="pom.xml"
77+
<project>
78+
<build>
79+
<plugins>
80+
<plugin>
81+
<groupId>org.openrewrite.maven</groupId>
82+
<artifactId>rewrite-maven-plugin</artifactId>
83+
<version>{{VERSION_REWRITE_MAVEN_PLUGIN}}</version>
84+
<configuration>
85+
<exportDatatables>true</exportDatatables>
86+
<activeRecipes>
87+
<recipe>com.yourorg.CopyValueExample</recipe>
88+
</activeRecipes>
89+
</configuration>
90+
</plugin>
91+
</plugins>
92+
</build>
93+
</project>
94+
```
95+
2. Run `mvn rewrite:run` to run the recipe.
96+
</TabItem>
97+
<TabItem value="moderne-cli" label="Moderne CLI">
98+
99+
You will need to have configured the [Moderne CLI](https://docs.moderne.io/user-documentation/moderne-cli/getting-started/cli-intro) on your machine before you can run the following command.
100+
101+
```shell title="shell"
102+
mod run . --recipe CopyValue --recipe-option "sourceKeyPath=$.source.kind" --recipe-option "sourceFilePath=src/main/resources/application.json" --recipe-option "destinationKeyPath='$.subjects.*' or '$.' or '$.x[1].y.*' etc." --recipe-option "destinationKey=myKey" --recipe-option "destinationFilePath=src/main/resources/application.json"
103+
```
104+
105+
If the recipe is not available locally, then you can install it using:
106+
```shell
107+
mod config recipes jar install org.openrewrite:rewrite-json:{{VERSION_ORG_OPENREWRITE_REWRITE_JSON}}
108+
```
109+
</TabItem>
110+
</Tabs>
111+
112+
## See how this recipe works across multiple open-source repositories
113+
114+
import RecipeCallout from '@site/src/components/ModerneLink';
115+
116+
<RecipeCallout link="https://app.moderne.io/recipes/org.openrewrite.json.CopyValue" />
117+
118+
The community edition of the Moderne platform enables you to easily run recipes across thousands of open-source repositories.
119+
120+
Please [contact Moderne](https://moderne.io/product) for more information about safely running the recipes on your own codebase in a private SaaS.
121+
## Data Tables
122+
123+
<Tabs groupId="data-tables">
124+
<TabItem value="org.openrewrite.table.SourcesFileResults" label="SourcesFileResults">
125+
126+
### Source files that had results
127+
**org.openrewrite.table.SourcesFileResults**
128+
129+
_Source files that were modified by the recipe run._
130+
131+
| Column Name | Description |
132+
| ----------- | ----------- |
133+
| Source path before the run | The source path of the file before the run. `null` when a source file was created during the run. |
134+
| Source path after the run | A recipe may modify the source path. This is the path after the run. `null` when a source file was deleted during the run. |
135+
| Parent of the recipe that made changes | In a hierarchical recipe, the parent of the recipe that made a change. Empty if this is the root of a hierarchy or if the recipe is not hierarchical at all. |
136+
| Recipe that made changes | The specific recipe that made a change. |
137+
| Estimated time saving | An estimated effort that a developer to fix manually instead of using this recipe, in unit of seconds. |
138+
| Cycle | The recipe cycle in which the change was made. |
139+
140+
</TabItem>
141+
142+
<TabItem value="org.openrewrite.table.SearchResults" label="SearchResults">
143+
144+
### Source files that had search results
145+
**org.openrewrite.table.SearchResults**
146+
147+
_Search results that were found during the recipe run._
148+
149+
| Column Name | Description |
150+
| ----------- | ----------- |
151+
| Source path of search result before the run | The source path of the file with the search result markers present. |
152+
| Source path of search result after run the run | A recipe may modify the source path. This is the path after the run. `null` when a source file was deleted during the run. |
153+
| Result | The trimmed printed tree of the LST element that the marker is attached to. |
154+
| Description | The content of the description of the marker. |
155+
| Recipe that added the search marker | The specific recipe that added the Search marker. |
156+
157+
</TabItem>
158+
159+
<TabItem value="org.openrewrite.table.SourcesFileErrors" label="SourcesFileErrors">
160+
161+
### Source files that errored on a recipe
162+
**org.openrewrite.table.SourcesFileErrors**
163+
164+
_The details of all errors produced by a recipe run._
165+
166+
| Column Name | Description |
167+
| ----------- | ----------- |
168+
| Source path | The file that failed to parse. |
169+
| Recipe that made changes | The specific recipe that made a change. |
170+
| Stack trace | The stack trace of the failure. |
171+
172+
</TabItem>
173+
174+
<TabItem value="org.openrewrite.table.RecipeRunStats" label="RecipeRunStats">
175+
176+
### Recipe performance
177+
**org.openrewrite.table.RecipeRunStats**
178+
179+
_Statistics used in analyzing the performance of recipes._
180+
181+
| Column Name | Description |
182+
| ----------- | ----------- |
183+
| The recipe | The recipe whose stats are being measured both individually and cumulatively. |
184+
| Source file count | The number of source files the recipe ran over. |
185+
| Source file changed count | The number of source files which were changed in the recipe run. Includes files created, deleted, and edited. |
186+
| Cumulative scanning time (ns) | The total time spent across the scanning phase of this recipe. |
187+
| Max scanning time (ns) | The max time scanning any one source file. |
188+
| Cumulative edit time (ns) | The total time spent across the editing phase of this recipe. |
189+
| Max edit time (ns) | The max time editing any one source file. |
190+
191+
</TabItem>
192+
193+
</Tabs>

docs/recipes/kotlin/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ _Recipes to search and transform Kotlin._
1414
## Recipes
1515

1616
* [Find Kotlin sources and collect data metrics](./findkotlinsources.md)
17+
* [Order Kotlin imports](./orderimports.md)
1718
* [Rename type alias](./renametypealias.md)
1819

1920

docs/recipes/kotlin/cleanup/removetrailingsemicolon.md

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@ _Some Java programmers may mistakenly add semicolons at the end when writing Kot
1919

2020
This recipe is available under the [Apache License Version 2.0](https://www.apache.org/licenses/LICENSE-2.0).
2121

22-
## Examples
23-
##### Example 1
22+
## Example
2423

2524

2625
<Tabs groupId="beforeAfter">
@@ -62,18 +61,6 @@ fun method() {
6261
</TabItem>
6362
</Tabs>
6463

65-
---
66-
67-
##### Example 2
68-
69-
70-
###### Unchanged
71-
```kotlin
72-
fun method() {
73-
var foo = 1; var bar: Int
74-
}
75-
```
76-
7764

7865
## Usage
7966

docs/recipes/kotlin/cleanup/unnecessarytypeparentheses.md

Lines changed: 1 addition & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@ _In Kotlin, it's possible to add redundant nested parentheses in type definition
1919

2020
This recipe is available under the [Apache License Version 2.0](https://www.apache.org/licenses/LICENSE-2.0).
2121

22-
## Examples
23-
##### Example 1
22+
## Example
2423

2524

2625
<Tabs groupId="beforeAfter">
@@ -53,41 +52,6 @@ val y : Int = 42
5352
</TabItem>
5453
</Tabs>
5554

56-
---
57-
58-
##### Example 2
59-
60-
61-
<Tabs groupId="beforeAfter">
62-
<TabItem value="kotlin" label="kotlin">
63-
64-
65-
###### Before
66-
```kotlin
67-
val sum : (Int, Int) -> (Int) = { a, b -> a + b }
68-
val double : ((Int)) -> ((Int)) = { a -> a * 2 }
69-
```
70-
71-
###### After
72-
```kotlin
73-
val sum : (Int, Int) -> Int = { a, b -> a + b }
74-
val double : (Int) -> Int = { a -> a * 2 }
75-
```
76-
77-
</TabItem>
78-
<TabItem value="diff" label="Diff" >
79-
80-
```diff
81-
@@ -1,2 +1,2 @@
82-
-val sum : (Int, Int) -> (Int) = { a, b -> a + b }
83-
-val double : ((Int)) -> ((Int)) = { a -> a * 2 }
84-
+val sum : (Int, Int) -> Int = { a, b -> a + b }
85-
+val double : (Int) -> Int = { a -> a * 2 }
86-
87-
```
88-
</TabItem>
89-
</Tabs>
90-
9155

9256
## Usage
9357

0 commit comments

Comments
 (0)