|
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)). |
0 commit comments