Skip to content

Commit

Permalink
Migration tool exclude custom sdks (#5602)
Browse files Browse the repository at this point in the history
* Migration tool skip transforming custom SDKs

* Remove packages to skip

* Keep skipped packages test and add Lambda invoke class
  • Loading branch information
davidh44 committed Sep 16, 2024
1 parent d2b33fd commit cae19ee
Show file tree
Hide file tree
Showing 4 changed files with 428 additions and 15 deletions.
13 changes: 12 additions & 1 deletion v2-migration/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,17 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-s3</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>com.fasterxml.jackson</groupId>
<artifactId>jackson-core</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-dynamodb</artifactId>
Expand All @@ -155,7 +166,7 @@
</dependency>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-s3</artifactId>
<artifactId>aws-java-sdk-lambda</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@

import static software.amazon.awssdk.v2migration.internal.utils.NamingConversionUtils.getV2Equivalent;
import static software.amazon.awssdk.v2migration.internal.utils.NamingConversionUtils.getV2ModelPackageWildCardEquivalent;
import static software.amazon.awssdk.v2migration.internal.utils.SdkTypeUtils.isCustomSdk;
import static software.amazon.awssdk.v2migration.internal.utils.SdkTypeUtils.isV1ClientClass;
import static software.amazon.awssdk.v2migration.internal.utils.SdkTypeUtils.isV1ModelClass;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.IdentityHashMap;
Expand Down Expand Up @@ -65,10 +65,6 @@ public class ChangeSdkType extends Recipe {
"com\\.amazonaws\\.services\\.[a-zA-Z0-9]+\\.model\\.\\*";
private static final String V1_SERVICE_WILD_CARD_CLASS_PATTERN = "com\\.amazonaws\\.services\\.[a-zA-Z0-9]+\\.\\*";

private static final Set<String> PACKAGES_TO_SKIP = new HashSet<>(
Arrays.asList("com.amazonaws.services.s3.transfer",
"com.amazonaws.services.dynamodbv2.datamodeling"));

@Override
public String getDisplayName() {
return "Change AWS SDK for Java v1 types to v2 equivalents";
Expand Down Expand Up @@ -139,17 +135,16 @@ private static boolean isWildcard(String fullName) {

private static boolean isV1Class(JavaType.FullyQualified fullyQualified) {
String fullyQualifiedName = fullyQualified.getFullyQualifiedName();
if (shouldSkip(fullyQualifiedName)) {
log.info(() -> String.format("Skipping transformation for %s because it is not supported in the migration "
+ "tooling at the moment", fullyQualifiedName));

if (!isV1ModelClass(fullyQualified) && !isV1ClientClass(fullyQualified)) {
return false;
}

return isV1ModelClass(fullyQualified) || isV1ClientClass(fullyQualified);
}

private static boolean shouldSkip(String fqcn) {
return PACKAGES_TO_SKIP.stream().anyMatch(fqcn::startsWith);
if (isCustomSdk(fullyQualifiedName)) {
log.info(() -> String.format("Skipping transformation for %s because it is a custom SDK", fullyQualifiedName));
return false;
}
return true;
}

@Override
Expand Down
Loading

0 comments on commit cae19ee

Please sign in to comment.