Skip to content
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
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": "General availability 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."
}
7 changes: 6 additions & 1 deletion test/v2-migration-tests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
<dependency>
<groupId>software.amazon.awssdk</groupId>
<artifactId>v2-migration</artifactId>
<version>${project.version}-PREVIEW</version>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
<dependency>
Expand Down Expand Up @@ -136,6 +136,11 @@
<artifactId>test-utils</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.EnabledIf;
import software.amazon.awssdk.testutils.SdkVersionUtils;
import software.amazon.awssdk.utils.Logger;

public class GradleProjectTest {
Expand Down Expand Up @@ -75,7 +74,7 @@ static void setUp() throws IOException {

Files.setPosixFilePermissions(gradlew, perms);

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

private static void deleteTempDirectories() throws IOException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ static void setUp() throws IOException {
@Test
@EnabledIf("versionAvailable")
void mavenProject_shouldConvert() throws IOException {
boolean experimental = true;
verifyTransformation(experimental);
verifyTransformation();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@ static void setUp() throws IOException {
@Test
@EnabledIf("versionAvailable")
void mavenProject_shouldConvert() throws IOException {
boolean experimental = false;
verifyTransformation(experimental);
verifyTransformation();
verifyCompilation();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,18 +47,13 @@ protected static void deleteTempDirectories() throws IOException {
FileUtils.deleteDirectory(mavenExpected.toFile());
}

protected static void verifyTransformation(boolean experimental) throws IOException {
protected static void verifyTransformation() throws IOException {
String recipeCmd = "-Drewrite.activeRecipes=software.amazon.awssdk.v2migration.AwsSdkJavaV1ToV2";
if (experimental) {
recipeCmd += "Experimental";
}

List<String> rewriteArgs = new ArrayList<>();
// pin version since updates have broken tests
String rewriteMavenPluginVersion = "5.46.0";
String rewriteMavenPluginVersion = "6.17.0";
addAll(rewriteArgs, "mvn", "org.openrewrite.maven:rewrite-maven-plugin:" + rewriteMavenPluginVersion + ":run",
"-Drewrite.recipeArtifactCoordinates=software.amazon.awssdk:v2-migration:"+ getMigrationToolVersion() + "-PREVIEW",
recipeCmd);
"-Drewrite.recipeArtifactCoordinates=software.amazon.awssdk:v2-migration:"+ getMigrationToolVersion(), recipeCmd);

run(mavenActual, rewriteArgs.toArray(new String[0]));
FileUtils.deleteDirectory(mavenActual.resolve("target").toFile());
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ initscript {
maven { url "https://plugins.gradle.org/m2" }
}
dependencies {
classpath("org.openrewrite:plugin:6.28.0")
classpath("org.openrewrite:plugin:7.15.0")
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public class S3EnDateTime {
public void parseEvent(String jsonInput) {
S3EventNotification notification = S3EventNotification.fromJson(jsonInput);

for (S3EventNotification.S3EventNotificationRecord record : notification.getRecords()) {
for (S3EventNotificationRecord record : notification.getRecords()) {
DateTime eventTime = /*AWS SDK for Java v2 migration: getEventTime returns Instant instead of DateTime in v2. AWS SDK v2 does not include org.joda.time as a dependency. If you want to keep using DateTime, you'll need to manually add "org.joda.time:joda-time" dependency to your project after migration.*/new DateTime(record.getEventTime().toEpochMilli());

GlacierEventData glacierEventData = record.getGlacierEventData();
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@
<artifactId>s3-event-notifications</artifactId>
<version>V2_VERSION</version>
</dependency>
<dependency>
<groupId>software.amazon.awssdk</groupId>
<artifactId>s3-transfer-manager</artifactId>
<version>V2_VERSION</version>
</dependency>
<dependency>
<groupId>software.amazon.awssdk</groupId>
<artifactId>s3</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,11 @@ public static void main(String... args) {

} catch (SqsException exception) {
System.out.println(String.format("Error code: %s. RequestId: %s. Raw response content: %s",
exception.awsErrorDetails().errorCode(), exception.requestId(),
exception.awsErrorDetails().rawResponse().asUtf8String()));
exception.awsErrorDetails().errorCode(), exception.requestId(),
exception.awsErrorDetails().rawResponse().asUtf8String()));
} catch (AwsServiceException exception) {
System.out.println(String.format("Error message: %s. Service Name: %s",
exception.awsErrorDetails().errorMessage(), exception.awsErrorDetails().serviceName()));
exception.awsErrorDetails().errorMessage(), exception.awsErrorDetails().serviceName()));
} catch (SdkException exception) {
System.out.println("Error message " + exception.getMessage());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,7 @@ private void completeMpu(S3Client s3, String bucket, String key) {
.build();

CompleteMultipartUploadRequest completeMpuRequest2 =
CompleteMultipartUploadRequest.builder().bucket(bucket).key(key).uploadId("uploadId").multipartUpload(CompletedMultipartUpload.builder().parts(partETags).build())
.build();
CompleteMultipartUploadRequest.builder().bucket(bucket).key(key).uploadId("uploadId").multipartUpload(CompletedMultipartUpload.builder().parts(partETags).build()).build();
}

private void listObjects(S3Client s3, String bucket) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,7 @@ public void requestconstructor() {

s3.abortMultipartUpload(AbortMultipartUploadRequest.builder().bucket("name").key("key").uploadId("upload")
.build());
s3.completeMultipartUpload(CompleteMultipartUploadRequest.builder().bucket("name").key("key").uploadId("upload").multipartUpload(CompletedMultipartUpload.builder().parts(new ArrayList<>()).build())
.build());
s3.completeMultipartUpload(CompleteMultipartUploadRequest.builder().bucket("name").key("key").uploadId("upload").multipartUpload(CompletedMultipartUpload.builder().parts(new ArrayList<>()).build()).build());

s3.copyObject(CopyObjectRequest.builder()
.build());
Expand Down Expand Up @@ -458,8 +457,7 @@ public void requestconstructor() {
.build();

List<Tag> tags = new ArrayList<>();
GetObjectTaggingResponse getObjectTaggingResult = GetObjectTaggingResponse.builder().tagSet(tags)
.build();
GetObjectTaggingResponse getObjectTaggingResult = GetObjectTaggingResponse.builder().tagSet(tags).build();

PutBucketVersioningRequest setBucketVersioningConfigurationRequest =
PutBucketVersioningRequest.builder().bucket(bucketName).versioningConfiguration(VersioningConfiguration.builder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ void putObject_bucketKeyStreamMetadata(String bucket, String key, InputStream st
HeadObjectResponse metadataWithLength = HeadObjectResponse.builder()
.build();
s3.putObject(PutObjectRequest.builder().bucket(bucket).key(key).contentLength(22L)
.build(), RequestBody.fromInputStream(stream, 22L));
.build(), RequestBody.fromInputStream(stream, 22));


HeadObjectResponse metadataWithoutLength = HeadObjectResponse.builder()
Expand Down Expand Up @@ -105,7 +105,7 @@ void putObject_requestPojoWithInputStream(String bucket, String key) {
HeadObjectResponse metadata = HeadObjectResponse.builder()
.build();
s3.putObject(PutObjectRequest.builder().bucket(bucket).key(key).websiteRedirectLocation("location").contentLength(11L)
.build(), RequestBody.fromInputStream(inputStream2, 11L));
.build(), RequestBody.fromInputStream(inputStream2, 11));
}

void putObject_requestPojoWithoutPayload(String bucket, String key) {
Expand All @@ -117,8 +117,7 @@ void putObject_requestPojoWithoutPayload(String bucket, String key) {

void putObjectSetters() {
List<Tag> tags = new ArrayList<>();
Tagging objectTagging = Tagging.builder().tagSet(tags)
.build();
Tagging objectTagging = Tagging.builder().tagSet(tags).build();

PutObjectRequest putObjectRequest =
PutObjectRequest.builder().bucket("bucket").key("key").websiteRedirectLocation("location")
Expand Down
Loading
Loading