Skip to content

Preview release of v2 migration tool #5486

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 60 commits into from
Aug 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
8924bfc
Create new module for migration tool with basic recipe (#4823)
zoewangg Feb 1, 2024
4b4c2aa
Add recipe to change SDK generated types. (#5053)
zoewangg Apr 8, 2024
ae2b8db
Account for v1 Services Module Naming Differences (#5109)
davidh44 Apr 17, 2024
55f165a
Fix checkstyle errors and suppress spotbug errors for ChangeSdkType (…
zoewangg Apr 17, 2024
23c2ad6
Add Region class mapping (#5118)
zoewangg Apr 18, 2024
a2e0bc5
Add NewV1ClassToBuilder recipe (#5115)
dagnir Apr 18, 2024
7ea05d9
Preserve prefix when moving from new to builder (#5130)
dagnir Apr 22, 2024
a4e8c88
Improve test script to log diff (#5131)
zoewangg Apr 22, 2024
5e99856
Improve diff output when tests fail (#5152)
dagnir Apr 25, 2024
dd1a687
Support code transformation for credentials related classes. (#5147)
zoewangg Apr 25, 2024
3126f62
Flush output after writing diff (#5154)
dagnir Apr 25, 2024
9831bdf
Add ConstructorToFluent recipe (#5145)
dagnir Apr 26, 2024
7a638af
Migration Tool Client Config Part 1: map builder variations to the st…
zoewangg Apr 30, 2024
71aeedd
Add AddCommentToMethod recipe (#5167)
zoewangg May 1, 2024
3f0cbe1
Add NumberToDuration recipe to convert numeric type to Duration (#5170)
zoewangg May 1, 2024
e860bba
Add S3StreamingResponseToV2 Recipe (#5173)
dagnir May 2, 2024
0734f68
Add S3StreamingResponseToV2 to migration recipe (#5180)
dagnir May 6, 2024
1b5f27e
Add mappping for non-HTTP config settings and add comments for settin…
zoewangg May 7, 2024
7bdb373
Add package mapping for the new module and exclude it from javadoc ex…
zoewangg May 7, 2024
55da9ba
Change package name for migration tool and update dependencies (#5200)
zoewangg May 8, 2024
55004c5
Fix NumberToDuraion recipe to handle variable (#5208)
zoewangg May 9, 2024
9408e75
HTTP settings mapping part 1: remove HTTP settings from client config…
zoewangg May 10, 2024
8f14af3
Prefix comment to method call (#5212)
dagnir May 10, 2024
e8e3fca
Add V1GetterToV2 Recipe (#5260)
davidh44 Jun 4, 2024
856a9d1
fix NPE in SdkTypeUtils (#5301)
sullis Jun 18, 2024
62bfe66
Fix POJO class naming mapping (#5315)
zoewangg Jun 19, 2024
59ba025
Change auth type getters to fluent getters (#5318)
zoewangg Jun 21, 2024
e3558b6
Support HTTP settings mapping (#5308)
zoewangg Jun 21, 2024
bbf1287
Fix missing space issue for ClientOverrideConfiguration (#5323)
zoewangg Jun 24, 2024
77efad7
Add mapping for core exception types and getters (#5326)
zoewangg Jun 25, 2024
6aa7d91
Wrap region string with Region.of (#5331)
zoewangg Jun 25, 2024
84986d1
Handle wildcard imports in ChangeSdkType recipe (#5336)
zoewangg Jun 26, 2024
8aa665c
Fix V1GetterToV2 to not change get method (#5338)
zoewangg Jun 27, 2024
4590205
Fix NPE in ChangeSdkType (#5342)
zoewangg Jun 28, 2024
8329c9b
Account for v1 package service name differences (#5353)
davidh44 Jul 2, 2024
0547c4e
Replace aws-java-sdk-core dependency (#5347)
zoewangg Jul 2, 2024
c528be2
Skip transformation for S3 Transfer Manager and DynamoDB mapper (#5364)
zoewangg Jul 4, 2024
db6f51a
Merge remote-tracking branch 'origin' into feature/master/migration-tool
zoewangg Jul 4, 2024
68334e8
Fix tests
zoewangg Jul 4, 2024
c0d444b
Remove hard-coded version in migration-tool-tests test script (#5366)
zoewangg Jul 4, 2024
1f2b0f3
Minor refactoring and updating readme (#5370)
zoewangg Jul 8, 2024
1ee64ee
Add gradle support and add tests for gradle project (#5368)
zoewangg Jul 8, 2024
8e5c6e9
Transform defaultClient to create (#5374)
davidh44 Jul 9, 2024
bfa1524
Add parentheses to method patterns (#5384)
davidh44 Jul 9, 2024
872bdad
Rename module and recipes (#5377)
zoewangg Jul 10, 2024
7ac2931
Add package mapping for rewrite-java-dependencies (#5388)
zoewangg Jul 10, 2024
6f33595
Fix import for real (#5389)
zoewangg Jul 10, 2024
3a90e8d
Add enum getters and casing transforms (#5393)
davidh44 Jul 17, 2024
b1ff244
Refactor HttpSettingsToHttpClient to handler client builder without b…
zoewangg Jul 18, 2024
ae31d77
Transforming S3 PUT override (#5411)
zoewangg Jul 18, 2024
5503299
Fix package/file naming and test (#5426)
davidh44 Jul 25, 2024
53e04b7
Update recipe display name (#5448)
zoewangg Aug 1, 2024
af1b260
Doc update (#5447)
zoewangg Aug 1, 2024
7470df1
Append PREVIEW to the migration tool version and add changelog entry …
zoewangg Aug 2, 2024
cc7233c
Merge remote-tracking branch 'origin/master' into feature/master/migr…
zoewangg Aug 6, 2024
cd6d1e3
Update version
zoewangg Aug 6, 2024
12d5cbf
Use Java to run tests instead of python (#5482)
zoewangg Aug 8, 2024
3e77acb
Merge remote-tracking branch 'origin/master' into feature/master/migr…
zoewangg Aug 8, 2024
374644e
Fix version
zoewangg Aug 8, 2024
b08ea8d
Update to not generate upgrade-sdk-dependencies and change-enum-gette…
zoewangg Aug 8, 2024
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
7 changes: 6 additions & 1 deletion .brazil.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@

"dynamodb": { "packageName": "AwsJavaSdk-DynamoDb" },
"waf": { "packageName": "AwsJavaSdk-Waf" },
"v2-migration": { "packageName": "AwsJavaSdk-Tooling-V2Migration"},

"third-party-jackson-core": {
"packageName": "AwsJavaSdk-ThirdParty-JacksonCore",
Expand Down Expand Up @@ -105,6 +106,7 @@
"tests-coverage-reporting": { "skipImport": true },
"third-party": { "skipImport": true },
"third-party-slf4j-api": { "skipImport": true },
"v2-migration-tests": {"skipImport": true},
"crt-unavailable-tests": { "skipImport": true },
"bundle-shading-tests": { "skipImport": true }
},
Expand Down Expand Up @@ -145,6 +147,9 @@
"org.junit.jupiter:junit-jupiter": { "packageName": "JUnit5", "packageVersion": "5.x" },
"org.mockito:mockito-core": { "packageName": "Mockito", "packageVersion": "3.x" },
"io.reactivex.rxjava3:rxjava": { "packageName": "RxJava", "packageVersion": "3.x" },
"org.assertj:assertj-core": { "packageName": "AssertJ", "packageVersion": "3.22.x" }
"org.assertj:assertj-core": { "packageName": "AssertJ", "packageVersion": "3.22.x" },
"org.openrewrite:rewrite-java-8": {"packageName": "Maven-org-openrewrite_rewrite-java-8", "packageVersion": "8.x"},
"org.openrewrite:rewrite-java": {"packageName": "Maven-org-openrewrite_rewrite-java", "packageVersion": "8.x"},
"org.openrewrite.recipe:rewrite-java-dependencies": {"packageName": "Maven-org-openrewrite-recipe_rewrite-java-dependencies", "packageVersion": "1.x"}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"type": "feature",
"category": "AWS SDK for Java v2 Migration Tool",
"contributor": "",
"description": "Introduce the preview release of the AWS SDK for Java v2 migration tool that automatically migrates applications from the AWS SDK for Java v1 to the AWS SDK for Java v2."
}
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,15 @@
</Not>
</Match>

<!-- Skip the warning since this source is forked from openrewrite -->
<Match>
<Or>
<Class name="software.amazon.awssdk.v2migration.ChangeSdkType"/>
<Class name="software.amazon.awssdk.v2migration.ChangeSdkType$ChangeTypeVisitor"/>
</Or>
<Bug pattern="NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE"/>
</Match>

<Match>
<Class name="software.amazon.awssdk.core.internal.waiters.ResponseOrException"/>
<Bug pattern="NM_CLASS_NOT_EXCEPTION"/>
Expand Down Expand Up @@ -300,4 +309,10 @@
</Or>
<Bug pattern="SA_FIELD_SELF_ASSIGNMENT"/>
</Match>

<!-- False positive -->
<Match>
<Class name="software.amazon.awssdk.v2migration.EnumCasingToV2$Visitor"/>
<Bug pattern="NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE"/>
</Match>
</FindBugsFilter>
2 changes: 1 addition & 1 deletion buildspecs/release-javadoc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ phases:
commands:
- python ./scripts/doc_crosslinks/generate_cross_link_data.py --apiDefinitionsBasePath ./services/ --apiDefinitionsRelativeFilePath src/main/resources/codegen-resources/service-2.json --templateFilePath ./scripts/doc_crosslinks/crosslink_redirect.html --outputFilePath ./scripts/crosslink_redirect.html
- mvn install -P quick -T1C
- mvn clean install javadoc:aggregate -B -Ppublic-javadoc -Dcheckstyle.skip -Dspotbugs.skip -DskipTests -Ddoclint=none -pl '!:protocol-tests,!:protocol-tests-core,!:codegen-generated-classes-test,!:sdk-benchmarks,!:s3-benchmarks,!:module-path-tests,!:test-utils,!:http-client-tests,!:tests-coverage-reporting,!:sdk-native-image-test,!:ruleset-testing-core,!:old-client-version-compatibility-test,!:crt-unavailable-tests,!:bundle-shading-tests'
- mvn clean install javadoc:aggregate -B -Ppublic-javadoc -Dcheckstyle.skip -Dspotbugs.skip -DskipTests -Ddoclint=none -pl '!:protocol-tests,!:protocol-tests-core,!:codegen-generated-classes-test,!:sdk-benchmarks,!:s3-benchmarks,!:module-path-tests,!:test-utils,!:http-client-tests,!:tests-coverage-reporting,!:sdk-native-image-test,!:ruleset-testing-core,!:old-client-version-compatibility-test,!:crt-unavailable-tests,!:bundle-shading-tests,!:v2-migration,!:v2-migration-tests'
- RELEASE_VERSION=`mvn -q -Dexec.executable=echo -Dexec.args='${project.version}' --non-recursive exec:exec`
-
- aws s3 sync target/site/apidocs/ $DOC_PATH/$RELEASE_VERSION/ --acl="public-read"
Expand Down
2 changes: 1 addition & 1 deletion buildspecs/release-to-maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ phases:
awk 'BEGIN { var=ENVIRON["SDK_SIGNING_GPG_KEYNAME"] } { gsub("\\$SDK_SIGNING_GPG_KEYNAME", var, $0); print }' > \
$SETTINGS_XML

mvn clean deploy -B -s $SETTINGS_XML -Ppublishing -DperformRelease -Dspotbugs.skip -DskipTests -Dcheckstyle.skip -Djapicmp.skip -Ddoclint=none -pl !:protocol-tests,!:protocol-tests-core,!:codegen-generated-classes-test,!:sdk-benchmarks,!:module-path-tests,!:tests-coverage-reporting,!:stability-tests,!:sdk-native-image-test,!:auth-tests,!:s3-benchmarks,!:region-testing,!:old-client-version-compatibility-test,!:crt-unavailable-tests,!:bundle-shading-tests -DautoReleaseAfterClose=true -DstagingProgressTimeoutMinutes=30 -Dmaven.wagon.httpconnectionManager.ttlSeconds=120 -Dmaven.wagon.http.retryHandler.requestSentEnabled=true
mvn clean deploy -B -s $SETTINGS_XML -Ppublishing -DperformRelease -Dspotbugs.skip -DskipTests -Dcheckstyle.skip -Djapicmp.skip -Ddoclint=none -pl !:protocol-tests,!:protocol-tests-core,!:codegen-generated-classes-test,!:sdk-benchmarks,!:module-path-tests,!:tests-coverage-reporting,!:stability-tests,!:sdk-native-image-test,!:auth-tests,!:s3-benchmarks,!:region-testing,!:old-client-version-compatibility-test,!:crt-unavailable-tests,!:bundle-shading-tests,!:v2-migration-tests -DautoReleaseAfterClose=true -DstagingProgressTimeoutMinutes=30 -Dmaven.wagon.httpconnectionManager.ttlSeconds=120 -Dmaven.wagon.http.retryHandler.requestSentEnabled=true
else
echo "This version was already released."
fi
2 changes: 2 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
<module>codegen-lite-maven-plugin</module>
<module>archetypes</module>
<module>third-party</module>
<module>v2-migration</module>
<module>test/http-client-tests</module>
<module>test/protocol-tests</module>
<module>test/protocol-tests-core</module>
Expand All @@ -88,6 +89,7 @@
<module>test/ruleset-testing-core</module>
<module>test/old-client-version-compatibility-test</module>
<module>test/bundle-logging-bridge-binding-test</module>
<module>test/v2-migration-tests</module>
<module>test/bundle-shading-tests</module>
<module>test/crt-unavailable-tests</module>
</modules>
Expand Down
6 changes: 6 additions & 0 deletions test/v2-migration-tests/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# AWS SDK Migration Tool Tests

## Description
This module is used to test `v2-migration`. It contains an application that uses the AWS SDK for Java v1
and performs `mvn open:rewrite` to migrate it to the AWS SDK for Java v2 and compares the transformed code
with the expected code for verification. The test code is in [run-test](./src/test/resources/run-test).
154 changes: 154 additions & 0 deletions test/v2-migration-tests/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
<?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.27.1-SNAPSHOT</version>
<relativePath>../..</relativePath>
</parent>

<groupId>software.amazon.awssdk</groupId>
<artifactId>v2-migration-tests</artifactId>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>software.amazon.awssdk</groupId>
<artifactId>bom-internal</artifactId>
<version>${project.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-bom</artifactId>
<version>1.11.1000</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>

</dependencyManagement>

<dependencies>
<dependency>
<groupId>software.amazon.awssdk</groupId>
<artifactId>utils</artifactId>
<version>${project.version}</version>
</dependency>

<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-sqs</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-s3</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>software.amazon.awssdk</groupId>
<artifactId>s3</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>software.amazon.awssdk</groupId>
<artifactId>dynamodb</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>software.amazon.awssdk</groupId>
<artifactId>v2-migration</artifactId>
<version>${project.version}-PREVIEW</version>
<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>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-iostreams</artifactId>
<version>${log4j.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>com.github.spotbugs</groupId>
<artifactId>spotbugs-maven-plugin</artifactId>
<configuration>
<!-- Skipping spotbugs for the generated JMH classes-->
<skip>true</skip>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>analyze-only</goal>
</goals>
</execution>
</executions>
<configuration>
<!-- Skipping maven dependencies analysis to speed up the build -->
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</build>


</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
/*
* 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.
*/

package software.amazon.awssdk.v2migrationtests;

import static java.util.Collections.addAll;
import static software.amazon.awssdk.v2migrationtests.TestUtils.assertTwoDirectoriesHaveSameStructure;
import static software.amazon.awssdk.v2migrationtests.TestUtils.getMigrationToolVersion;
import static software.amazon.awssdk.v2migrationtests.TestUtils.getVersion;
import static software.amazon.awssdk.v2migrationtests.TestUtils.replaceVersion;
import static software.amazon.awssdk.v2migrationtests.TestUtils.run;

import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.attribute.PosixFilePermission;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import org.apache.commons.io.FileUtils;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import software.amazon.awssdk.utils.Logger;

public class GradleProjectTest {
private static final Logger log = Logger.loggerFor(GradleProjectTest.class);
private static String sdkVersion;
private static Path gradleBefore;
private static Path gradleAfter;
private static Path target;
private static Path gradleActual;
private static Path gradleExpected;

@BeforeAll
static void setUp() throws IOException {
sdkVersion = getVersion();
gradleBefore = new File(GradleProjectTest.class.getResource("gradle/before").getFile()).toPath();
gradleAfter = new File(GradleProjectTest.class.getResource("gradle/after").getFile()).toPath();
target = new File(GradleProjectTest.class.getResource("/").getFile()).toPath().getParent();

gradleActual = target.resolve("gradle/actual");
gradleExpected = target.resolve("gradle/expected");

deleteTempDirectories();

FileUtils.copyDirectory(gradleBefore.toFile(), gradleActual.toFile());
FileUtils.copyDirectory(gradleAfter.toFile(), gradleExpected.toFile());

Path gradlew = gradleActual.resolve("gradlew");

Set<PosixFilePermission> perms = new HashSet<>();
perms.addAll(Arrays.asList(PosixFilePermission.OWNER_READ,
PosixFilePermission.OWNER_EXECUTE,
PosixFilePermission.GROUP_EXECUTE,
PosixFilePermission.GROUP_READ,
PosixFilePermission.OTHERS_READ,
PosixFilePermission.OTHERS_EXECUTE));

Files.setPosixFilePermissions(gradlew, perms);

replaceVersion(gradleActual.resolve("init.gradle"), getMigrationToolVersion() + "-PREVIEW");
}

private static void deleteTempDirectories() throws IOException {
FileUtils.deleteDirectory(gradleActual.toFile());
FileUtils.deleteDirectory(gradleExpected.toFile());
}

@Test
void gradleProject_shouldConvert() throws IOException {
verifyTransformation();
verifyCompilation();
}

private static void verifyTransformation() throws IOException {
List<String> rewriteArgs = new ArrayList<>();
addAll(rewriteArgs, "./gradlew", "rewriteRun", "--init-script", "init.gradle",
"-Drewrite.activeRecipes=software.amazon.awssdk.v2migration.AwsSdkJavaV1ToV2");

run(gradleActual, rewriteArgs.toArray(new String[0]));
// only compares source directory and build.gradle and skip non-code directories such as gradle wrapper
assertTwoDirectoriesHaveSameStructure(gradleActual.resolve("src"), gradleExpected.resolve("src"));
}

private static void verifyCompilation() {
List<String> packageArgs = new ArrayList<>();
addAll(packageArgs, "./gradlew", "build");
run(gradleActual, packageArgs.toArray(new String[0]));
}
}
Loading
Loading