Skip to content

Create new module for migration tool with basic recipe #4823

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions migration-tool/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# AWS SDK for Java v2 Migration Tool

## Description
This is a migration tool to automate migration from AWS SDK for Java v1 to AWS SDK for Java v2.
It uses [OpenRewrite][open-rewrite].

## Usage

You can use [OpenRewrite Maven plugin][open-rewrite-plugin] to start the migration. See [Running OpenRewrite Recipes][open-rewrite-usage] for more information.
To get started, you can either perform a dry run or run directly.

- Dry Run

With this mode, it generates diff logs in the console as well as diff file in the `target` folder.
Note that you need to replace `{sdkversion}` with the actual SDK version. See [Maven Central][maven-central] to
find the latest version.

```
mvn org.openrewrite.maven:rewrite-maven-plugin:dryRun \
-Drewrite.recipeArtifactCoordinates=software.amazon.awssdk:migration-tool:{sdkversion}
-Drewrite.activeRecipes=software.amazon.awssdk.UpgradeJavaSdk2
```

- Run

With this mode, it runs the SDK recipes and applies the changes locally.

```
mvn org.openrewrite.maven:rewrite-maven-plugin:run \
-Drewrite.recipeArtifactCoordinates=software.amazon.awssdk:migration-tool:{sdkversion}
-Drewrite.activeRecipes=software.amazon.awssdk.UpgradeJavaSdk2
```

[open-rewrite]: https://docs.openrewrite.org/
[open-rewrite-usage]: https://docs.openrewrite.org/running-recipes
[open-rewrite-plugin]: https://docs.openrewrite.org/reference/rewrite-maven-plugin
[maven-central]: https://central.sonatype.com/artifact/software.amazon.awssdk/migration-tool
123 changes: 123 additions & 0 deletions migration-tool/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
~
~ Licensed under the Apache License, Version 2.0 (the "License").
~ You may not use this file except in compliance with the License.
~ A copy of the License is located at
~
~ http://aws.amazon.com/apache2.0
~
~ or in the "license" file accompanying this file. This file is distributed
~ on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
~ express or implied. See the License for the specific language governing
~ permissions and limitations under the License.
-->

<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>software.amazon.awssdk</groupId>
<artifactId>aws-sdk-java-pom</artifactId>
<version>2.23.16-SNAPSHOT</version>
</parent>

<artifactId>migration-tool</artifactId>
<name>AWS Java SDK :: Migration Tool</name>
<description>
Migration tool to help users migrate from AWS SDK for Java v1 to AWS SDK for Java v2
</description>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.openrewrite.recipe</groupId>
<artifactId>rewrite-recipe-bom</artifactId>
<version>2.5.4</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>software.amazon.awssdk</groupId>
<artifactId>bom-internal</artifactId>
<version>${awsjavasdk.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>
<dependency>
<groupId>org.openrewrite</groupId>
<artifactId>rewrite-java</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.openrewrite</groupId>
<artifactId>rewrite-java-8</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.openrewrite</groupId>
<artifactId>rewrite-maven</artifactId>
<scope>compile</scope>
</dependency>

<dependency>
<groupId>org.openrewrite</groupId>
<artifactId>rewrite-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>${junit5.version}</version>
<scope>test</scope>
</dependency>
<!-- Used in UpgradeSdkDependenciesTest -->
<dependency>
<groupId>software.amazon.awssdk</groupId>
<artifactId>sqs</artifactId>
<scope>test</scope>
<version>${awsjavasdk.version}</version>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
<plugin>
<artifactId>exec-maven-plugin</artifactId>
<groupId>org.codehaus.mojo</groupId>
<version>${exec-maven-plugin.version}</version>
<executions>
<execution>
<id>generate-recipe</id>
<phase>generate-resources</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>python</executable>
<commandlineArgs>${basedir}/src/main/resources/generate-recipes</commandlineArgs>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License").
# You may not use this file except in compliance with the License.
# A copy of the License is located at
#
# http://aws.amazon.com/apache2.0
#
# or in the "license" file accompanying this file. This file is distributed
# on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
# express or implied. See the License for the specific language governing
# permissions and limitations under the License.
#
---
type: specs.openrewrite.org/v1beta/recipe
name: software.amazon.awssdk.UpgradeJavaSdk2
displayName: Migrate to the AWS SDK for Java v2
description: Migrate applications to the AWS SDK for Java v2.
tags:
- aws
- sdk
recipeList:
- software.amazon.awssdk.UpgradeSdkDependencies
- software.amazon.awssdk.UpdateSdkTypes
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License").
# You may not use this file except in compliance with the License.
# A copy of the License is located at
#
# http://aws.amazon.com/apache2.0
#
# or in the "license" file accompanying this file. This file is distributed
# on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
# express or implied. See the License for the specific language governing
# permissions and limitations under the License.
#
---
type: specs.openrewrite.org/v1beta/recipe
name: software.amazon.awssdk.UpdateSdkTypes
displayName: Change Maven dependency groupId, artifactId and/or the version example
recipeList:
## TODO: we should generate these mappings
- org.openrewrite.java.ChangeType:
oldFullyQualifiedTypeName: com.amazonaws.services.sqs.AmazonSQS
newFullyQualifiedTypeName: software.amazon.awssdk.services.sqs.SqsClient
- org.openrewrite.java.ChangeType:
oldFullyQualifiedTypeName: com.amazonaws.services.sqs.AmazonSQSClient
newFullyQualifiedTypeName: software.amazon.awssdk.services.sqs.SqsClient
Loading