Skip to content

Commit dbe16a4

Browse files
authored
Merge pull request #25 from Azure/split-spring-recipes
Split recipes sets into spring upgrade and asa, polish readme
2 parents b5d34a8 + 867d588 commit dbe16a4

File tree

2 files changed

+124
-66
lines changed

2 files changed

+124
-66
lines changed

README.md

Lines changed: 103 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,103 @@
1-
# azure-spring-rewrite
2-
3-
## how to use
4-
azure-spring-rewrite is released as a Github Maven package. To use it, you need to perform two steps:
5-
1) Configure authentication with a personal access token.
6-
7-
Go to your maven setting file, by default is $HOME/.m2/settings.xml, add azure-spring-rewrite repository and your github personal access token.
8-
9-
'''
10-
11-
<profiles>
12-
<profile>
13-
<id>github</id>
14-
<repositories>
15-
<repository>
16-
<id>central</id>
17-
<url>https://repo1.maven.org/maven2</url>
18-
</repository>
19-
<!-- add azure-spring-rewrite repository here -->
20-
<repository>
21-
<id>github</id>
22-
<url>https://maven.pkg.github.com/azure/azure-spring-rewrite</url>
23-
<snapshots>
24-
<enabled>true</enabled>
25-
</snapshots>
26-
</repository>
27-
</repositories>
28-
</profile>
29-
</profiles>
30-
<servers>
31-
<!-- add github personal access token -->
32-
<server>
33-
<id>github</id>
34-
<username>git username</username>
35-
<password>token</password>
36-
</server>
37-
</servers>
38-
39-
'''
40-
41-
You can refer to [authenticating-with-a-personal-access-token](https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-apache-maven-registry#authenticating-with-a-personal-access-token) for more information.
42-
43-
To create a personal access token, refer to [Creating a personal access token (classic)](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token#creating-a-personal-access-token-classic). Make sure you select the access to `read:packages` when creating token.
44-
45-
46-
2) Run maven command
47-
48-
```cmd
49-
./mvnw -U -Pgithub org.openrewrite.maven:rewrite-maven-plugin:run \
50-
"-Drewrite.activeRecipes=com.azure.spring.migration.UpgradeToAzureSpringApps" \
51-
"-Drewrite.recipeArtifactCoordinates=com.azure.spring.migration:azure-spring-rewrite:0.1.1"
52-
```
1+
# Azure Spring Rewrite
2+
3+
## Recipes
4+
5+
There are two sets of recipes available: one for upgrading Spring Boot/Spring Cloud and another for migrating to Azure Spring Apps.
6+
7+
### Upgrade Spring Boot/Spring Cloud
8+
9+
The recipe `com.azure.spring.migration.UpgradeSpringboot_2_7_SpringCloud_2021` upgrades your Spring Boot app to Spring Boot 2.7 and Spring Cloud 2021.
10+
11+
For a list of changes this recipe makes for the Spring Boot 2.7 upgrade, see [UpgradeSpringBoot_2_7](https://docs.openrewrite.org/reference/recipes/java/spring/boot2/upgradespringboot_2_7#definition).
12+
For the Spring Cloud 2021 upgrade, this recipe modifies the Spring Cloud version in the application's Maven POM file.
13+
14+
### Migrate to Azure Spring Apps
15+
16+
The recipe `com.azure.spring.migration.UpgradeToAzureSpringApps` checks your code and adds TODO comments in your application for migration to Azure Spring Apps.
17+
18+
The currently available list of check items includes:
19+
- Windows file path
20+
- File storage usage
21+
- Logging to console
22+
- Eureka and Config Server connection info
23+
- Password and user ID in configuration files
24+
- Java system load
25+
- Java system config
26+
27+
## How to Use
28+
29+
Azure-spring-rewrite is released as a GitHub Maven package. To use it, you need to perform two steps:
30+
1) **Configure authentication with a personal access token**
31+
32+
Go to your Maven settings file (by default, `$HOME/.m2/settings.xml`) and add the azure-spring-rewrite repository and your GitHub personal access token.
33+
You can refer to [authenticating-with-a-personal-access-token](https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-apache-maven-registry#authenticating-with-a-personal-access-token) for more information.
34+
35+
To create a personal access token, refer to [Creating a personal access token (classic)](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token#creating-a-personal-access-token-classic). Make sure you select access to `read:packages` when creating the token.
36+
```
37+
<profiles>
38+
<profile>
39+
<id>github</id>
40+
<repositories>
41+
<repository>
42+
<id>central</id>
43+
<url>https://repo1.maven.org/maven2</url>
44+
</repository>
45+
<!-- add azure-spring-rewrite repository here -->
46+
<repository>
47+
<id>github</id>
48+
<url>https://maven.pkg.github.com/azure/azure-spring-rewrite</url>
49+
<snapshots>
50+
<enabled>true</enabled>
51+
</snapshots>
52+
</repository>
53+
</repositories>
54+
</profile>
55+
</profiles>
56+
<servers>
57+
<!-- add github personal access token -->
58+
<server>
59+
<id>github</id>
60+
<username>username</username>
61+
<password>github personal access token</password>
62+
</server>
63+
</servers>
64+
```
65+
66+
67+
2) **Run rewrite plugin**
68+
69+
For maven projects, you can run maven command line under your application path:
70+
```cmd
71+
./mvnw -U -Pgithub org.openrewrite.maven:rewrite-maven-plugin:run "-Drewrite.activeRecipes=com.azure.spring.migration.UpgradeToAzureSpringApps, com.azure.spring.migration.UpgradeSpringboot_2_7_SpringCloud_2021" "-Drewrite.recipeArtifactCoordinates=com.azure.spring.migration:azure-spring-rewrite:LATEST"
72+
```
73+
74+
For gradle projects, you need to configure rewrite-gradle-plugin:
75+
```gradle
76+
plugins {
77+
id("org.openrewrite.rewrite") version("5.38.0")
78+
}
79+
80+
rewrite {
81+
activeRecipe("com.azure.spring.migration.UpgradeToAzureSpringApps", "com.azure.spring.migration.UpgradeSpringboot_2_7_SpringCloud_2021")
82+
}
83+
84+
repositories {
85+
mavenCentral()
86+
maven {
87+
name = "GitHubPackages"
88+
url = uri("https://maven.pkg.github.com/azure/azure-spring-rewrite")
89+
credentials {
90+
username = "<username>"
91+
password = "<github personal access token>"
92+
}
93+
}
94+
}
95+
96+
dependencies {
97+
rewrite(platform("org.openrewrite.recipe:rewrite-recipe-bom:1.17.0"))
98+
rewrite("com.azure.spring.migration:azure-spring-rewrite:0.1.1")
99+
}
100+
```
101+
102+
You can **configure the recipes you want to apply to your application** by modifying the value of `-Drewrite.activeRecipes` in the Maven command line or `activeRecipe` in the Gradle file.
103+
You can add one or all of the defined recipes `com.azure.spring.migration.UpgradeToAzureSpringApps` and `com.azure.spring.migration.UpgradeSpringboot_2_7_SpringCloud_2021`, or add official OpenRewrite recipes, such as `org.openrewrite.java.migrate.UpgradeToJava17` ([reference page](https://docs.openrewrite.org/reference/recipes/java/migrate/upgradetojava17)).

src/main/resources/META-INF/rewrite/azure-spring-apps.yml

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
---
1717
type: specs.openrewrite.org/v1beta/recipe
1818

19-
name: com.azure.spring.migration.openrewrite.WindowFilePath
19+
name: com.azure.spring.migration.openrewrite.WindowsFilePath
2020
displayName: Remove Windows file path in application
2121
description: Find file system path which is Microsoft Windows platform dependent. It needs to be replaced with a Linux-style path
2222
tags:
@@ -26,7 +26,7 @@ tags:
2626
recipeList:
2727
- com.azure.spring.migration.openrewrite.java.search.FindLiterals:
2828
pattern: '[A-z]:([\\\/][^\n\t]+)+|(\\\\([^\\\,\n\t]+)\\\S+)+'
29-
mark: "TODO ASA-WindowFilePath: this file system path is Microsoft Windows platform dependent"
29+
mark: "TODO ASA-WindowsFilePath: this file system path is Microsoft Windows platform dependent"
3030
---
3131
type: specs.openrewrite.org/v1beta/recipe
3232

@@ -112,32 +112,31 @@ type: specs.openrewrite.org/v1beta/recipe
112112
name: com.azure.spring.migration.openrewrite.JavaSystemConfig
113113
displayName: Find uses of Java System Config
114114
description: >
115-
Review usage of environment variables and system properties and externalize.
116-
You can use springboot configuration or inject any per-service configuration settings into each service as environment variables.
117-
https://learn.microsoft.com/en-us/azure/developer/java/migration/migrate-spring-boot-to-azure-spring-apps#configure-per-service-secrets-and-externalized-settings
115+
Review usage of environment variables and system properties and externalize. Configure environment variables or jvm options in azure spring apps
116+
http://aka.ms/spring-boot-to-asa?toc=%2Fazure%2Fspring-apps%2Ftoc.json&bc=%2Fazure%2Fspring-apps%2Fbreadcrumb%2Ftoc.json#configure-per-service-secrets-and-externalized-settings
118117
tags:
119118
- systemConfig
120119
recipeList:
121120
- com.azure.spring.migration.openrewrite.java.search.FindMethods:
122121
methodPattern: 'java.lang.System getenv(..)'
123122
matchOverrides: true
124123
flow: null
125-
mark: "TODO ASA-JavaSystemConfig: need environment configuration in azure spring apps"
124+
mark: "TODO ASA-JavaSystemConfig: need environment variables configuration in azure spring apps"
126125
- com.azure.spring.migration.openrewrite.java.search.FindMethods:
127126
methodPattern: 'java.lang.System getProperty(..)'
128127
matchOverrides: true
129128
flow: null
130-
mark: "TODO ASA-JavaSystemConfig: need environment configuration in azure spring apps"
129+
mark: "TODO ASA-JavaSystemConfig: review usage of system properties and externalize by configuring jvm options in azure spring apps"
131130
- com.azure.spring.migration.openrewrite.java.search.FindMethods:
132131
methodPattern: 'java.lang.System setProperties(..)'
133132
matchOverrides: true
134133
flow: null
135-
mark: "TODO ASA-JavaSystemConfig: need environment configuration in azure spring apps"
134+
mark: "TODO ASA-JavaSystemConfig: review usage of system properties and externalize by configuring jvm options in azure spring apps"
136135
- com.azure.spring.migration.openrewrite.java.search.FindMethods:
137136
methodPattern: 'java.lang.System setProperty(..)'
138137
matchOverrides: true
139138
flow: null
140-
mark: "TODO ASA-JavaSystemConfig: need environment configuration in azure spring apps"
139+
mark: "TODO ASA-JavaSystemConfig: review usage of system properties and externalize by configuring jvm options in azure spring apps"
141140
---
142141
type: specs.openrewrite.org/v1beta/recipe
143142

@@ -207,12 +206,10 @@ recipeList:
207206
---
208207
type: specs.openrewrite.org/v1beta/recipe
209208
name: com.azure.spring.migration.UpgradeToAzureSpringApps
210-
displayName: Migrate to Spring Apps
211-
description: Migrate to Spring Apps
209+
displayName: Migrate to Azure Spring Apps
210+
description: Migrate to Azure Spring Apps
212211
recipeList:
213-
- com.azure.spring.migration.openrewrite.Springboot_2_x
214-
- com.azure.spring.migration.openrewrite.SpringCloud_2021
215-
- com.azure.spring.migration.openrewrite.WindowFilePath
212+
- com.azure.spring.migration.openrewrite.WindowsFilePath
216213
- com.azure.spring.migration.openrewrite.FindFileScheme
217214
- com.azure.spring.migration.openrewrite.FileStorageApi
218215
- com.azure.spring.migration.openrewrite.AddCommentInLogging
@@ -222,4 +219,14 @@ recipeList:
222219
- com.azure.spring.migration.openrewrite.JavaSystemConfig
223220

224221

222+
---
223+
type: specs.openrewrite.org/v1beta/recipe
224+
name: com.azure.spring.migration.UpgradeSpringboot_2_7_SpringCloud_2021
225+
displayName: Migrate to Springboot_2_7 and SpringCloud_2021
226+
description: Migrate to Springboot_2_7 and SpringCloud_2021
227+
recipeList:
228+
- com.azure.spring.migration.openrewrite.Springboot_2_x
229+
- com.azure.spring.migration.openrewrite.SpringCloud_2021
230+
231+
225232

0 commit comments

Comments
 (0)