Skip to content

Commit 6e62359

Browse files
authored
Identity OpenRewrite Migration (Azure#45647)
* Update compiler PR * Add v1 samples. Need to migrate v2 * Add v1 samples. Need to migrate v2 * Remove unrelated files * Remove deprecated samples * Update to v2 samples * Updates to Identity Migration * Updating the identity samples * Updating the identity samples * updating PR; ready for review * Updating compiler CI * add identity-v2 to v2 profile in the pom * adjusting scope of dependency * Remove unecessary OrderImports from Identity recipe
1 parent 4a5a6b8 commit 6e62359

File tree

43 files changed

+608
-767
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+608
-767
lines changed

sdk/tools/azure-openrewrite/pom.xml

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
<dependency>
2121
<groupId>org.openrewrite.recipe</groupId>
2222
<artifactId>rewrite-recipe-bom</artifactId>
23-
<version>3.6.1</version> <!-- {x-version-update;org.openrewrite.recipe:rewrite-recipe-bom;external_dependency} -->
23+
<version>3.9.0</version> <!-- {x-version-update;org.openrewrite.recipe:rewrite-recipe-bom;external_dependency} -->
2424
<type>pom</type>
2525
<scope>import</scope>
2626
</dependency>
@@ -186,6 +186,14 @@
186186
<version>1.16.2</version> <!-- {x-version-update;com.azure:azure-identity;dependency} -->
187187
<scope>test</scope>
188188
</dependency>
189+
190+
<dependency>
191+
<groupId>com.azure.v2</groupId>
192+
<artifactId>azure-identity</artifactId>
193+
<version>2.0.0-beta.1</version> <!-- {x-version-update;com.azure.v2:azure-identity;dependency} -->
194+
<scope>test</scope>
195+
</dependency>
196+
189197
<dependency>
190198
<groupId>com.azure</groupId>
191199
<artifactId>azure-data-appconfiguration</artifactId>
@@ -318,6 +326,12 @@
318326
<version>2.0.0-beta.1</version> <!-- {x-version-update;com.azure.v2:azure-core;dependency} -->
319327
<scope>provided</scope>
320328
</dependency>
329+
<dependency>
330+
<groupId>com.azure.v2</groupId>
331+
<artifactId>azure-identity</artifactId>
332+
<version>2.0.0-beta.1</version> <!-- {x-version-update;com.azure.v2:azure-identity;dependency} -->
333+
<scope>provided</scope>
334+
</dependency>
321335
</dependencies>
322336
</profile>
323337
</profiles>

sdk/tools/azure-openrewrite/src/main/java/com/azure/openrewrite/core/credential/AccessTokenCustomRecipe.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package com.azure.openrewrite.core.credential;
22

3-
import com.azure.openrewrite.util.ConfiguredParserJavaTemplateBuilder;
43
import org.openrewrite.ExecutionContext;
54
import org.openrewrite.Recipe;
65
import org.openrewrite.java.JavaIsoVisitor;
@@ -9,6 +8,8 @@
98
import org.openrewrite.java.tree.J;
109
import org.openrewrite.java.tree.Space;
1110

11+
import com.azure.openrewrite.util.ConfiguredParserJavaTemplateBuilder;
12+
1213
/**
1314
* A custom OpenRewrite recipe to migrate the use of AccessToken.
1415
*
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Copyright (c) Microsoft Corporation. All rights reserved.
2+
# Licensed under the MIT License.
3+
# --------------------------------------------------------------------
4+
# Migration Recipes for Azure Identity Library
5+
# --------------------------------------------------------------------
6+
type: specs.openrewrite.org/v1beta/recipe
7+
name: com.azure.openrewrite.migration.identity
8+
displayName: Migrate from azure-identity to next generation stack
9+
description: This recipe migrates the Azure Identity library to the next generation stack.
10+
recipeList:
11+
12+
- org.openrewrite.java.ChangePackage:
13+
oldPackageName: 'com.azure.identity'
14+
newPackageName: 'com.azure.v2.identity'
15+
recursive: true
16+
17+
- org.openrewrite.java.ChangeMethodName:
18+
methodPattern: "com.azure.v2.identity.ClientCertificateCredentialBuilder pemCertificate(..)"
19+
newMethodName: "clientCertificate"
20+

sdk/tools/azure-openrewrite/src/main/resources/META-INF/rewrite/rewrite.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,11 @@ name: com.azure.openrewrite
99
displayName: Migrate Azure SDKs to Next-Generation Library Stack
1010
description: This recipe migrates the Azure SDKs to the next-generation library stack.
1111
recipeList:
12+
# Code Migration Recipes
1213
- com.azure.openrewrite.migration.core
14+
- com.azure.openrewrite.migration.identity
15+
16+
# Code Styling recipes
17+
- org.openrewrite.java.OrderImports:
18+
removeUnused: false
1319

sdk/tools/azure-openrewrite/src/test/java/com/azure/openrewrite/migration/FullSampleMigrationTest.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
import org.junit.jupiter.api.Assumptions;
55
import org.junit.jupiter.api.DisplayNameGeneration;
6-
import org.junit.jupiter.api.condition.DisabledIf;
76
import org.junit.jupiter.api.parallel.Execution;
87
import org.junit.jupiter.api.parallel.ExecutionMode;
98
import org.junit.jupiter.params.ParameterizedTest;
@@ -18,10 +17,7 @@
1817
import org.openrewrite.test.SourceSpecs;
1918
import org.openrewrite.test.TypeValidation;
2019

21-
import javax.swing.text.StyleContext;
2220
import java.io.IOException;
23-
import java.lang.reflect.Method;
24-
import java.lang.reflect.Parameter;
2521
import java.nio.file.Files;
2622
import java.nio.file.Path;
2723
import java.nio.file.Paths;
@@ -86,7 +82,7 @@ private static List<NamedStyles> getStyles() {
8682
styles.add(new org.openrewrite.java.style.ImportLayoutStyle(
8783
9999,
8884
9999,
89-
Collections.emptyList(),
85+
org.openrewrite.java.style.Autodetect.detector().getImportLayoutStyle().getLayout(),
9086
Collections.emptyList()
9187
));
9288
styles.add(new org.openrewrite.java.style.TabsAndIndentsStyle(
@@ -98,6 +94,8 @@ private static List<NamedStyles> getStyles() {
9894
new TabsAndIndentsStyle.MethodDeclarationParameters(true)
9995
));
10096

97+
98+
10199
return Collections.singletonList(
102100
new NamedStyles(
103101
Tree.randomId(),

0 commit comments

Comments
 (0)