Skip to content

Commit 8924bfc

Browse files
authored
Create new module for migration tool with basic recipe (#4823)
* Create new module for migration tool with basic transformation * Test application * Generate upgrade-sdk-depenencies recipe * Add more tests * Add README and fix test * Generate bom version change * Fix build
1 parent b29f144 commit 8924bfc

File tree

18 files changed

+3017
-0
lines changed

18 files changed

+3017
-0
lines changed

migration-tool/README.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# AWS SDK for Java v2 Migration Tool
2+
3+
## Description
4+
This is a migration tool to automate migration from AWS SDK for Java v1 to AWS SDK for Java v2.
5+
It uses [OpenRewrite][open-rewrite].
6+
7+
## Usage
8+
9+
You can use [OpenRewrite Maven plugin][open-rewrite-plugin] to start the migration. See [Running OpenRewrite Recipes][open-rewrite-usage] for more information.
10+
To get started, you can either perform a dry run or run directly.
11+
12+
- Dry Run
13+
14+
With this mode, it generates diff logs in the console as well as diff file in the `target` folder.
15+
Note that you need to replace `{sdkversion}` with the actual SDK version. See [Maven Central][maven-central] to
16+
find the latest version.
17+
18+
```
19+
mvn org.openrewrite.maven:rewrite-maven-plugin:dryRun \
20+
-Drewrite.recipeArtifactCoordinates=software.amazon.awssdk:migration-tool:{sdkversion}
21+
-Drewrite.activeRecipes=software.amazon.awssdk.UpgradeJavaSdk2
22+
```
23+
24+
- Run
25+
26+
With this mode, it runs the SDK recipes and applies the changes locally.
27+
28+
```
29+
mvn org.openrewrite.maven:rewrite-maven-plugin:run \
30+
-Drewrite.recipeArtifactCoordinates=software.amazon.awssdk:migration-tool:{sdkversion}
31+
-Drewrite.activeRecipes=software.amazon.awssdk.UpgradeJavaSdk2
32+
```
33+
34+
[open-rewrite]: https://docs.openrewrite.org/
35+
[open-rewrite-usage]: https://docs.openrewrite.org/running-recipes
36+
[open-rewrite-plugin]: https://docs.openrewrite.org/reference/rewrite-maven-plugin
37+
[maven-central]: https://central.sonatype.com/artifact/software.amazon.awssdk/migration-tool

migration-tool/pom.xml

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
~ Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
4+
~
5+
~ Licensed under the Apache License, Version 2.0 (the "License").
6+
~ You may not use this file except in compliance with the License.
7+
~ A copy of the License is located at
8+
~
9+
~ http://aws.amazon.com/apache2.0
10+
~
11+
~ or in the "license" file accompanying this file. This file is distributed
12+
~ on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13+
~ express or implied. See the License for the specific language governing
14+
~ permissions and limitations under the License.
15+
-->
16+
17+
<project xmlns="http://maven.apache.org/POM/4.0.0"
18+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
19+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
20+
<modelVersion>4.0.0</modelVersion>
21+
<parent>
22+
<groupId>software.amazon.awssdk</groupId>
23+
<artifactId>aws-sdk-java-pom</artifactId>
24+
<version>2.23.16-SNAPSHOT</version>
25+
</parent>
26+
27+
<artifactId>migration-tool</artifactId>
28+
<name>AWS Java SDK :: Migration Tool</name>
29+
<description>
30+
Migration tool to help users migrate from AWS SDK for Java v1 to AWS SDK for Java v2
31+
</description>
32+
33+
<dependencyManagement>
34+
<dependencies>
35+
<dependency>
36+
<groupId>org.openrewrite.recipe</groupId>
37+
<artifactId>rewrite-recipe-bom</artifactId>
38+
<version>2.5.4</version>
39+
<type>pom</type>
40+
<scope>import</scope>
41+
</dependency>
42+
<dependency>
43+
<groupId>software.amazon.awssdk</groupId>
44+
<artifactId>bom-internal</artifactId>
45+
<version>${awsjavasdk.version}</version>
46+
<type>pom</type>
47+
<scope>import</scope>
48+
</dependency>
49+
</dependencies>
50+
</dependencyManagement>
51+
52+
<dependencies>
53+
<dependency>
54+
<groupId>org.openrewrite</groupId>
55+
<artifactId>rewrite-java</artifactId>
56+
<scope>compile</scope>
57+
</dependency>
58+
<dependency>
59+
<groupId>org.openrewrite</groupId>
60+
<artifactId>rewrite-java-8</artifactId>
61+
<scope>runtime</scope>
62+
</dependency>
63+
<dependency>
64+
<groupId>org.openrewrite</groupId>
65+
<artifactId>rewrite-maven</artifactId>
66+
<scope>compile</scope>
67+
</dependency>
68+
69+
<dependency>
70+
<groupId>org.openrewrite</groupId>
71+
<artifactId>rewrite-test</artifactId>
72+
<scope>test</scope>
73+
</dependency>
74+
<dependency>
75+
<groupId>org.junit.jupiter</groupId>
76+
<artifactId>junit-jupiter</artifactId>
77+
<scope>test</scope>
78+
</dependency>
79+
<dependency>
80+
<groupId>org.junit.jupiter</groupId>
81+
<artifactId>junit-jupiter-engine</artifactId>
82+
<version>${junit5.version}</version>
83+
<scope>test</scope>
84+
</dependency>
85+
<!-- Used in UpgradeSdkDependenciesTest -->
86+
<dependency>
87+
<groupId>software.amazon.awssdk</groupId>
88+
<artifactId>sqs</artifactId>
89+
<scope>test</scope>
90+
<version>${awsjavasdk.version}</version>
91+
</dependency>
92+
</dependencies>
93+
94+
<build>
95+
<plugins>
96+
<plugin>
97+
<groupId>org.apache.maven.plugins</groupId>
98+
<artifactId>maven-dependency-plugin</artifactId>
99+
<configuration>
100+
<skip>true</skip>
101+
</configuration>
102+
</plugin>
103+
<plugin>
104+
<artifactId>exec-maven-plugin</artifactId>
105+
<groupId>org.codehaus.mojo</groupId>
106+
<version>${exec-maven-plugin.version}</version>
107+
<executions>
108+
<execution>
109+
<id>generate-recipe</id>
110+
<phase>generate-resources</phase>
111+
<goals>
112+
<goal>exec</goal>
113+
</goals>
114+
<configuration>
115+
<executable>python</executable>
116+
<commandlineArgs>${basedir}/src/main/resources/generate-recipes</commandlineArgs>
117+
</configuration>
118+
</execution>
119+
</executions>
120+
</plugin>
121+
</plugins>
122+
</build>
123+
</project>
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#
2+
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License").
5+
# You may not use this file except in compliance with the License.
6+
# A copy of the License is located at
7+
#
8+
# http://aws.amazon.com/apache2.0
9+
#
10+
# or in the "license" file accompanying this file. This file is distributed
11+
# on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12+
# express or implied. See the License for the specific language governing
13+
# permissions and limitations under the License.
14+
#
15+
---
16+
type: specs.openrewrite.org/v1beta/recipe
17+
name: software.amazon.awssdk.UpgradeJavaSdk2
18+
displayName: Migrate to the AWS SDK for Java v2
19+
description: Migrate applications to the AWS SDK for Java v2.
20+
tags:
21+
- aws
22+
- sdk
23+
recipeList:
24+
- software.amazon.awssdk.UpgradeSdkDependencies
25+
- software.amazon.awssdk.UpdateSdkTypes
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#
2+
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License").
5+
# You may not use this file except in compliance with the License.
6+
# A copy of the License is located at
7+
#
8+
# http://aws.amazon.com/apache2.0
9+
#
10+
# or in the "license" file accompanying this file. This file is distributed
11+
# on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12+
# express or implied. See the License for the specific language governing
13+
# permissions and limitations under the License.
14+
#
15+
---
16+
type: specs.openrewrite.org/v1beta/recipe
17+
name: software.amazon.awssdk.UpdateSdkTypes
18+
displayName: Change Maven dependency groupId, artifactId and/or the version example
19+
recipeList:
20+
## TODO: we should generate these mappings
21+
- org.openrewrite.java.ChangeType:
22+
oldFullyQualifiedTypeName: com.amazonaws.services.sqs.AmazonSQS
23+
newFullyQualifiedTypeName: software.amazon.awssdk.services.sqs.SqsClient
24+
- org.openrewrite.java.ChangeType:
25+
oldFullyQualifiedTypeName: com.amazonaws.services.sqs.AmazonSQSClient
26+
newFullyQualifiedTypeName: software.amazon.awssdk.services.sqs.SqsClient

0 commit comments

Comments
 (0)