From 939ad416c891f0ffb2befc320a234a0539669211 Mon Sep 17 00:00:00 2001 From: Zoe Wang Date: Wed, 3 Feb 2021 15:17:05 -0800 Subject: [PATCH] Add GraalVM Native Image compilation support Add archetype-app-quickstart archetype --- .../feature-AWSSDKforJavav2-61fb1a6.json | 6 + .../feature-AWSSDKforJavav2-818e995.json | 6 + archetypes/README.md | 6 +- archetypes/archetype-app-quickstart/README.md | 61 ++++++ archetypes/archetype-app-quickstart/pom.xml | 174 +++++++++++++++++ .../META-INF/maven/archetype-metadata.xml | 46 +++++ .../resources/archetype-resources/.gitignore | 17 ++ .../resources/archetype-resources/README.md | 55 ++++++ .../resources/archetype-resources/pom.xml | 149 +++++++++++++++ .../src/main/java/App.java | 17 ++ .../src/main/java/DependencyFactory.java | 23 +++ .../src/main/java/Handler.java | 17 ++ .../main/resources/simplelogger.properties | 24 +++ .../src/test/java/HandlerTest.java | 10 + .../apachehttpclient/archetype.properties | 8 + .../projects/apachehttpclient/goal.txt | 1 + .../apachehttpclient/reference/README.md | 53 ++++++ .../apachehttpclient/reference/pom.xml | 140 ++++++++++++++ .../java/software/amazonaws/test/App.java | 16 ++ .../amazonaws/test/DependencyFactory.java | 22 +++ .../java/software/amazonaws/test/Handler.java | 16 ++ .../main/resources/simplelogger.properties | 24 +++ .../software/amazonaws/test/HandlerTest.java | 7 + .../archetype.properties | 8 + .../goal.txt | 1 + .../reference/README.md | 38 ++++ .../reference/pom.xml | 101 ++++++++++ .../java/software/amazonaws/test/App.java | 16 ++ .../amazonaws/test/DependencyFactory.java | 22 +++ .../java/software/amazonaws/test/Handler.java | 16 ++ .../main/resources/simplelogger.properties | 24 +++ .../software/amazonaws/test/HandlerTest.java | 7 + .../projects/nettyclient/archetype.properties | 8 + .../resources/projects/nettyclient/goal.txt | 1 + .../projects/nettyclient/reference/README.md | 53 ++++++ .../projects/nettyclient/reference/pom.xml | 127 +++++++++++++ .../java/software/amazonaws/test/App.java | 16 ++ .../amazonaws/test/DependencyFactory.java | 22 +++ .../java/software/amazonaws/test/Handler.java | 16 ++ .../main/resources/simplelogger.properties | 24 +++ .../software/amazonaws/test/HandlerTest.java | 7 + .../urlhttpclient/archetype.properties | 8 + .../resources/projects/urlhttpclient/goal.txt | 1 + .../urlhttpclient/reference/README.md | 53 ++++++ .../projects/urlhttpclient/reference/pom.xml | 127 +++++++++++++ .../java/software/amazonaws/test/App.java | 16 ++ .../amazonaws/test/DependencyFactory.java | 22 +++ .../java/software/amazonaws/test/Handler.java | 16 ++ .../main/resources/simplelogger.properties | 24 +++ .../software/amazonaws/test/HandlerTest.java | 7 + archetypes/archetype-lambda/pom.xml | 62 +++--- .../META-INF/maven/archetype-metadata.xml | 2 +- archetypes/archetype-tools/pom.xml | 62 ++++++ .../src/main/resources/global.vm | 2 +- .../resources/map-service-to-client-prefix | 0 .../src/test/resources/serviceMapping.vm | 1 + archetypes/pom.xml | 2 + buildspecs/archetype-native-image-test.yml | 63 +++++++ buildspecs/native-image-integ-test.yml | 11 ++ buildspecs/release-to-maven.yml | 2 +- .../naming/DefaultNamingStrategyTest.java | 2 +- .../sdk-core/native-image.properties | 15 ++ .../sdk-core/reflect-config.json | 11 ++ .../sdk-core/resource-config.json | 12 ++ .../apache-client/proxy-config.json | 15 ++ .../apache-client/reflect-config.json | 28 +++ .../apache-client/resource-config.json | 7 + .../netty-nio-client/native-image.properties | 25 +++ .../netty-nio-client/reflect-config.json | 11 ++ .../netty-nio-client/resource-config.json | 7 + .../url-connection-client/reflect-config.json | 11 ++ .../resource-config.json | 7 + pom.xml | 3 + .../reflect-config.json | 11 ++ .../apigateway/reflect-config.json | 11 ++ .../cloudsearchdomain/reflect-config.json | 11 ++ .../docdb/reflect-config.json | 20 ++ .../ec2/reflect-config.json | 20 ++ .../glacier/reflect-config.json | 20 ++ .../iam/reflect-config.json | 11 ++ .../machinelearning/reflect-config.json | 20 ++ .../neptune/reflect-config.json | 20 ++ .../rds/reflect-config.json | 47 +++++ .../reflect-config.json | 11 ++ .../s3/reflect-config.json | 119 ++++++++++++ .../s3control/reflect-config.json | 29 +++ .../sqs/reflect-config.json | 11 ++ test/sdk-native-image-test/README.md | 22 +++ test/sdk-native-image-test/pom.xml | 176 ++++++++++++++++++ .../amazon/awssdk/nativeimagetest/App.java | 39 ++++ .../nativeimagetest/DependencyFactory.java | 77 ++++++++ .../DynamoDbEnhancedClientTestRunner.java | 160 ++++++++++++++++ .../awssdk/nativeimagetest/S3TestRunner.java | 73 ++++++++ .../awssdk/nativeimagetest/TestRunner.java | 21 +++ .../main/resources/simplelogger.properties | 35 ++++ 95 files changed, 2967 insertions(+), 37 deletions(-) create mode 100644 .changes/next-release/feature-AWSSDKforJavav2-61fb1a6.json create mode 100644 .changes/next-release/feature-AWSSDKforJavav2-818e995.json create mode 100755 archetypes/archetype-app-quickstart/README.md create mode 100644 archetypes/archetype-app-quickstart/pom.xml create mode 100644 archetypes/archetype-app-quickstart/src/main/resources/META-INF/maven/archetype-metadata.xml create mode 100644 archetypes/archetype-app-quickstart/src/main/resources/archetype-resources/.gitignore create mode 100644 archetypes/archetype-app-quickstart/src/main/resources/archetype-resources/README.md create mode 100644 archetypes/archetype-app-quickstart/src/main/resources/archetype-resources/pom.xml create mode 100644 archetypes/archetype-app-quickstart/src/main/resources/archetype-resources/src/main/java/App.java create mode 100644 archetypes/archetype-app-quickstart/src/main/resources/archetype-resources/src/main/java/DependencyFactory.java create mode 100644 archetypes/archetype-app-quickstart/src/main/resources/archetype-resources/src/main/java/Handler.java create mode 100644 archetypes/archetype-app-quickstart/src/main/resources/archetype-resources/src/main/resources/simplelogger.properties create mode 100644 archetypes/archetype-app-quickstart/src/main/resources/archetype-resources/src/test/java/HandlerTest.java create mode 100644 archetypes/archetype-app-quickstart/src/test/resources/projects/apachehttpclient/archetype.properties create mode 100644 archetypes/archetype-app-quickstart/src/test/resources/projects/apachehttpclient/goal.txt create mode 100644 archetypes/archetype-app-quickstart/src/test/resources/projects/apachehttpclient/reference/README.md create mode 100644 archetypes/archetype-app-quickstart/src/test/resources/projects/apachehttpclient/reference/pom.xml create mode 100644 archetypes/archetype-app-quickstart/src/test/resources/projects/apachehttpclient/reference/src/main/java/software/amazonaws/test/App.java create mode 100644 archetypes/archetype-app-quickstart/src/test/resources/projects/apachehttpclient/reference/src/main/java/software/amazonaws/test/DependencyFactory.java create mode 100644 archetypes/archetype-app-quickstart/src/test/resources/projects/apachehttpclient/reference/src/main/java/software/amazonaws/test/Handler.java create mode 100644 archetypes/archetype-app-quickstart/src/test/resources/projects/apachehttpclient/reference/src/main/resources/simplelogger.properties create mode 100644 archetypes/archetype-app-quickstart/src/test/resources/projects/apachehttpclient/reference/src/test/java/software/amazonaws/test/HandlerTest.java create mode 100644 archetypes/archetype-app-quickstart/src/test/resources/projects/apachehttpclientwithoutnativeimage/archetype.properties create mode 100644 archetypes/archetype-app-quickstart/src/test/resources/projects/apachehttpclientwithoutnativeimage/goal.txt create mode 100644 archetypes/archetype-app-quickstart/src/test/resources/projects/apachehttpclientwithoutnativeimage/reference/README.md create mode 100644 archetypes/archetype-app-quickstart/src/test/resources/projects/apachehttpclientwithoutnativeimage/reference/pom.xml create mode 100644 archetypes/archetype-app-quickstart/src/test/resources/projects/apachehttpclientwithoutnativeimage/reference/src/main/java/software/amazonaws/test/App.java create mode 100644 archetypes/archetype-app-quickstart/src/test/resources/projects/apachehttpclientwithoutnativeimage/reference/src/main/java/software/amazonaws/test/DependencyFactory.java create mode 100644 archetypes/archetype-app-quickstart/src/test/resources/projects/apachehttpclientwithoutnativeimage/reference/src/main/java/software/amazonaws/test/Handler.java create mode 100644 archetypes/archetype-app-quickstart/src/test/resources/projects/apachehttpclientwithoutnativeimage/reference/src/main/resources/simplelogger.properties create mode 100644 archetypes/archetype-app-quickstart/src/test/resources/projects/apachehttpclientwithoutnativeimage/reference/src/test/java/software/amazonaws/test/HandlerTest.java create mode 100644 archetypes/archetype-app-quickstart/src/test/resources/projects/nettyclient/archetype.properties create mode 100644 archetypes/archetype-app-quickstart/src/test/resources/projects/nettyclient/goal.txt create mode 100644 archetypes/archetype-app-quickstart/src/test/resources/projects/nettyclient/reference/README.md create mode 100644 archetypes/archetype-app-quickstart/src/test/resources/projects/nettyclient/reference/pom.xml create mode 100644 archetypes/archetype-app-quickstart/src/test/resources/projects/nettyclient/reference/src/main/java/software/amazonaws/test/App.java create mode 100644 archetypes/archetype-app-quickstart/src/test/resources/projects/nettyclient/reference/src/main/java/software/amazonaws/test/DependencyFactory.java create mode 100644 archetypes/archetype-app-quickstart/src/test/resources/projects/nettyclient/reference/src/main/java/software/amazonaws/test/Handler.java create mode 100644 archetypes/archetype-app-quickstart/src/test/resources/projects/nettyclient/reference/src/main/resources/simplelogger.properties create mode 100644 archetypes/archetype-app-quickstart/src/test/resources/projects/nettyclient/reference/src/test/java/software/amazonaws/test/HandlerTest.java create mode 100644 archetypes/archetype-app-quickstart/src/test/resources/projects/urlhttpclient/archetype.properties create mode 100644 archetypes/archetype-app-quickstart/src/test/resources/projects/urlhttpclient/goal.txt create mode 100644 archetypes/archetype-app-quickstart/src/test/resources/projects/urlhttpclient/reference/README.md create mode 100644 archetypes/archetype-app-quickstart/src/test/resources/projects/urlhttpclient/reference/pom.xml create mode 100644 archetypes/archetype-app-quickstart/src/test/resources/projects/urlhttpclient/reference/src/main/java/software/amazonaws/test/App.java create mode 100644 archetypes/archetype-app-quickstart/src/test/resources/projects/urlhttpclient/reference/src/main/java/software/amazonaws/test/DependencyFactory.java create mode 100644 archetypes/archetype-app-quickstart/src/test/resources/projects/urlhttpclient/reference/src/main/java/software/amazonaws/test/Handler.java create mode 100644 archetypes/archetype-app-quickstart/src/test/resources/projects/urlhttpclient/reference/src/main/resources/simplelogger.properties create mode 100644 archetypes/archetype-app-quickstart/src/test/resources/projects/urlhttpclient/reference/src/test/java/software/amazonaws/test/HandlerTest.java create mode 100644 archetypes/archetype-tools/pom.xml rename archetypes/{archetype-lambda => archetype-tools}/src/main/resources/global.vm (96%) rename archetypes/{archetype-lambda => archetype-tools}/src/main/resources/map-service-to-client-prefix (100%) create mode 100644 archetypes/archetype-tools/src/test/resources/serviceMapping.vm create mode 100644 buildspecs/archetype-native-image-test.yml create mode 100644 buildspecs/native-image-integ-test.yml create mode 100644 core/sdk-core/src/main/resources/META-INF/native-image/software.amazon.awssdk/sdk-core/native-image.properties create mode 100644 core/sdk-core/src/main/resources/META-INF/native-image/software.amazon.awssdk/sdk-core/reflect-config.json create mode 100644 core/sdk-core/src/main/resources/META-INF/native-image/software.amazon.awssdk/sdk-core/resource-config.json create mode 100644 http-clients/apache-client/src/main/resources/META-INF/native-image/software.amazon.awssdk/apache-client/proxy-config.json create mode 100644 http-clients/apache-client/src/main/resources/META-INF/native-image/software.amazon.awssdk/apache-client/reflect-config.json create mode 100644 http-clients/apache-client/src/main/resources/META-INF/native-image/software.amazon.awssdk/apache-client/resource-config.json create mode 100644 http-clients/netty-nio-client/src/main/resources/META-INF/native-image/software.amazon.awssdk/netty-nio-client/native-image.properties create mode 100644 http-clients/netty-nio-client/src/main/resources/META-INF/native-image/software.amazon.awssdk/netty-nio-client/reflect-config.json create mode 100644 http-clients/netty-nio-client/src/main/resources/META-INF/native-image/software.amazon.awssdk/netty-nio-client/resource-config.json create mode 100644 http-clients/url-connection-client/src/main/resources/META-INF/native-image/software.amazon.awssdk/url-connection-client/reflect-config.json create mode 100644 http-clients/url-connection-client/src/main/resources/META-INF/native-image/software.amazon.awssdk/url-connection-client/resource-config.json create mode 100644 services-custom/dynamodb-enhanced/src/main/resources/META-INF/native-image/software.amazon.awssdk.dynamodb-enhanced/reflect-config.json create mode 100644 services/apigateway/src/main/resources/META-INF/native-image/software.amazon.awssdk/apigateway/reflect-config.json create mode 100644 services/cloudsearchdomain/src/main/resources/META-INF/native-image/software.amazon.awssdk/cloudsearchdomain/reflect-config.json create mode 100644 services/docdb/src/main/resources/META-INF/native-image/software.amazon.awssdk/docdb/reflect-config.json create mode 100644 services/ec2/src/main/resources/META-INF/native-image/software.amazon.awssdk/ec2/reflect-config.json create mode 100644 services/glacier/src/main/resources/META-INF/native-image/software.amazon.awssdk/glacier/reflect-config.json create mode 100644 services/iam/src/main/resources/META-INF/native-image/software.amazon.awssdk/iam/reflect-config.json create mode 100644 services/machinelearning/src/main/resources/META-INF/native-image/software.amazon.awssdk/machinelearning/reflect-config.json create mode 100644 services/neptune/src/main/resources/META-INF/native-image/software.amazon.awssdk/neptune/reflect-config.json create mode 100644 services/rds/src/main/resources/META-INF/native-image/software.amazon.awssdk/rds/reflect-config.json create mode 100644 services/route53/src/main/resources/META-INF/software.amazon.awssdk.route53/reflect-config.json create mode 100644 services/s3/src/main/resources/META-INF/native-image/software.amazon.awssdk/s3/reflect-config.json create mode 100644 services/s3control/src/main/resources/META-INF/native-image/software.amazon.awssdk/s3control/reflect-config.json create mode 100644 services/sqs/src/main/resources/META-INF/native-image/software.amazon.awssdk/sqs/reflect-config.json create mode 100644 test/sdk-native-image-test/README.md create mode 100644 test/sdk-native-image-test/pom.xml create mode 100644 test/sdk-native-image-test/src/main/java/software/amazon/awssdk/nativeimagetest/App.java create mode 100644 test/sdk-native-image-test/src/main/java/software/amazon/awssdk/nativeimagetest/DependencyFactory.java create mode 100644 test/sdk-native-image-test/src/main/java/software/amazon/awssdk/nativeimagetest/DynamoDbEnhancedClientTestRunner.java create mode 100644 test/sdk-native-image-test/src/main/java/software/amazon/awssdk/nativeimagetest/S3TestRunner.java create mode 100644 test/sdk-native-image-test/src/main/java/software/amazon/awssdk/nativeimagetest/TestRunner.java create mode 100644 test/sdk-native-image-test/src/main/resources/simplelogger.properties diff --git a/.changes/next-release/feature-AWSSDKforJavav2-61fb1a6.json b/.changes/next-release/feature-AWSSDKforJavav2-61fb1a6.json new file mode 100644 index 000000000000..1e1287fb1861 --- /dev/null +++ b/.changes/next-release/feature-AWSSDKforJavav2-61fb1a6.json @@ -0,0 +1,6 @@ +{ + "category": "AWS SDK for Java v2", + "contributor": "", + "type": "feature", + "description": "Created a new archetype, `archetype-app-quickstart`, which allows you to create a simple application with SDK dependencies" +} diff --git a/.changes/next-release/feature-AWSSDKforJavav2-818e995.json b/.changes/next-release/feature-AWSSDKforJavav2-818e995.json new file mode 100644 index 000000000000..92fda02855c7 --- /dev/null +++ b/.changes/next-release/feature-AWSSDKforJavav2-818e995.json @@ -0,0 +1,6 @@ +{ + "category": "AWS SDK for Java v2", + "contributor": "", + "type": "feature", + "description": "Add GraalVM Native Image configurations for SDK classes" +} diff --git a/archetypes/README.md b/archetypes/README.md index 70980eb12890..cb7da5f1bdfc 100755 --- a/archetypes/README.md +++ b/archetypes/README.md @@ -5,5 +5,9 @@ This module contains maven archetypes for AWS Java SDK 2.x. ## Archetypes -- [archetype-lambda](archetype-lambda/README.md) - a lambda function template using AWS Java SDK 2.x +- [archetype-app-quickstart](archetype-app-quickstart/README.md) - a simple client application + template using the AWS SDK for Java 2.x +- [archetype-lambda](archetype-lambda/README.md) - an AWS Lambda function + template using the AWS SDK for Java 2.x + diff --git a/archetypes/archetype-app-quickstart/README.md b/archetypes/archetype-app-quickstart/README.md new file mode 100755 index 000000000000..2c95d96ff8b7 --- /dev/null +++ b/archetypes/archetype-app-quickstart/README.md @@ -0,0 +1,61 @@ +# Maven Archetype for client applications using the AWS SDK for Java 2.x + +## Description +This is an Apache Maven Archetype to create a client application with +a dependency of [AWS Java SDK 2.x][aws-java-sdk-v2]. + +### Features + +The generated application has the following features: + +- Uses [Bill of Materials](BOM) to manage SDK dependencies +- Contains the code to create the SDK client +- Out-of-box support of GraalVM Native Image when `nativeImage` is enabled + +## Usage + +You can use `mvn archetype:generate` to generate a project using this archetype. See [maven archetype usage guidance][maven-archetype-usage] for more information. + +- Interactive mode + +``` +mvn archetype:generate \ + -DarchetypeGroupId=software.amazon.awssdk \ + -DarchetypeArtifactId=archetype-app-quickstart \ + -DarchetypeVersion=2.x +``` + +- Batch mode + +``` +mvn archetype:generate \ + -DarchetypeGroupId=software.amazon.awssdk \ + -DarchetypeArtifactId=archetype-app-quickstart \ + -DarchetypeVersion=2.x \ + -DgroupId=com.test \ + -DnativeImage=true \ + -DhttpClient=apache-client \ + -DartifactId=sample-project \ + -Dservice=s3 \ + -DinteractiveMode=false +``` + +### Parameters + +Parameter Name | Default Value | Description +---|---|--- +`service` (required) | n/a | Specifies the service client to be used in the application, eg: s3, dynamodb. Only one service should be provided. You can find available services [here][java-sdk-v2-services]. +`groupId`(required) | n/a | Specifies the group ID of the project +`artifactId`(required) | n/a | Specifies the artifact ID of the project +`nativeImage`(required) | n/a | Specifies whether GraalVM Native Image configuration should be included +`httpClient`(required) | n/a | Specifies the http client to be used by the SDK client. Available options are `url-connection-client` (sync), `apache-client` (sync), `netty-nio-client` (async). See [http clients][sdk-http-clients] +`javaSdkVersion` | Same version as the archetype version | Specifies the version of the AWS Java SDK 2.x to be used +`version` | 1.0-SNAPSHOT | Specifies the version of the project +`package` | ${groupId} | Specifies the package name for the classes + + +[aws-java-sdk-v2]: https://github.com/aws/aws-sdk-java-v2 +[java-sdk-v2-services]: https://github.com/aws/aws-sdk-java-v2/tree/master/services +[sdk-http-clients]: https://github.com/aws/aws-sdk-java-v2/tree/master/http-clients +[maven-archetype-usage]: https://maven.apache.org/archetype/maven-archetype-plugin/usage.html +[graalvm]: https://www.graalvm.org/docs/getting-started/#native-images diff --git a/archetypes/archetype-app-quickstart/pom.xml b/archetypes/archetype-app-quickstart/pom.xml new file mode 100644 index 000000000000..cc61645656c4 --- /dev/null +++ b/archetypes/archetype-app-quickstart/pom.xml @@ -0,0 +1,174 @@ + + + + + + archetypes + software.amazon.awssdk + 2.16.1-SNAPSHOT + + 4.0.0 + + archetype-app-quickstart + maven-archetype + AWS Java SDK :: Archetype App + + The AWS SDK for Java - Maven archetype for a sample application using AWS Java SDK 2.x + + + + 3.2.0 + 3.2.0 + 1.6.0 + + + + + software.amazon.awssdk + archetype-tools + ${awsjavasdk.version} + provided + + + + + + + src/main/resources + true + + META-INF/maven/archetype-metadata.xml + + + + src/main/resources + false + + META-INF/maven/archetype-metadata.xml + + + + + + org.apache.maven.archetype + archetype-packaging + ${maven.archetype.version} + + + + + + maven-archetype-plugin + ${maven.archetype.version} + + true + true + ${skip.unit.tests} + + + + integration-test + verify + + integration-test + + + + + + + + org.apache.maven.plugins + maven-dependency-plugin + ${maven-dependency-plugin.version} + + + unpack-archetype-tools + process-classes + + unpack + + + + + software.amazon.awssdk + archetype-tools + ${project.version} + ${basedir}/target/classes/archetype-resources + **/*.vm + + + + + + + + + + maven-resources-plugin + ${maven.resource.plugin.version} + + + copy-resources-to-sub-folder + process-classes + + copy-resources + + + ${basedir}/target/classes/archetype-resources/src/main/java + UTF-8 + + + ${basedir}/target/classes/archetype-resources + + global.vm + serviceMapping.vm + + + + + + + copy-resources-to-sub-folder-2 + process-classes + + copy-resources + + + ${basedir}/target/classes + UTF-8 + + + ${basedir}/target/classes/archetype-resources + + global.vm + serviceMapping.vm + + + + + + + + + + + \ No newline at end of file diff --git a/archetypes/archetype-app-quickstart/src/main/resources/META-INF/maven/archetype-metadata.xml b/archetypes/archetype-app-quickstart/src/main/resources/META-INF/maven/archetype-metadata.xml new file mode 100644 index 000000000000..ced7dbdba15b --- /dev/null +++ b/archetypes/archetype-app-quickstart/src/main/resources/META-INF/maven/archetype-metadata.xml @@ -0,0 +1,46 @@ + + + + + src/main/java + + **/*.java + + + + src/test/java + + **/*.java + + + + src/main/resources + + simplelogger.properties + + + + + + .gitignore + README.md + + + + + + ${project.version} + \d+\.\d+.\d+ + + + + + (url-connection-client|apache-client|netty-nio-client) + + + (true|false) + + + diff --git a/archetypes/archetype-app-quickstart/src/main/resources/archetype-resources/.gitignore b/archetypes/archetype-app-quickstart/src/main/resources/archetype-resources/.gitignore new file mode 100644 index 000000000000..a500caff54ac --- /dev/null +++ b/archetypes/archetype-app-quickstart/src/main/resources/archetype-resources/.gitignore @@ -0,0 +1,17 @@ +# Eclipse +.classpath +.project +.settings/ + +# Intellij +.idea/ +*.iml +*.iws + +# Mac +.DS_Store + +# Maven +target/ + +**/dependency-reduced-pom.xml diff --git a/archetypes/archetype-app-quickstart/src/main/resources/archetype-resources/README.md b/archetypes/archetype-app-quickstart/src/main/resources/archetype-resources/README.md new file mode 100644 index 000000000000..81bdf7a33d94 --- /dev/null +++ b/archetypes/archetype-app-quickstart/src/main/resources/archetype-resources/README.md @@ -0,0 +1,55 @@ +#[[#]]# App + +This project contains a maven application with [AWS Java SDK 2.x](https://github.com/aws/aws-sdk-java-v2) dependencies. + +#[[##]]# Prerequisites +- Java 1.8+ +- Apache Maven +- GraalVM Native Image (optional) + +#[[##]]# Development + +Below is the structure of the generated project. + +``` +├── src +│   ├── main +│   │   ├── java +│   │   │   └── package +│   │   │   ├── App.java +│   │   │   ├── DependencyFactory.java +│   │   │   └── Handler.java +│   │   └── resources +│   │   └── simplelogger.properties +│   └── test +│   └── java +│   └── package +│   └── HandlerTest.java +``` + +- `App.java`: main entry of the application +- `DependencyFactory.java`: creates the SDK client +- `Handler.java`: you can invoke the api calls using the SDK client here. + +#[[####]]# Building the project +``` +mvn clean package +``` + +#if( $nativeImage == 'true') +#[[####]]# Building the native image + +Note that it requires `native-image` installed in your environment + +``` +mvn clean package -P native-image +``` +After it finishes, you can find the generated native image in the `target +` folder. + +You can run the following command to execute it. + +``` +target/${artifactId} +``` +#end diff --git a/archetypes/archetype-app-quickstart/src/main/resources/archetype-resources/pom.xml b/archetypes/archetype-app-quickstart/src/main/resources/archetype-resources/pom.xml new file mode 100644 index 000000000000..020e0d3db7da --- /dev/null +++ b/archetypes/archetype-app-quickstart/src/main/resources/archetype-resources/pom.xml @@ -0,0 +1,149 @@ +#parse ( "global.vm") + + + 4.0.0 + + ${groupId} + ${artifactId} + ${version} + jar + + UTF-8 + 1.8 + 1.8 + 3.2.1 + 3.6.1 + 1.6.0 + ${javaSdkVersion} + 1.7.28 + 21.0.0 + 5.4.2 + + + + + + software.amazon.awssdk + bom + ${aws.java.sdk.version} + pom + import + + + + + + + software.amazon.awssdk + ${moduleName} + + + software.amazon.awssdk + netty-nio-client + + + software.amazon.awssdk + apache-client + + + + + + software.amazon.awssdk + ${httpClient} +#if( $httpClient == 'apache-client') + + + commons-logging + commons-logging + + +#end + + + + org.slf4j + slf4j-api + ${slf4j.version} + + + + org.slf4j + slf4j-simple + ${slf4j.version} + + +#if( $httpClient == 'apache-client') + + + org.slf4j + jcl-over-slf4j + ${slf4j.version} + +#end + +#if( $nativeImage == 'true') + + org.graalvm.sdk + graal-sdk + ${graalvm.version} + provided + +#end + + + + org.junit.jupiter + junit-jupiter + ${junit5.version} + test + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + ${maven.compiler.plugin.version} + + + + +#if( $nativeImage == 'true') + + + native-image + + + + org.graalvm.nativeimage + native-image-maven-plugin + ${graalvm.version} + + + + native-image + + package + + + + ${artifactId} + ${package}.App + + + --verbose + --no-fallback + --initialize-at-build-time=org.slf4j + + + + + + + + + #end + diff --git a/archetypes/archetype-app-quickstart/src/main/resources/archetype-resources/src/main/java/App.java b/archetypes/archetype-app-quickstart/src/main/resources/archetype-resources/src/main/java/App.java new file mode 100644 index 000000000000..44ea2ca440ac --- /dev/null +++ b/archetypes/archetype-app-quickstart/src/main/resources/archetype-resources/src/main/java/App.java @@ -0,0 +1,17 @@ +#parse ( "global.vm") +package ${package}; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class App { + private static final Logger logger = LoggerFactory.getLogger(App.class); + + public static void main(String... args) { + logger.info("Application starts"); + + Handler handler = new Handler(); + handler.sendRequest(); + + logger.info("Application ends"); + } +} diff --git a/archetypes/archetype-app-quickstart/src/main/resources/archetype-resources/src/main/java/DependencyFactory.java b/archetypes/archetype-app-quickstart/src/main/resources/archetype-resources/src/main/java/DependencyFactory.java new file mode 100644 index 000000000000..65d8c9d8cf47 --- /dev/null +++ b/archetypes/archetype-app-quickstart/src/main/resources/archetype-resources/src/main/java/DependencyFactory.java @@ -0,0 +1,23 @@ +#parse ( "global.vm") + +package ${package}; + +import software.amazon.awssdk.http.${httpClientPackageName}; +import software.amazon.awssdk.services.${servicePackage}.${serviceClientClassName}; + +/** + * The module containing all dependencies required by the {@link Handler}. + */ +public class DependencyFactory { + + private DependencyFactory() {} + + /** + * @return an instance of ${serviceClientClassName} + */ + public static ${serviceClientClassName} ${serviceClientVariable}Client() { + return ${serviceClientClassName}.builder() + .httpClientBuilder(${httpClientClassName}.builder()) + .build(); + } +} diff --git a/archetypes/archetype-app-quickstart/src/main/resources/archetype-resources/src/main/java/Handler.java b/archetypes/archetype-app-quickstart/src/main/resources/archetype-resources/src/main/java/Handler.java new file mode 100644 index 000000000000..83c7f3a2d762 --- /dev/null +++ b/archetypes/archetype-app-quickstart/src/main/resources/archetype-resources/src/main/java/Handler.java @@ -0,0 +1,17 @@ +#parse ( "global.vm") +package ${package}; + +import software.amazon.awssdk.services.${servicePackage}.${serviceClientClassName}; + + +public class Handler { + private final ${serviceClientClassName} ${serviceClientVariable}Client; + + public Handler() { + ${serviceClientVariable}Client = DependencyFactory.${serviceClientVariable}Client(); + } + + public void sendRequest() { + // TODO: invoking the api calls using ${serviceClientVariable}Client. + } +} diff --git a/archetypes/archetype-app-quickstart/src/main/resources/archetype-resources/src/main/resources/simplelogger.properties b/archetypes/archetype-app-quickstart/src/main/resources/archetype-resources/src/main/resources/simplelogger.properties new file mode 100644 index 000000000000..0e6cb98a68ad --- /dev/null +++ b/archetypes/archetype-app-quickstart/src/main/resources/archetype-resources/src/main/resources/simplelogger.properties @@ -0,0 +1,24 @@ +# SLF4J's SimpleLogger configuration file +# Simple implementation of Logger that sends all enabled log messages, for all defined loggers, to System.err. + +# Default logging detail level for all instances of SimpleLogger. +# Must be one of ("trace", "debug", "info", "warn", or "error"). +# If not specified, defaults to "info". +org.slf4j.simpleLogger.defaultLogLevel=info + +# Log SDK requests +org.slf4j.simpleLogger.log.software.amazon.awssdk.request=debug +org.slf4j.simpleLogger.showDateTime=true +org.slf4j.simpleLogger.dateTimeFormat=yyyy-MM-dd HH:mm:ss:SSS Z + +# Set to true if you want to output the current thread name. +# Defaults to true. +org.slf4j.simpleLogger.showThreadName=true + +# Set to true if you want the Logger instance name to be included in output messages. +# Defaults to true. +#org.slf4j.simpleLogger.showLogName=true + +# Set to true if you want the last component of the name to be included in output messages. +# Defaults to false. +org.slf4j.simpleLogger.showShortLogName=false \ No newline at end of file diff --git a/archetypes/archetype-app-quickstart/src/main/resources/archetype-resources/src/test/java/HandlerTest.java b/archetypes/archetype-app-quickstart/src/main/resources/archetype-resources/src/test/java/HandlerTest.java new file mode 100644 index 000000000000..6f709fac3fbd --- /dev/null +++ b/archetypes/archetype-app-quickstart/src/main/resources/archetype-resources/src/test/java/HandlerTest.java @@ -0,0 +1,10 @@ +#set( $symbol_pound = '#' ) +#set( $symbol_dollar = '$' ) +#set( $symbol_escape = '\' ) +package ${package}; + +import org.junit.jupiter.api.Test; + +public class HandlerTest { + //TODO add tests here +} diff --git a/archetypes/archetype-app-quickstart/src/test/resources/projects/apachehttpclient/archetype.properties b/archetypes/archetype-app-quickstart/src/test/resources/projects/apachehttpclient/archetype.properties new file mode 100644 index 000000000000..0af6b84ce1aa --- /dev/null +++ b/archetypes/archetype-app-quickstart/src/test/resources/projects/apachehttpclient/archetype.properties @@ -0,0 +1,8 @@ +groupId=software.amazonaws.test +artifactId=test-apache-artifact +version=1.0-SNAPSHOT +package=software.amazonaws.test +service=s3 +httpClient=apache-client +javaSdkVersion=2.11.0 +nativeImage=true \ No newline at end of file diff --git a/archetypes/archetype-app-quickstart/src/test/resources/projects/apachehttpclient/goal.txt b/archetypes/archetype-app-quickstart/src/test/resources/projects/apachehttpclient/goal.txt new file mode 100644 index 000000000000..4a1a71d3364c --- /dev/null +++ b/archetypes/archetype-app-quickstart/src/test/resources/projects/apachehttpclient/goal.txt @@ -0,0 +1 @@ +verify \ No newline at end of file diff --git a/archetypes/archetype-app-quickstart/src/test/resources/projects/apachehttpclient/reference/README.md b/archetypes/archetype-app-quickstart/src/test/resources/projects/apachehttpclient/reference/README.md new file mode 100644 index 000000000000..d17e94244e89 --- /dev/null +++ b/archetypes/archetype-app-quickstart/src/test/resources/projects/apachehttpclient/reference/README.md @@ -0,0 +1,53 @@ +# App + +This project contains a maven application with [AWS Java SDK 2.x](https://github.com/aws/aws-sdk-java-v2) dependencies. + +## Prerequisites +- Java 1.8+ +- Apache Maven +- GraalVM Native Image (optional) + +## Development + +Below is the structure of the generated project. + +``` +├── src +│   ├── main +│   │   ├── java +│   │   │   └── package +│   │   │   ├── App.java +│   │   │   ├── DependencyFactory.java +│   │   │   └── Handler.java +│   │   └── resources +│   │   └── simplelogger.properties +│   └── test +│   └── java +│   └── package +│   └── HandlerTest.java +``` + +- `App.java`: main entry of the application +- `DependencyFactory.java`: creates the SDK client +- `Handler.java`: you can invoke the api calls using the SDK client here. + +#### Building the project +``` +mvn clean package +``` + +#### Building the native image + +Note that it requires `native-image` installed in your environment + +``` +mvn clean package -P native-image +``` +After it finishes, you can find the generated native image in the `target +` folder. + +You can run the following command to execute it. + +``` +target/test-apache-artifact +``` diff --git a/archetypes/archetype-app-quickstart/src/test/resources/projects/apachehttpclient/reference/pom.xml b/archetypes/archetype-app-quickstart/src/test/resources/projects/apachehttpclient/reference/pom.xml new file mode 100644 index 000000000000..8fb45458697e --- /dev/null +++ b/archetypes/archetype-app-quickstart/src/test/resources/projects/apachehttpclient/reference/pom.xml @@ -0,0 +1,140 @@ + + + 4.0.0 + + software.amazonaws.test + test-apache-artifact + 1.0-SNAPSHOT + jar + + UTF-8 + 1.8 + 1.8 + 3.2.1 + 3.6.1 + 1.6.0 + 2.11.0 + 1.7.28 + 21.0.0 + 5.4.2 + + + + + + software.amazon.awssdk + bom + ${aws.java.sdk.version} + pom + import + + + + + + + software.amazon.awssdk + s3 + + + software.amazon.awssdk + netty-nio-client + + + software.amazon.awssdk + apache-client + + + + + + software.amazon.awssdk + apache-client + + + commons-logging + commons-logging + + + + + + org.slf4j + slf4j-api + ${slf4j.version} + + + + org.slf4j + slf4j-simple + ${slf4j.version} + + + + + org.slf4j + jcl-over-slf4j + ${slf4j.version} + + + + org.graalvm.sdk + graal-sdk + ${graalvm.version} + provided + + + + + org.junit.jupiter + junit-jupiter + ${junit5.version} + test + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + ${maven.compiler.plugin.version} + + + + + + + native-image + + + + org.graalvm.nativeimage + native-image-maven-plugin + ${graalvm.version} + + + + native-image + + package + + + + test-apache-artifact + software.amazonaws.test.App + + + --verbose + --no-fallback + --initialize-at-build-time=org.slf4j + + + + + + + + + diff --git a/archetypes/archetype-app-quickstart/src/test/resources/projects/apachehttpclient/reference/src/main/java/software/amazonaws/test/App.java b/archetypes/archetype-app-quickstart/src/test/resources/projects/apachehttpclient/reference/src/main/java/software/amazonaws/test/App.java new file mode 100644 index 000000000000..b587b851e90e --- /dev/null +++ b/archetypes/archetype-app-quickstart/src/test/resources/projects/apachehttpclient/reference/src/main/java/software/amazonaws/test/App.java @@ -0,0 +1,16 @@ +package software.amazonaws.test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class App { + private static final Logger logger = LoggerFactory.getLogger(App.class); + + public static void main(String... args) { + logger.info("Application starts"); + + Handler handler = new Handler(); + handler.sendRequest(); + + logger.info("Application ends"); + } +} diff --git a/archetypes/archetype-app-quickstart/src/test/resources/projects/apachehttpclient/reference/src/main/java/software/amazonaws/test/DependencyFactory.java b/archetypes/archetype-app-quickstart/src/test/resources/projects/apachehttpclient/reference/src/main/java/software/amazonaws/test/DependencyFactory.java new file mode 100644 index 000000000000..113edb683c85 --- /dev/null +++ b/archetypes/archetype-app-quickstart/src/test/resources/projects/apachehttpclient/reference/src/main/java/software/amazonaws/test/DependencyFactory.java @@ -0,0 +1,22 @@ + +package software.amazonaws.test; + +import software.amazon.awssdk.http.apache.ApacheHttpClient; +import software.amazon.awssdk.services.s3.S3Client; + +/** + * The module containing all dependencies required by the {@link Handler}. + */ +public class DependencyFactory { + + private DependencyFactory() {} + + /** + * @return an instance of S3Client + */ + public static S3Client s3Client() { + return S3Client.builder() + .httpClientBuilder(ApacheHttpClient.builder()) + .build(); + } +} diff --git a/archetypes/archetype-app-quickstart/src/test/resources/projects/apachehttpclient/reference/src/main/java/software/amazonaws/test/Handler.java b/archetypes/archetype-app-quickstart/src/test/resources/projects/apachehttpclient/reference/src/main/java/software/amazonaws/test/Handler.java new file mode 100644 index 000000000000..fd15451b80fd --- /dev/null +++ b/archetypes/archetype-app-quickstart/src/test/resources/projects/apachehttpclient/reference/src/main/java/software/amazonaws/test/Handler.java @@ -0,0 +1,16 @@ +package software.amazonaws.test; + +import software.amazon.awssdk.services.s3.S3Client; + + +public class Handler { + private final S3Client s3Client; + + public Handler() { + s3Client = DependencyFactory.s3Client(); + } + + public void sendRequest() { + // TODO: invoking the api calls using s3Client. + } +} diff --git a/archetypes/archetype-app-quickstart/src/test/resources/projects/apachehttpclient/reference/src/main/resources/simplelogger.properties b/archetypes/archetype-app-quickstart/src/test/resources/projects/apachehttpclient/reference/src/main/resources/simplelogger.properties new file mode 100644 index 000000000000..0e6cb98a68ad --- /dev/null +++ b/archetypes/archetype-app-quickstart/src/test/resources/projects/apachehttpclient/reference/src/main/resources/simplelogger.properties @@ -0,0 +1,24 @@ +# SLF4J's SimpleLogger configuration file +# Simple implementation of Logger that sends all enabled log messages, for all defined loggers, to System.err. + +# Default logging detail level for all instances of SimpleLogger. +# Must be one of ("trace", "debug", "info", "warn", or "error"). +# If not specified, defaults to "info". +org.slf4j.simpleLogger.defaultLogLevel=info + +# Log SDK requests +org.slf4j.simpleLogger.log.software.amazon.awssdk.request=debug +org.slf4j.simpleLogger.showDateTime=true +org.slf4j.simpleLogger.dateTimeFormat=yyyy-MM-dd HH:mm:ss:SSS Z + +# Set to true if you want to output the current thread name. +# Defaults to true. +org.slf4j.simpleLogger.showThreadName=true + +# Set to true if you want the Logger instance name to be included in output messages. +# Defaults to true. +#org.slf4j.simpleLogger.showLogName=true + +# Set to true if you want the last component of the name to be included in output messages. +# Defaults to false. +org.slf4j.simpleLogger.showShortLogName=false \ No newline at end of file diff --git a/archetypes/archetype-app-quickstart/src/test/resources/projects/apachehttpclient/reference/src/test/java/software/amazonaws/test/HandlerTest.java b/archetypes/archetype-app-quickstart/src/test/resources/projects/apachehttpclient/reference/src/test/java/software/amazonaws/test/HandlerTest.java new file mode 100644 index 000000000000..9837081757f2 --- /dev/null +++ b/archetypes/archetype-app-quickstart/src/test/resources/projects/apachehttpclient/reference/src/test/java/software/amazonaws/test/HandlerTest.java @@ -0,0 +1,7 @@ +package software.amazonaws.test; + +import org.junit.jupiter.api.Test; + +public class HandlerTest { + //TODO add tests here +} diff --git a/archetypes/archetype-app-quickstart/src/test/resources/projects/apachehttpclientwithoutnativeimage/archetype.properties b/archetypes/archetype-app-quickstart/src/test/resources/projects/apachehttpclientwithoutnativeimage/archetype.properties new file mode 100644 index 000000000000..79cc885e1603 --- /dev/null +++ b/archetypes/archetype-app-quickstart/src/test/resources/projects/apachehttpclientwithoutnativeimage/archetype.properties @@ -0,0 +1,8 @@ +groupId=software.amazonaws.test +artifactId=test-apache-artifact +version=1.0-SNAPSHOT +package=software.amazonaws.test +service=s3 +httpClient=apache-client +javaSdkVersion=2.11.0 +nativeImage=false \ No newline at end of file diff --git a/archetypes/archetype-app-quickstart/src/test/resources/projects/apachehttpclientwithoutnativeimage/goal.txt b/archetypes/archetype-app-quickstart/src/test/resources/projects/apachehttpclientwithoutnativeimage/goal.txt new file mode 100644 index 000000000000..4a1a71d3364c --- /dev/null +++ b/archetypes/archetype-app-quickstart/src/test/resources/projects/apachehttpclientwithoutnativeimage/goal.txt @@ -0,0 +1 @@ +verify \ No newline at end of file diff --git a/archetypes/archetype-app-quickstart/src/test/resources/projects/apachehttpclientwithoutnativeimage/reference/README.md b/archetypes/archetype-app-quickstart/src/test/resources/projects/apachehttpclientwithoutnativeimage/reference/README.md new file mode 100644 index 000000000000..4b13a336abbc --- /dev/null +++ b/archetypes/archetype-app-quickstart/src/test/resources/projects/apachehttpclientwithoutnativeimage/reference/README.md @@ -0,0 +1,38 @@ +# App + +This project contains a maven application with [AWS Java SDK 2.x](https://github.com/aws/aws-sdk-java-v2) dependencies. + +## Prerequisites +- Java 1.8+ +- Apache Maven +- GraalVM Native Image (optional) + +## Development + +Below is the structure of the generated project. + +``` +├── src +│   ├── main +│   │   ├── java +│   │   │   └── package +│   │   │   ├── App.java +│   │   │   ├── DependencyFactory.java +│   │   │   └── Handler.java +│   │   └── resources +│   │   └── simplelogger.properties +│   └── test +│   └── java +│   └── package +│   └── HandlerTest.java +``` + +- `App.java`: main entry of the application +- `DependencyFactory.java`: creates the SDK client +- `Handler.java`: you can invoke the api calls using the SDK client here. + +#### Building the project +``` +mvn clean package +``` + diff --git a/archetypes/archetype-app-quickstart/src/test/resources/projects/apachehttpclientwithoutnativeimage/reference/pom.xml b/archetypes/archetype-app-quickstart/src/test/resources/projects/apachehttpclientwithoutnativeimage/reference/pom.xml new file mode 100644 index 000000000000..abe47b27513e --- /dev/null +++ b/archetypes/archetype-app-quickstart/src/test/resources/projects/apachehttpclientwithoutnativeimage/reference/pom.xml @@ -0,0 +1,101 @@ + + + 4.0.0 + + software.amazonaws.test + test-apache-artifact + 1.0-SNAPSHOT + jar + + UTF-8 + 1.8 + 1.8 + 3.2.1 + 3.6.1 + 1.6.0 + 2.11.0 + 1.7.28 + 21.0.0 + 5.4.2 + + + + + + software.amazon.awssdk + bom + ${aws.java.sdk.version} + pom + import + + + + + + + software.amazon.awssdk + s3 + + + software.amazon.awssdk + netty-nio-client + + + software.amazon.awssdk + apache-client + + + + + + software.amazon.awssdk + apache-client + + + commons-logging + commons-logging + + + + + + org.slf4j + slf4j-api + ${slf4j.version} + + + + org.slf4j + slf4j-simple + ${slf4j.version} + + + + + org.slf4j + jcl-over-slf4j + ${slf4j.version} + + + + + + org.junit.jupiter + junit-jupiter + ${junit5.version} + test + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + ${maven.compiler.plugin.version} + + + + + diff --git a/archetypes/archetype-app-quickstart/src/test/resources/projects/apachehttpclientwithoutnativeimage/reference/src/main/java/software/amazonaws/test/App.java b/archetypes/archetype-app-quickstart/src/test/resources/projects/apachehttpclientwithoutnativeimage/reference/src/main/java/software/amazonaws/test/App.java new file mode 100644 index 000000000000..b587b851e90e --- /dev/null +++ b/archetypes/archetype-app-quickstart/src/test/resources/projects/apachehttpclientwithoutnativeimage/reference/src/main/java/software/amazonaws/test/App.java @@ -0,0 +1,16 @@ +package software.amazonaws.test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class App { + private static final Logger logger = LoggerFactory.getLogger(App.class); + + public static void main(String... args) { + logger.info("Application starts"); + + Handler handler = new Handler(); + handler.sendRequest(); + + logger.info("Application ends"); + } +} diff --git a/archetypes/archetype-app-quickstart/src/test/resources/projects/apachehttpclientwithoutnativeimage/reference/src/main/java/software/amazonaws/test/DependencyFactory.java b/archetypes/archetype-app-quickstart/src/test/resources/projects/apachehttpclientwithoutnativeimage/reference/src/main/java/software/amazonaws/test/DependencyFactory.java new file mode 100644 index 000000000000..113edb683c85 --- /dev/null +++ b/archetypes/archetype-app-quickstart/src/test/resources/projects/apachehttpclientwithoutnativeimage/reference/src/main/java/software/amazonaws/test/DependencyFactory.java @@ -0,0 +1,22 @@ + +package software.amazonaws.test; + +import software.amazon.awssdk.http.apache.ApacheHttpClient; +import software.amazon.awssdk.services.s3.S3Client; + +/** + * The module containing all dependencies required by the {@link Handler}. + */ +public class DependencyFactory { + + private DependencyFactory() {} + + /** + * @return an instance of S3Client + */ + public static S3Client s3Client() { + return S3Client.builder() + .httpClientBuilder(ApacheHttpClient.builder()) + .build(); + } +} diff --git a/archetypes/archetype-app-quickstart/src/test/resources/projects/apachehttpclientwithoutnativeimage/reference/src/main/java/software/amazonaws/test/Handler.java b/archetypes/archetype-app-quickstart/src/test/resources/projects/apachehttpclientwithoutnativeimage/reference/src/main/java/software/amazonaws/test/Handler.java new file mode 100644 index 000000000000..fd15451b80fd --- /dev/null +++ b/archetypes/archetype-app-quickstart/src/test/resources/projects/apachehttpclientwithoutnativeimage/reference/src/main/java/software/amazonaws/test/Handler.java @@ -0,0 +1,16 @@ +package software.amazonaws.test; + +import software.amazon.awssdk.services.s3.S3Client; + + +public class Handler { + private final S3Client s3Client; + + public Handler() { + s3Client = DependencyFactory.s3Client(); + } + + public void sendRequest() { + // TODO: invoking the api calls using s3Client. + } +} diff --git a/archetypes/archetype-app-quickstart/src/test/resources/projects/apachehttpclientwithoutnativeimage/reference/src/main/resources/simplelogger.properties b/archetypes/archetype-app-quickstart/src/test/resources/projects/apachehttpclientwithoutnativeimage/reference/src/main/resources/simplelogger.properties new file mode 100644 index 000000000000..0e6cb98a68ad --- /dev/null +++ b/archetypes/archetype-app-quickstart/src/test/resources/projects/apachehttpclientwithoutnativeimage/reference/src/main/resources/simplelogger.properties @@ -0,0 +1,24 @@ +# SLF4J's SimpleLogger configuration file +# Simple implementation of Logger that sends all enabled log messages, for all defined loggers, to System.err. + +# Default logging detail level for all instances of SimpleLogger. +# Must be one of ("trace", "debug", "info", "warn", or "error"). +# If not specified, defaults to "info". +org.slf4j.simpleLogger.defaultLogLevel=info + +# Log SDK requests +org.slf4j.simpleLogger.log.software.amazon.awssdk.request=debug +org.slf4j.simpleLogger.showDateTime=true +org.slf4j.simpleLogger.dateTimeFormat=yyyy-MM-dd HH:mm:ss:SSS Z + +# Set to true if you want to output the current thread name. +# Defaults to true. +org.slf4j.simpleLogger.showThreadName=true + +# Set to true if you want the Logger instance name to be included in output messages. +# Defaults to true. +#org.slf4j.simpleLogger.showLogName=true + +# Set to true if you want the last component of the name to be included in output messages. +# Defaults to false. +org.slf4j.simpleLogger.showShortLogName=false \ No newline at end of file diff --git a/archetypes/archetype-app-quickstart/src/test/resources/projects/apachehttpclientwithoutnativeimage/reference/src/test/java/software/amazonaws/test/HandlerTest.java b/archetypes/archetype-app-quickstart/src/test/resources/projects/apachehttpclientwithoutnativeimage/reference/src/test/java/software/amazonaws/test/HandlerTest.java new file mode 100644 index 000000000000..9837081757f2 --- /dev/null +++ b/archetypes/archetype-app-quickstart/src/test/resources/projects/apachehttpclientwithoutnativeimage/reference/src/test/java/software/amazonaws/test/HandlerTest.java @@ -0,0 +1,7 @@ +package software.amazonaws.test; + +import org.junit.jupiter.api.Test; + +public class HandlerTest { + //TODO add tests here +} diff --git a/archetypes/archetype-app-quickstart/src/test/resources/projects/nettyclient/archetype.properties b/archetypes/archetype-app-quickstart/src/test/resources/projects/nettyclient/archetype.properties new file mode 100644 index 000000000000..16b16eac4f8d --- /dev/null +++ b/archetypes/archetype-app-quickstart/src/test/resources/projects/nettyclient/archetype.properties @@ -0,0 +1,8 @@ +groupId=software.amazonaws.test +artifactId=test-apache-artifact +version=1.0-SNAPSHOT +package=software.amazonaws.test +service=s3 +httpClient=netty-nio-client +javaSdkVersion=2.11.0 +nativeImage=true \ No newline at end of file diff --git a/archetypes/archetype-app-quickstart/src/test/resources/projects/nettyclient/goal.txt b/archetypes/archetype-app-quickstart/src/test/resources/projects/nettyclient/goal.txt new file mode 100644 index 000000000000..4a1a71d3364c --- /dev/null +++ b/archetypes/archetype-app-quickstart/src/test/resources/projects/nettyclient/goal.txt @@ -0,0 +1 @@ +verify \ No newline at end of file diff --git a/archetypes/archetype-app-quickstart/src/test/resources/projects/nettyclient/reference/README.md b/archetypes/archetype-app-quickstart/src/test/resources/projects/nettyclient/reference/README.md new file mode 100644 index 000000000000..d17e94244e89 --- /dev/null +++ b/archetypes/archetype-app-quickstart/src/test/resources/projects/nettyclient/reference/README.md @@ -0,0 +1,53 @@ +# App + +This project contains a maven application with [AWS Java SDK 2.x](https://github.com/aws/aws-sdk-java-v2) dependencies. + +## Prerequisites +- Java 1.8+ +- Apache Maven +- GraalVM Native Image (optional) + +## Development + +Below is the structure of the generated project. + +``` +├── src +│   ├── main +│   │   ├── java +│   │   │   └── package +│   │   │   ├── App.java +│   │   │   ├── DependencyFactory.java +│   │   │   └── Handler.java +│   │   └── resources +│   │   └── simplelogger.properties +│   └── test +│   └── java +│   └── package +│   └── HandlerTest.java +``` + +- `App.java`: main entry of the application +- `DependencyFactory.java`: creates the SDK client +- `Handler.java`: you can invoke the api calls using the SDK client here. + +#### Building the project +``` +mvn clean package +``` + +#### Building the native image + +Note that it requires `native-image` installed in your environment + +``` +mvn clean package -P native-image +``` +After it finishes, you can find the generated native image in the `target +` folder. + +You can run the following command to execute it. + +``` +target/test-apache-artifact +``` diff --git a/archetypes/archetype-app-quickstart/src/test/resources/projects/nettyclient/reference/pom.xml b/archetypes/archetype-app-quickstart/src/test/resources/projects/nettyclient/reference/pom.xml new file mode 100644 index 000000000000..bd4ece385699 --- /dev/null +++ b/archetypes/archetype-app-quickstart/src/test/resources/projects/nettyclient/reference/pom.xml @@ -0,0 +1,127 @@ + + + 4.0.0 + + software.amazonaws.test + test-apache-artifact + 1.0-SNAPSHOT + jar + + UTF-8 + 1.8 + 1.8 + 3.2.1 + 3.6.1 + 1.6.0 + 2.11.0 + 1.7.28 + 21.0.0 + 5.4.2 + + + + + + software.amazon.awssdk + bom + ${aws.java.sdk.version} + pom + import + + + + + + + software.amazon.awssdk + s3 + + + software.amazon.awssdk + netty-nio-client + + + software.amazon.awssdk + apache-client + + + + + + software.amazon.awssdk + netty-nio-client + + + + org.slf4j + slf4j-api + ${slf4j.version} + + + + org.slf4j + slf4j-simple + ${slf4j.version} + + + + + org.graalvm.sdk + graal-sdk + ${graalvm.version} + provided + + + + + org.junit.jupiter + junit-jupiter + ${junit5.version} + test + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + ${maven.compiler.plugin.version} + + + + + + + native-image + + + + org.graalvm.nativeimage + native-image-maven-plugin + ${graalvm.version} + + + + native-image + + package + + + + test-apache-artifact + software.amazonaws.test.App + + + --verbose + --no-fallback + --initialize-at-build-time=org.slf4j + + + + + + + + + diff --git a/archetypes/archetype-app-quickstart/src/test/resources/projects/nettyclient/reference/src/main/java/software/amazonaws/test/App.java b/archetypes/archetype-app-quickstart/src/test/resources/projects/nettyclient/reference/src/main/java/software/amazonaws/test/App.java new file mode 100644 index 000000000000..b587b851e90e --- /dev/null +++ b/archetypes/archetype-app-quickstart/src/test/resources/projects/nettyclient/reference/src/main/java/software/amazonaws/test/App.java @@ -0,0 +1,16 @@ +package software.amazonaws.test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class App { + private static final Logger logger = LoggerFactory.getLogger(App.class); + + public static void main(String... args) { + logger.info("Application starts"); + + Handler handler = new Handler(); + handler.sendRequest(); + + logger.info("Application ends"); + } +} diff --git a/archetypes/archetype-app-quickstart/src/test/resources/projects/nettyclient/reference/src/main/java/software/amazonaws/test/DependencyFactory.java b/archetypes/archetype-app-quickstart/src/test/resources/projects/nettyclient/reference/src/main/java/software/amazonaws/test/DependencyFactory.java new file mode 100644 index 000000000000..305d624b36b3 --- /dev/null +++ b/archetypes/archetype-app-quickstart/src/test/resources/projects/nettyclient/reference/src/main/java/software/amazonaws/test/DependencyFactory.java @@ -0,0 +1,22 @@ + +package software.amazonaws.test; + +import software.amazon.awssdk.http.nio.netty.NettyNioAsyncHttpClient; +import software.amazon.awssdk.services.s3.S3AsyncClient; + +/** + * The module containing all dependencies required by the {@link Handler}. + */ +public class DependencyFactory { + + private DependencyFactory() {} + + /** + * @return an instance of S3AsyncClient + */ + public static S3AsyncClient s3Client() { + return S3AsyncClient.builder() + .httpClientBuilder(NettyNioAsyncHttpClient.builder()) + .build(); + } +} diff --git a/archetypes/archetype-app-quickstart/src/test/resources/projects/nettyclient/reference/src/main/java/software/amazonaws/test/Handler.java b/archetypes/archetype-app-quickstart/src/test/resources/projects/nettyclient/reference/src/main/java/software/amazonaws/test/Handler.java new file mode 100644 index 000000000000..6a18ad1f4aed --- /dev/null +++ b/archetypes/archetype-app-quickstart/src/test/resources/projects/nettyclient/reference/src/main/java/software/amazonaws/test/Handler.java @@ -0,0 +1,16 @@ +package software.amazonaws.test; + +import software.amazon.awssdk.services.s3.S3AsyncClient; + + +public class Handler { + private final S3AsyncClient s3Client; + + public Handler() { + s3Client = DependencyFactory.s3Client(); + } + + public void sendRequest() { + // TODO: invoking the api calls using s3Client. + } +} diff --git a/archetypes/archetype-app-quickstart/src/test/resources/projects/nettyclient/reference/src/main/resources/simplelogger.properties b/archetypes/archetype-app-quickstart/src/test/resources/projects/nettyclient/reference/src/main/resources/simplelogger.properties new file mode 100644 index 000000000000..0e6cb98a68ad --- /dev/null +++ b/archetypes/archetype-app-quickstart/src/test/resources/projects/nettyclient/reference/src/main/resources/simplelogger.properties @@ -0,0 +1,24 @@ +# SLF4J's SimpleLogger configuration file +# Simple implementation of Logger that sends all enabled log messages, for all defined loggers, to System.err. + +# Default logging detail level for all instances of SimpleLogger. +# Must be one of ("trace", "debug", "info", "warn", or "error"). +# If not specified, defaults to "info". +org.slf4j.simpleLogger.defaultLogLevel=info + +# Log SDK requests +org.slf4j.simpleLogger.log.software.amazon.awssdk.request=debug +org.slf4j.simpleLogger.showDateTime=true +org.slf4j.simpleLogger.dateTimeFormat=yyyy-MM-dd HH:mm:ss:SSS Z + +# Set to true if you want to output the current thread name. +# Defaults to true. +org.slf4j.simpleLogger.showThreadName=true + +# Set to true if you want the Logger instance name to be included in output messages. +# Defaults to true. +#org.slf4j.simpleLogger.showLogName=true + +# Set to true if you want the last component of the name to be included in output messages. +# Defaults to false. +org.slf4j.simpleLogger.showShortLogName=false \ No newline at end of file diff --git a/archetypes/archetype-app-quickstart/src/test/resources/projects/nettyclient/reference/src/test/java/software/amazonaws/test/HandlerTest.java b/archetypes/archetype-app-quickstart/src/test/resources/projects/nettyclient/reference/src/test/java/software/amazonaws/test/HandlerTest.java new file mode 100644 index 000000000000..9837081757f2 --- /dev/null +++ b/archetypes/archetype-app-quickstart/src/test/resources/projects/nettyclient/reference/src/test/java/software/amazonaws/test/HandlerTest.java @@ -0,0 +1,7 @@ +package software.amazonaws.test; + +import org.junit.jupiter.api.Test; + +public class HandlerTest { + //TODO add tests here +} diff --git a/archetypes/archetype-app-quickstart/src/test/resources/projects/urlhttpclient/archetype.properties b/archetypes/archetype-app-quickstart/src/test/resources/projects/urlhttpclient/archetype.properties new file mode 100644 index 000000000000..931670cc7cee --- /dev/null +++ b/archetypes/archetype-app-quickstart/src/test/resources/projects/urlhttpclient/archetype.properties @@ -0,0 +1,8 @@ +groupId=software.amazonaws.test +artifactId=test-apache-artifact +version=1.0-SNAPSHOT +package=software.amazonaws.test +service=dynamodb +httpClient=url-connection-client +javaSdkVersion=2.11.0 +nativeImage=true \ No newline at end of file diff --git a/archetypes/archetype-app-quickstart/src/test/resources/projects/urlhttpclient/goal.txt b/archetypes/archetype-app-quickstart/src/test/resources/projects/urlhttpclient/goal.txt new file mode 100644 index 000000000000..4a1a71d3364c --- /dev/null +++ b/archetypes/archetype-app-quickstart/src/test/resources/projects/urlhttpclient/goal.txt @@ -0,0 +1 @@ +verify \ No newline at end of file diff --git a/archetypes/archetype-app-quickstart/src/test/resources/projects/urlhttpclient/reference/README.md b/archetypes/archetype-app-quickstart/src/test/resources/projects/urlhttpclient/reference/README.md new file mode 100644 index 000000000000..d17e94244e89 --- /dev/null +++ b/archetypes/archetype-app-quickstart/src/test/resources/projects/urlhttpclient/reference/README.md @@ -0,0 +1,53 @@ +# App + +This project contains a maven application with [AWS Java SDK 2.x](https://github.com/aws/aws-sdk-java-v2) dependencies. + +## Prerequisites +- Java 1.8+ +- Apache Maven +- GraalVM Native Image (optional) + +## Development + +Below is the structure of the generated project. + +``` +├── src +│   ├── main +│   │   ├── java +│   │   │   └── package +│   │   │   ├── App.java +│   │   │   ├── DependencyFactory.java +│   │   │   └── Handler.java +│   │   └── resources +│   │   └── simplelogger.properties +│   └── test +│   └── java +│   └── package +│   └── HandlerTest.java +``` + +- `App.java`: main entry of the application +- `DependencyFactory.java`: creates the SDK client +- `Handler.java`: you can invoke the api calls using the SDK client here. + +#### Building the project +``` +mvn clean package +``` + +#### Building the native image + +Note that it requires `native-image` installed in your environment + +``` +mvn clean package -P native-image +``` +After it finishes, you can find the generated native image in the `target +` folder. + +You can run the following command to execute it. + +``` +target/test-apache-artifact +``` diff --git a/archetypes/archetype-app-quickstart/src/test/resources/projects/urlhttpclient/reference/pom.xml b/archetypes/archetype-app-quickstart/src/test/resources/projects/urlhttpclient/reference/pom.xml new file mode 100644 index 000000000000..7cf7cdd150ad --- /dev/null +++ b/archetypes/archetype-app-quickstart/src/test/resources/projects/urlhttpclient/reference/pom.xml @@ -0,0 +1,127 @@ + + + 4.0.0 + + software.amazonaws.test + test-apache-artifact + 1.0-SNAPSHOT + jar + + UTF-8 + 1.8 + 1.8 + 3.2.1 + 3.6.1 + 1.6.0 + 2.11.0 + 1.7.28 + 21.0.0 + 5.4.2 + + + + + + software.amazon.awssdk + bom + ${aws.java.sdk.version} + pom + import + + + + + + + software.amazon.awssdk + dynamodb + + + software.amazon.awssdk + netty-nio-client + + + software.amazon.awssdk + apache-client + + + + + + software.amazon.awssdk + url-connection-client + + + + org.slf4j + slf4j-api + ${slf4j.version} + + + + org.slf4j + slf4j-simple + ${slf4j.version} + + + + + org.graalvm.sdk + graal-sdk + ${graalvm.version} + provided + + + + + org.junit.jupiter + junit-jupiter + ${junit5.version} + test + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + ${maven.compiler.plugin.version} + + + + + + + native-image + + + + org.graalvm.nativeimage + native-image-maven-plugin + ${graalvm.version} + + + + native-image + + package + + + + test-apache-artifact + software.amazonaws.test.App + + + --verbose + --no-fallback + --initialize-at-build-time=org.slf4j + + + + + + + + + diff --git a/archetypes/archetype-app-quickstart/src/test/resources/projects/urlhttpclient/reference/src/main/java/software/amazonaws/test/App.java b/archetypes/archetype-app-quickstart/src/test/resources/projects/urlhttpclient/reference/src/main/java/software/amazonaws/test/App.java new file mode 100644 index 000000000000..b587b851e90e --- /dev/null +++ b/archetypes/archetype-app-quickstart/src/test/resources/projects/urlhttpclient/reference/src/main/java/software/amazonaws/test/App.java @@ -0,0 +1,16 @@ +package software.amazonaws.test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class App { + private static final Logger logger = LoggerFactory.getLogger(App.class); + + public static void main(String... args) { + logger.info("Application starts"); + + Handler handler = new Handler(); + handler.sendRequest(); + + logger.info("Application ends"); + } +} diff --git a/archetypes/archetype-app-quickstart/src/test/resources/projects/urlhttpclient/reference/src/main/java/software/amazonaws/test/DependencyFactory.java b/archetypes/archetype-app-quickstart/src/test/resources/projects/urlhttpclient/reference/src/main/java/software/amazonaws/test/DependencyFactory.java new file mode 100644 index 000000000000..637edf6ea7a8 --- /dev/null +++ b/archetypes/archetype-app-quickstart/src/test/resources/projects/urlhttpclient/reference/src/main/java/software/amazonaws/test/DependencyFactory.java @@ -0,0 +1,22 @@ + +package software.amazonaws.test; + +import software.amazon.awssdk.http.urlconnection.UrlConnectionHttpClient; +import software.amazon.awssdk.services.dynamodb.DynamoDbClient; + +/** + * The module containing all dependencies required by the {@link Handler}. + */ +public class DependencyFactory { + + private DependencyFactory() {} + + /** + * @return an instance of DynamoDbClient + */ + public static DynamoDbClient dynamoDbClient() { + return DynamoDbClient.builder() + .httpClientBuilder(UrlConnectionHttpClient.builder()) + .build(); + } +} diff --git a/archetypes/archetype-app-quickstart/src/test/resources/projects/urlhttpclient/reference/src/main/java/software/amazonaws/test/Handler.java b/archetypes/archetype-app-quickstart/src/test/resources/projects/urlhttpclient/reference/src/main/java/software/amazonaws/test/Handler.java new file mode 100644 index 000000000000..5b40234b524a --- /dev/null +++ b/archetypes/archetype-app-quickstart/src/test/resources/projects/urlhttpclient/reference/src/main/java/software/amazonaws/test/Handler.java @@ -0,0 +1,16 @@ +package software.amazonaws.test; + +import software.amazon.awssdk.services.dynamodb.DynamoDbClient; + + +public class Handler { + private final DynamoDbClient dynamoDbClient; + + public Handler() { + dynamoDbClient = DependencyFactory.dynamoDbClient(); + } + + public void sendRequest() { + // TODO: invoking the api calls using dynamoDbClient. + } +} diff --git a/archetypes/archetype-app-quickstart/src/test/resources/projects/urlhttpclient/reference/src/main/resources/simplelogger.properties b/archetypes/archetype-app-quickstart/src/test/resources/projects/urlhttpclient/reference/src/main/resources/simplelogger.properties new file mode 100644 index 000000000000..0e6cb98a68ad --- /dev/null +++ b/archetypes/archetype-app-quickstart/src/test/resources/projects/urlhttpclient/reference/src/main/resources/simplelogger.properties @@ -0,0 +1,24 @@ +# SLF4J's SimpleLogger configuration file +# Simple implementation of Logger that sends all enabled log messages, for all defined loggers, to System.err. + +# Default logging detail level for all instances of SimpleLogger. +# Must be one of ("trace", "debug", "info", "warn", or "error"). +# If not specified, defaults to "info". +org.slf4j.simpleLogger.defaultLogLevel=info + +# Log SDK requests +org.slf4j.simpleLogger.log.software.amazon.awssdk.request=debug +org.slf4j.simpleLogger.showDateTime=true +org.slf4j.simpleLogger.dateTimeFormat=yyyy-MM-dd HH:mm:ss:SSS Z + +# Set to true if you want to output the current thread name. +# Defaults to true. +org.slf4j.simpleLogger.showThreadName=true + +# Set to true if you want the Logger instance name to be included in output messages. +# Defaults to true. +#org.slf4j.simpleLogger.showLogName=true + +# Set to true if you want the last component of the name to be included in output messages. +# Defaults to false. +org.slf4j.simpleLogger.showShortLogName=false \ No newline at end of file diff --git a/archetypes/archetype-app-quickstart/src/test/resources/projects/urlhttpclient/reference/src/test/java/software/amazonaws/test/HandlerTest.java b/archetypes/archetype-app-quickstart/src/test/resources/projects/urlhttpclient/reference/src/test/java/software/amazonaws/test/HandlerTest.java new file mode 100644 index 000000000000..9837081757f2 --- /dev/null +++ b/archetypes/archetype-app-quickstart/src/test/resources/projects/urlhttpclient/reference/src/test/java/software/amazonaws/test/HandlerTest.java @@ -0,0 +1,7 @@ +package software.amazonaws.test; + +import org.junit.jupiter.api.Test; + +public class HandlerTest { + //TODO add tests here +} diff --git a/archetypes/archetype-lambda/pom.xml b/archetypes/archetype-lambda/pom.xml index e28e7ead725c..9569a914cb8b 100644 --- a/archetypes/archetype-lambda/pom.xml +++ b/archetypes/archetype-lambda/pom.xml @@ -37,12 +37,11 @@ - software.amazon.awssdk - aws-sdk-java + archetype-tools ${awsjavasdk.version} - test + provided @@ -73,24 +72,6 @@ - - exec-maven-plugin - org.codehaus.mojo - ${exec-maven-plugin.version} - - - map-service-to-client-prefix - generate-resources - - exec - - - python - ${basedir}/src/main/resources/map-service-to-client-prefix - - - - maven-archetype-plugin ${maven.archetype.version} @@ -110,35 +91,52 @@ - + org.apache.maven.plugins maven-dependency-plugin ${maven-dependency-plugin.version} - - true - + + + unpack-archetype-tools + process-classes + + unpack + + + + + software.amazon.awssdk + archetype-tools + ${project.version} + ${basedir}/target/classes/archetype-resources + **/*.vm + + + + + maven-resources-plugin ${maven.resource.plugin.version} - copy-resources + copy-resources-to-sub-folder process-classes copy-resources - ${basedir}/target/classes/archetype-resources + ${basedir}/target/classes/archetype-resources/src/main/java UTF-8 - ${basedir}/target/classes/ + ${basedir}/target/classes/archetype-resources global.vm serviceMapping.vm @@ -148,17 +146,17 @@ - copy-resources-to-sub-folder + copy-resources-to-sub-folder-2 process-classes copy-resources - ${basedir}/target/classes/archetype-resources/src/main/java + ${basedir}/target/classes UTF-8 - ${basedir}/target/classes/ + ${basedir}/target/classes/archetype-resources global.vm serviceMapping.vm diff --git a/archetypes/archetype-lambda/src/main/resources/META-INF/maven/archetype-metadata.xml b/archetypes/archetype-lambda/src/main/resources/META-INF/maven/archetype-metadata.xml index 82f7c91a528c..08d6331f3465 100644 --- a/archetypes/archetype-lambda/src/main/resources/META-INF/maven/archetype-metadata.xml +++ b/archetypes/archetype-lambda/src/main/resources/META-INF/maven/archetype-metadata.xml @@ -1,5 +1,5 @@ - diff --git a/archetypes/archetype-tools/pom.xml b/archetypes/archetype-tools/pom.xml new file mode 100644 index 000000000000..83f98b6554a6 --- /dev/null +++ b/archetypes/archetype-tools/pom.xml @@ -0,0 +1,62 @@ + + + + + + archetypes + software.amazon.awssdk + 2.16.1-SNAPSHOT + + 4.0.0 + + archetype-tools + + + + + software.amazon.awssdk + aws-sdk-java + ${awsjavasdk.version} + provided + + + + + + + exec-maven-plugin + org.codehaus.mojo + ${exec-maven-plugin.version} + + + map-service-to-client-prefix + generate-resources + + exec + + + python + ${basedir}/src/main/resources/map-service-to-client-prefix + + + + + + + + \ No newline at end of file diff --git a/archetypes/archetype-lambda/src/main/resources/global.vm b/archetypes/archetype-tools/src/main/resources/global.vm similarity index 96% rename from archetypes/archetype-lambda/src/main/resources/global.vm rename to archetypes/archetype-tools/src/main/resources/global.vm index 610b556958ff..93a7a31620b4 100644 --- a/archetypes/archetype-lambda/src/main/resources/global.vm +++ b/archetypes/archetype-tools/src/main/resources/global.vm @@ -20,7 +20,7 @@ #end #set ( $serviceClientVariable = $serviceClientPrefix.substring(0,1).toLowerCase() + $serviceClientPrefix.substring(1)) #set( $regionEnum = $region.replace("-", "_").toUpperCase() ) -## map the client module name to the client class name and pacakge name +## map the client module name to the client class name and package name #if( $httpClient == 'url-connection-client') #set ($httpClientClassName = 'UrlConnectionHttpClient') #set ($httpClientPackageName = 'urlconnection.' + $httpClientClassName) diff --git a/archetypes/archetype-lambda/src/main/resources/map-service-to-client-prefix b/archetypes/archetype-tools/src/main/resources/map-service-to-client-prefix similarity index 100% rename from archetypes/archetype-lambda/src/main/resources/map-service-to-client-prefix rename to archetypes/archetype-tools/src/main/resources/map-service-to-client-prefix diff --git a/archetypes/archetype-tools/src/test/resources/serviceMapping.vm b/archetypes/archetype-tools/src/test/resources/serviceMapping.vm new file mode 100644 index 000000000000..4b7e3e20c424 --- /dev/null +++ b/archetypes/archetype-tools/src/test/resources/serviceMapping.vm @@ -0,0 +1 @@ +#set ( $serviceMapping ={"detective": "Detective", "efs": "Efs", "shield": "Shield", "appflow": "Appflow", "connectparticipant": "ConnectParticipant", "datapipeline": "DataPipeline", "kafka": "Kafka", "appstream": "AppStream", "dlm": "Dlm", "pinpointemail": "PinpointEmail", "glue": "Glue", "route53": "Route53", "sesv2": "SesV2", "storagegateway": "StorageGateway", "ses": "Ses", "resourcegroupstaggingapi": "ResourceGroupsTaggingApi", "personalizeruntime": "PersonalizeRuntime", "alexaforbusiness": "AlexaForBusiness", "qldb": "Qldb", "cloud9": "Cloud9", "appmesh": "AppMesh", "dynamodb": "DynamoDb", "cloudhsmv2": "CloudHsmV2", "elasticbeanstalk": "ElasticBeanstalk", "macie2": "Macie2", "cognitosync": "CognitoSync", "marketplaceentitlement": "MarketplaceEntitlement", "health": "Health", "kinesisvideo": "KinesisVideo", "cognitoidentity": "CognitoIdentity", "cloudwatchlogs": "CloudWatchLogs", "securityhub": "SecurityHub", "kinesis": "Kinesis", "polly": "Polly", "datasync": "DataSync", "autoscaling": "AutoScaling", "pinpointsmsvoice": "PinpointSmsVoice", "ssm": "Ssm", "sso": "Sso", "redshiftdata": "RedshiftData", "transcribestreaming": "TranscribeStreaming", "kinesisanalyticsv2": "KinesisAnalyticsV2", "dax": "Dax", "ssooidc": "SsoOidc", "apigateway": "ApiGateway", "medialive": "MediaLive", "groundstation": "GroundStation", "lexruntime": "LexRuntime", "snowball": "Snowball", "appconfig": "AppConfig", "mediaconvert": "MediaConvert", "macie": "Macie", "marketplacecatalog": "MarketplaceCatalog", "secretsmanager": "SecretsManager", "emr": "Emr", "iot1clickdevices": "Iot1ClickDevices", "dataexchange": "DataExchange", "forecastquery": "Forecastquery", "iotsitewise": "IoTSiteWise", "braket": "Braket", "opsworks": "OpsWorks", "iotthingsgraph": "IoTThingsGraph", "imagebuilder": "Imagebuilder", "mediapackage": "MediaPackage", "lightsail": "Lightsail", "xray": "XRay", "migrationhub": "MigrationHub", "connect": "Connect", "ebs": "Ebs", "qldbsession": "QldbSession", "iotevents": "IotEvents", "computeoptimizer": "ComputeOptimizer", "appsync": "AppSync", "iot1clickprojects": "Iot1ClickProjects", "pinpoint": "Pinpoint", "workdocs": "WorkDocs", "cloudwatchevents": "CloudWatchEvents", "sms": "Sms", "timestreamquery": "TimestreamQuery", "cloudwatch": "CloudWatch", "forecast": "Forecast", "route53domains": "Route53Domains", "kms": "Kms", "serverlessapplicationrepository": "ServerlessApplicationRepository", "budgets": "Budgets", "synthetics": "Synthetics", "applicationdiscovery": "ApplicationDiscovery", "sts": "Sts", "applicationautoscaling": "ApplicationAutoScaling", "personalize": "Personalize", "robomaker": "RoboMaker", "databasemigration": "DatabaseMigration", "frauddetector": "FraudDetector", "guardduty": "GuardDuty", "comprehendmedical": "ComprehendMedical", "ecs": "Ecs", "ecr": "Ecr", "codebuild": "CodeBuild", "directconnect": "DirectConnect", "mediastore": "MediaStore", "opsworkscm": "OpsWorksCm", "codestar": "CodeStar", "rds": "Rds", "gamelift": "GameLift", "quicksight": "QuickSight", "mediapackagevod": "MediaPackageVod", "firehose": "Firehose", "elasticsearch": "Elasticsearch", "outposts": "Outposts", "waf": "Waf", "licensemanager": "LicenseManager", "networkmanager": "NetworkManager", "elasticache": "ElastiCache", "eks": "Eks", "s3outposts": "S3Outposts", "kinesisvideoarchivedmedia": "KinesisVideoArchivedMedia", "lambda": "Lambda", "devicefarm": "DeviceFarm", "backup": "Backup", "redshift": "Redshift", "codegurureviewer": "CodeGuruReviewer", "cloudformation": "CloudFormation", "autoscalingplans": "AutoScalingPlans", "mediaconnect": "MediaConnect", "transcribe": "Transcribe", "textract": "Textract", "chime": "Chime", "iotdataplane": "IotDataPlane", "comprehend": "Comprehend", "iotanalytics": "IoTAnalytics", "iam": "Iam", "costexplorer": "CostExplorer", "eventbridge": "EventBridge", "machinelearning": "MachineLearning", "s3control": "S3Control", "transfer": "Transfer", "resourcegroups": "ResourceGroups", "support": "Support", "fms": "Fms", "ioteventsdata": "IotEventsData", "swf": "Swf", "kinesisvideosignaling": "KinesisVideoSignaling", "cloudsearchdomain": "CloudSearchDomain", "workmailmessageflow": "WorkMailMessageFlow", "acmpca": "AcmPca", "servicediscovery": "ServiceDiscovery", "rdsdata": "RdsData", "translate": "Translate", "athena": "Athena", "applicationinsights": "ApplicationInsights", "ram": "Ram", "lexmodelbuilding": "LexModelBuilding", "ec2instanceconnect": "Ec2InstanceConnect", "codeguruprofiler": "CodeGuruProfiler", "mturk": "MTurk", "cloudfront": "CloudFront", "ec2": "Ec2", "sagemakera2iruntime": "SageMakerA2IRuntime", "route53resolver": "Route53Resolver", "managedblockchain": "ManagedBlockchain", "kinesisanalytics": "KinesisAnalytics", "kendra": "Kendra", "identitystore": "Identitystore", "codepipeline": "CodePipeline", "elastictranscoder": "ElasticTranscoder", "organizations": "Organizations", "pi": "Pi", "servicecatalog": "ServiceCatalog", "apigatewayv2": "ApiGatewayV2", "servicequotas": "ServiceQuotas", "marketplacemetering": "MarketplaceMetering", "batch": "Batch", "codecommit": "CodeCommit", "mq": "Mq", "iotsecuretunneling": "IoTSecureTunneling", "costandusagereport": "CostAndUsageReport", "signer": "Signer", "migrationhubconfig": "MigrationHubConfig", "codestarnotifications": "CodestarNotifications", "elasticloadbalancing": "ElasticLoadBalancing", "pricing": "Pricing", "kinesisvideomedia": "KinesisVideoMedia", "rekognition": "Rekognition", "cloudtrail": "CloudTrail", "elasticloadbalancingv2": "ElasticLoadBalancingV2", "personalizeevents": "PersonalizeEvents", "ivs": "Ivs", "mediatailor": "MediaTailor", "cloudhsm": "CloudHsm", "honeycode": "Honeycode", "cloudsearch": "CloudSearch", "acm": "Acm", "timestreamwrite": "TimestreamWrite", "inspector": "Inspector", "lakeformation": "LakeFormation", "elasticinference": "ElasticInference", "schemas": "Schemas", "amplify": "Amplify", "globalaccelerator": "GlobalAccelerator", "s3": "S3", "clouddirectory": "CloudDirectory", "accessanalyzer": "AccessAnalyzer", "greengrass": "Greengrass", "worklink": "WorkLink", "sagemaker": "SageMaker", "config": "Config", "codeartifact": "Codeartifact", "workspaces": "WorkSpaces", "savingsplans": "Savingsplans", "sqs": "Sqs", "iot": "Iot", "codestarconnections": "CodeStarConnections", "ssoadmin": "SsoAdmin", "sfn": "Sfn", "directory": "Directory", "marketplacecommerceanalytics": "MarketplaceCommerceAnalytics", "sns": "Sns", "mediastoredata": "MediaStoreData", "workmail": "WorkMail", "cognitoidentityprovider": "CognitoIdentityProvider", "codedeploy": "CodeDeploy", "iotjobsdataplane": "IotJobsDataPlane", "mobile": "Mobile", "docdb": "DocDb", "neptune": "Neptune", "wafv2": "Wafv2", "glacier": "Glacier", "apigatewaymanagementapi": "ApiGatewayManagementApi", "fsx": "FSx", "sagemakerruntime": "SageMakerRuntime"}) \ No newline at end of file diff --git a/archetypes/pom.xml b/archetypes/pom.xml index f3a07cd5f986..6d2371ecec82 100644 --- a/archetypes/pom.xml +++ b/archetypes/pom.xml @@ -27,6 +27,8 @@ AWS Java SDK :: Archetypes archetype-lambda + archetype-app-quickstart + archetype-tools pom diff --git a/buildspecs/archetype-native-image-test.yml b/buildspecs/archetype-native-image-test.yml new file mode 100644 index 000000000000..7d89c8f78257 --- /dev/null +++ b/buildspecs/archetype-native-image-test.yml @@ -0,0 +1,63 @@ +version: 0.2 + +phases: + + build: + commands: + - mvn clean install -pl :archetype-app-quickstart -P quick --am -T1C + - mvn clean install -pl :bom,:bom-internal -P quick + - CURRENT_VERSION=$(cat pom.xml | grep "" | head -1 | cut -d\> -f 2 | cut -d\< -f 1) + - echo "Current version is $CURRENT_VERSION" + - cd .. && mkdir tmp + - cd tmp + - | + mvn archetype:generate \ + -DarchetypeGroupId=software.amazon.awssdk \ + -DarchetypeArtifactId=archetype-app-quickstart \ + -DarchetypeVersion=$CURRENT_VERSION \ + -DgroupId=com.test \ + -DnativeImage=true \ + -DartifactId=apache-project \ + -DhttpClient=apache-client \ + -Dservice=s3 \ + -DinteractiveMode=false + - | + - cd apache-project + - mvn clean package -P native-image + - target/apache-project + - cd .. + - + - + - | + mvn archetype:generate \ + -DarchetypeGroupId=software.amazon.awssdk \ + -DarchetypeArtifactId=archetype-app-quickstart \ + -DarchetypeVersion=$CURRENT_VERSION \ + -DgroupId=com.test \ + -DnativeImage=true \ + -DhttpClient=url-connection-client \ + -DartifactId=url-connection-project \ + -Dservice=s3 \ + -DinteractiveMode=false + - | + - cd url-connection-project + - mvn clean package -P native-image + - target/url-connection-project + - cd .. + - + - + - | + mvn archetype:generate \ + -DarchetypeGroupId=software.amazon.awssdk \ + -DarchetypeArtifactId=archetype-app-quickstart \ + -DarchetypeVersion=$CURRENT_VERSION \ + -DgroupId=com.test \ + -DhttpClient=netty-nio-client \ + -DnativeImage=true \ + -DartifactId=netty-project \ + -Dservice=dynamodb \ + -DinteractiveMode=false + - | + - cd netty-project + - mvn clean package -P native-image + - target/netty-project \ No newline at end of file diff --git a/buildspecs/native-image-integ-test.yml b/buildspecs/native-image-integ-test.yml new file mode 100644 index 000000000000..5b061466978b --- /dev/null +++ b/buildspecs/native-image-integ-test.yml @@ -0,0 +1,11 @@ +version: 0.2 + +phases: + + build: + commands: + - mvn clean install -pl :sdk-native-image-test -P quick --am -T1C + - mvn clean install -pl :bom-internal,:bom + - cd test/sdk-native-image-test + - mvn clean package -P native-image + - target/sdk-native-image-test \ No newline at end of file diff --git a/buildspecs/release-to-maven.yml b/buildspecs/release-to-maven.yml index 1b0c144354ae..9d05fafb1759 100644 --- a/buildspecs/release-to-maven.yml +++ b/buildspecs/release-to-maven.yml @@ -20,7 +20,7 @@ phases: if ! curl -f --head $SONATYPE_URL; then mkdir -p $CREDENTIALS aws s3 cp s3://aws-java-sdk-release-credentials/ $CREDENTIALS/ --recursive - mvn clean deploy -B -s $SETTINGS_XML -Dgpg.homedir=$GPG_HOME -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 -DautoReleaseAfterClose=true -DstagingProgressTimeoutMinutes=30 + mvn clean deploy -B -s $SETTINGS_XML -Dgpg.homedir=$GPG_HOME -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,!:archetype-tools -DautoReleaseAfterClose=true -DstagingProgressTimeoutMinutes=30 else echo "This version was already released." fi diff --git a/codegen/src/test/java/software/amazon/awssdk/codegen/naming/DefaultNamingStrategyTest.java b/codegen/src/test/java/software/amazon/awssdk/codegen/naming/DefaultNamingStrategyTest.java index d3da6d10a28e..f8f7d8e7f465 100644 --- a/codegen/src/test/java/software/amazon/awssdk/codegen/naming/DefaultNamingStrategyTest.java +++ b/codegen/src/test/java/software/amazon/awssdk/codegen/naming/DefaultNamingStrategyTest.java @@ -223,7 +223,7 @@ public void sharedModel_notProvidingPackageName_shouldUseServiceName() { @Test - public void sharedModel_providingPackageName_shouldUseProvidedPacakgeName() { + public void sharedModel_providingPackageName_shouldUseProvidedpackageName() { CustomizationConfig config = CustomizationConfig.create(); ShareModelConfig shareModelConfig = new ShareModelConfig(); shareModelConfig.setShareModelWith("foo"); diff --git a/core/sdk-core/src/main/resources/META-INF/native-image/software.amazon.awssdk/sdk-core/native-image.properties b/core/sdk-core/src/main/resources/META-INF/native-image/software.amazon.awssdk/sdk-core/native-image.properties new file mode 100644 index 000000000000..a00507b5e945 --- /dev/null +++ b/core/sdk-core/src/main/resources/META-INF/native-image/software.amazon.awssdk/sdk-core/native-image.properties @@ -0,0 +1,15 @@ +# +# 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. +# +Args=--enable-url-protocols=https --report-unsupported-elements-at-runtime \ No newline at end of file diff --git a/core/sdk-core/src/main/resources/META-INF/native-image/software.amazon.awssdk/sdk-core/reflect-config.json b/core/sdk-core/src/main/resources/META-INF/native-image/software.amazon.awssdk/sdk-core/reflect-config.json new file mode 100644 index 000000000000..678962dbb5c0 --- /dev/null +++ b/core/sdk-core/src/main/resources/META-INF/native-image/software.amazon.awssdk/sdk-core/reflect-config.json @@ -0,0 +1,11 @@ +[ + { + "name": "software.amazon.awssdk.core.internal.interceptor.HttpChecksumRequiredInterceptor", + "methods": [ + { + "name": "", + "parameterTypes": [] + } + ] + } +] \ No newline at end of file diff --git a/core/sdk-core/src/main/resources/META-INF/native-image/software.amazon.awssdk/sdk-core/resource-config.json b/core/sdk-core/src/main/resources/META-INF/native-image/software.amazon.awssdk/sdk-core/resource-config.json new file mode 100644 index 000000000000..9e4af3ba975e --- /dev/null +++ b/core/sdk-core/src/main/resources/META-INF/native-image/software.amazon.awssdk/sdk-core/resource-config.json @@ -0,0 +1,12 @@ +{ + "resources": { + "includes": [ + { + "pattern": "software/amazon/awssdk/services/\\w+/execution.interceptors" + }, + { + "pattern": "software/amazon/awssdk/.*" + } + ] + } +} \ No newline at end of file diff --git a/http-clients/apache-client/src/main/resources/META-INF/native-image/software.amazon.awssdk/apache-client/proxy-config.json b/http-clients/apache-client/src/main/resources/META-INF/native-image/software.amazon.awssdk/apache-client/proxy-config.json new file mode 100644 index 000000000000..8231ddce396c --- /dev/null +++ b/http-clients/apache-client/src/main/resources/META-INF/native-image/software.amazon.awssdk/apache-client/proxy-config.json @@ -0,0 +1,15 @@ +[ + [ + "org.apache.http.conn.HttpClientConnectionManager", + "org.apache.http.pool.ConnPoolControl", + "software.amazon.awssdk.http.apache.internal.conn.Wrapped" + ], + [ + "org.apache.http.conn.HttpClientConnectionManager", + "software.amazon.awssdk.http.apache.internal.conn.Wrapped" + ], + [ + "org.apache.http.conn.ConnectionRequest", + "software.amazon.awssdk.http.apache.internal.conn.Wrapped" + ] +] \ No newline at end of file diff --git a/http-clients/apache-client/src/main/resources/META-INF/native-image/software.amazon.awssdk/apache-client/reflect-config.json b/http-clients/apache-client/src/main/resources/META-INF/native-image/software.amazon.awssdk/apache-client/reflect-config.json new file mode 100644 index 000000000000..32161aa16f75 --- /dev/null +++ b/http-clients/apache-client/src/main/resources/META-INF/native-image/software.amazon.awssdk/apache-client/reflect-config.json @@ -0,0 +1,28 @@ +[ + { + "name": "software.amazon.awssdk.http.apache.ApacheSdkHttpService", + "methods": [ + { + "name": "", + "parameterTypes": [] + } + ] + }, + { + "name": "org.apache.http.client.config.RequestConfig$Builder", + "methods": [ + { + "name": "setNormalizeUri" + } + ] + }, + { + "name": "org.apache.commons.logging.LogFactory", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + } +] \ No newline at end of file diff --git a/http-clients/apache-client/src/main/resources/META-INF/native-image/software.amazon.awssdk/apache-client/resource-config.json b/http-clients/apache-client/src/main/resources/META-INF/native-image/software.amazon.awssdk/apache-client/resource-config.json new file mode 100644 index 000000000000..3a0b7729fff7 --- /dev/null +++ b/http-clients/apache-client/src/main/resources/META-INF/native-image/software.amazon.awssdk/apache-client/resource-config.json @@ -0,0 +1,7 @@ +{ + "resources": [ + { + "pattern": "\\Qsoftware.amazon.awssdk.http.SdkHttpService\\E" + } + ] +} \ No newline at end of file diff --git a/http-clients/netty-nio-client/src/main/resources/META-INF/native-image/software.amazon.awssdk/netty-nio-client/native-image.properties b/http-clients/netty-nio-client/src/main/resources/META-INF/native-image/software.amazon.awssdk/netty-nio-client/native-image.properties new file mode 100644 index 000000000000..2a38a91dea99 --- /dev/null +++ b/http-clients/netty-nio-client/src/main/resources/META-INF/native-image/software.amazon.awssdk/netty-nio-client/native-image.properties @@ -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. +# +Args=--allow-incomplete-classpath \ + --initialize-at-run-time=io.netty.util.internal.logging.Log4JLogger,org.apache.log4j.Logger,\ + io.netty.handler.ssl.ReferenceCountedOpenSslClientContext,\ + io.netty.handler.ssl.ReferenceCountedOpenSslServerContext,\ + io.netty.handler.ssl.ReferenceCountedOpenSslContext,\ + io.netty.handler.ssl.JdkNpnApplicationProtocolNegotiator,\ + io.netty.handler.ssl.ConscryptAlpnSslEngine,\ + io.netty.handler.ssl.JettyAlpnSslEngine$ClientEngine,\ + io.netty.handler.ssl.JettyAlpnSslEngine$ServerEngine,\ + io.netty.handler.ssl.JettyNpnSslEngine,\ + io.netty.handler.ssl.ReferenceCountedOpenSslEngine diff --git a/http-clients/netty-nio-client/src/main/resources/META-INF/native-image/software.amazon.awssdk/netty-nio-client/reflect-config.json b/http-clients/netty-nio-client/src/main/resources/META-INF/native-image/software.amazon.awssdk/netty-nio-client/reflect-config.json new file mode 100644 index 000000000000..061af8ded049 --- /dev/null +++ b/http-clients/netty-nio-client/src/main/resources/META-INF/native-image/software.amazon.awssdk/netty-nio-client/reflect-config.json @@ -0,0 +1,11 @@ +[ + { + "name": "software.amazon.awssdk.http.nio.netty.NettySdkAsyncHttpService", + "methods": [ + { + "name": "", + "parameterTypes": [] + } + ] + } +] \ No newline at end of file diff --git a/http-clients/netty-nio-client/src/main/resources/META-INF/native-image/software.amazon.awssdk/netty-nio-client/resource-config.json b/http-clients/netty-nio-client/src/main/resources/META-INF/native-image/software.amazon.awssdk/netty-nio-client/resource-config.json new file mode 100644 index 000000000000..8ebcdaad4da6 --- /dev/null +++ b/http-clients/netty-nio-client/src/main/resources/META-INF/native-image/software.amazon.awssdk/netty-nio-client/resource-config.json @@ -0,0 +1,7 @@ +{ + "resources": [ + { + "pattern": "\\Qsoftware.amazon.awssdk.http.async\\E" + } + ] +} \ No newline at end of file diff --git a/http-clients/url-connection-client/src/main/resources/META-INF/native-image/software.amazon.awssdk/url-connection-client/reflect-config.json b/http-clients/url-connection-client/src/main/resources/META-INF/native-image/software.amazon.awssdk/url-connection-client/reflect-config.json new file mode 100644 index 000000000000..59d734d7abef --- /dev/null +++ b/http-clients/url-connection-client/src/main/resources/META-INF/native-image/software.amazon.awssdk/url-connection-client/reflect-config.json @@ -0,0 +1,11 @@ +[ + { + "name": "software.amazon.awssdk.http.urlconnection.UrlConnectionSdkHttpService", + "methods": [ + { + "name": "", + "parameterTypes": [] + } + ] + } +] \ No newline at end of file diff --git a/http-clients/url-connection-client/src/main/resources/META-INF/native-image/software.amazon.awssdk/url-connection-client/resource-config.json b/http-clients/url-connection-client/src/main/resources/META-INF/native-image/software.amazon.awssdk/url-connection-client/resource-config.json new file mode 100644 index 000000000000..3a0b7729fff7 --- /dev/null +++ b/http-clients/url-connection-client/src/main/resources/META-INF/native-image/software.amazon.awssdk/url-connection-client/resource-config.json @@ -0,0 +1,7 @@ +{ + "resources": [ + { + "pattern": "\\Qsoftware.amazon.awssdk.http.SdkHttpService\\E" + } + ] +} \ No newline at end of file diff --git a/pom.xml b/pom.xml index fe34f7377d72..0a40e3b7451a 100644 --- a/pom.xml +++ b/pom.xml @@ -78,6 +78,7 @@ test/module-path-tests test/tests-coverage-reporting test/stability-tests + test/sdk-native-image-test https://github.com/aws/aws-sdk-java-v2.git @@ -527,6 +528,8 @@ tests-coverage-reporting aws-sdk-java archetype-lambda + archetype-app-quickstart + archetype-tools sdk-benchmarks bundle diff --git a/services-custom/dynamodb-enhanced/src/main/resources/META-INF/native-image/software.amazon.awssdk.dynamodb-enhanced/reflect-config.json b/services-custom/dynamodb-enhanced/src/main/resources/META-INF/native-image/software.amazon.awssdk.dynamodb-enhanced/reflect-config.json new file mode 100644 index 000000000000..e344d193ca4c --- /dev/null +++ b/services-custom/dynamodb-enhanced/src/main/resources/META-INF/native-image/software.amazon.awssdk.dynamodb-enhanced/reflect-config.json @@ -0,0 +1,11 @@ +[ + { + "name": "software.amazon.awssdk.enhanced.dynamodb.internal.ApplyUserAgentInterceptor", + "methods": [ + { + "name": "", + "parameterTypes": [] + } + ] + } +] \ No newline at end of file diff --git a/services/apigateway/src/main/resources/META-INF/native-image/software.amazon.awssdk/apigateway/reflect-config.json b/services/apigateway/src/main/resources/META-INF/native-image/software.amazon.awssdk/apigateway/reflect-config.json new file mode 100644 index 000000000000..69471e46d21f --- /dev/null +++ b/services/apigateway/src/main/resources/META-INF/native-image/software.amazon.awssdk/apigateway/reflect-config.json @@ -0,0 +1,11 @@ +[ + { + "name": "software.amazon.awssdk.services.apigateway.internal.AcceptJsonInterceptor", + "methods": [ + { + "name": "", + "parameterTypes": [] + } + ] + } +] \ No newline at end of file diff --git a/services/cloudsearchdomain/src/main/resources/META-INF/native-image/software.amazon.awssdk/cloudsearchdomain/reflect-config.json b/services/cloudsearchdomain/src/main/resources/META-INF/native-image/software.amazon.awssdk/cloudsearchdomain/reflect-config.json new file mode 100644 index 000000000000..776c443fee56 --- /dev/null +++ b/services/cloudsearchdomain/src/main/resources/META-INF/native-image/software.amazon.awssdk/cloudsearchdomain/reflect-config.json @@ -0,0 +1,11 @@ +[ + { + "name": "software.amazon.awssdk.services.cloudsearchdomain.internal.SwitchToPostInterceptor", + "methods": [ + { + "name": "", + "parameterTypes": [] + } + ] + } +] \ No newline at end of file diff --git a/services/docdb/src/main/resources/META-INF/native-image/software.amazon.awssdk/docdb/reflect-config.json b/services/docdb/src/main/resources/META-INF/native-image/software.amazon.awssdk/docdb/reflect-config.json new file mode 100644 index 000000000000..0c50c82139e5 --- /dev/null +++ b/services/docdb/src/main/resources/META-INF/native-image/software.amazon.awssdk/docdb/reflect-config.json @@ -0,0 +1,20 @@ +[ + { + "name": "software.amazon.awssdk.services.docdb.internal.CopyDbClusterSnapshotPresignInterceptor", + "methods": [ + { + "name": "", + "parameterTypes": [] + } + ] + }, + { + "name": "software.amazon.awssdk.services.docdb.internal.CreateDbClusterPresignInterceptor", + "methods": [ + { + "name": "", + "parameterTypes": [] + } + ] + } +] \ No newline at end of file diff --git a/services/ec2/src/main/resources/META-INF/native-image/software.amazon.awssdk/ec2/reflect-config.json b/services/ec2/src/main/resources/META-INF/native-image/software.amazon.awssdk/ec2/reflect-config.json new file mode 100644 index 000000000000..890250046efd --- /dev/null +++ b/services/ec2/src/main/resources/META-INF/native-image/software.amazon.awssdk/ec2/reflect-config.json @@ -0,0 +1,20 @@ +[ + { + "name": "software.amazon.awssdk.services.ec2.transform.internal.GeneratePreSignUrlInterceptor", + "methods": [ + { + "name": "", + "parameterTypes": [] + } + ] + }, + { + "name": "software.amazon.awssdk.services.ec2.transform.internal.TimestampFormatInterceptor", + "methods": [ + { + "name": "", + "parameterTypes": [] + } + ] + } +] \ No newline at end of file diff --git a/services/glacier/src/main/resources/META-INF/native-image/software.amazon.awssdk/glacier/reflect-config.json b/services/glacier/src/main/resources/META-INF/native-image/software.amazon.awssdk/glacier/reflect-config.json new file mode 100644 index 000000000000..ddddb1e443b0 --- /dev/null +++ b/services/glacier/src/main/resources/META-INF/native-image/software.amazon.awssdk/glacier/reflect-config.json @@ -0,0 +1,20 @@ +[ + { + "name": "software.amazon.awssdk.services.glacier.internal.AcceptJsonInterceptor", + "methods": [ + { + "name": "", + "parameterTypes": [] + } + ] + }, + { + "name": "software.amazon.awssdk.services.glacier.internal.GlacierExecutionInterceptor", + "methods": [ + { + "name": "", + "parameterTypes": [] + } + ] + } +] \ No newline at end of file diff --git a/services/iam/src/main/resources/META-INF/native-image/software.amazon.awssdk/iam/reflect-config.json b/services/iam/src/main/resources/META-INF/native-image/software.amazon.awssdk/iam/reflect-config.json new file mode 100644 index 000000000000..a8087ccecb54 --- /dev/null +++ b/services/iam/src/main/resources/META-INF/native-image/software.amazon.awssdk/iam/reflect-config.json @@ -0,0 +1,11 @@ +[ + { + "name": "software.amazon.awssdk.awscore.interceptor.GlobalServiceExecutionInterceptor", + "methods": [ + { + "name": "", + "parameterTypes": [] + } + ] + } +] \ No newline at end of file diff --git a/services/machinelearning/src/main/resources/META-INF/native-image/software.amazon.awssdk/machinelearning/reflect-config.json b/services/machinelearning/src/main/resources/META-INF/native-image/software.amazon.awssdk/machinelearning/reflect-config.json new file mode 100644 index 000000000000..31b97738f6d0 --- /dev/null +++ b/services/machinelearning/src/main/resources/META-INF/native-image/software.amazon.awssdk/machinelearning/reflect-config.json @@ -0,0 +1,20 @@ +[ + { + "name": "software.amazon.awssdk.services.machinelearning.internal.PredictEndpointInterceptor", + "methods": [ + { + "name": "", + "parameterTypes": [] + } + ] + }, + { + "name": "software.amazon.awssdk.services.machinelearning.internal.RandomIdInterceptor", + "methods": [ + { + "name": "", + "parameterTypes": [] + } + ] + } +] \ No newline at end of file diff --git a/services/neptune/src/main/resources/META-INF/native-image/software.amazon.awssdk/neptune/reflect-config.json b/services/neptune/src/main/resources/META-INF/native-image/software.amazon.awssdk/neptune/reflect-config.json new file mode 100644 index 000000000000..b8acee3f03a1 --- /dev/null +++ b/services/neptune/src/main/resources/META-INF/native-image/software.amazon.awssdk/neptune/reflect-config.json @@ -0,0 +1,20 @@ +[ + { + "name": "software.amazon.awssdk.services.neptune.internal.CopyDbClusterSnapshotPresignInterceptor", + "methods": [ + { + "name": "", + "parameterTypes": [] + } + ] + }, + { + "name": "software.amazon.awssdk.services.neptune.internal.CreateDbClusterPresignInterceptor", + "methods": [ + { + "name": "", + "parameterTypes": [] + } + ] + } +] \ No newline at end of file diff --git a/services/rds/src/main/resources/META-INF/native-image/software.amazon.awssdk/rds/reflect-config.json b/services/rds/src/main/resources/META-INF/native-image/software.amazon.awssdk/rds/reflect-config.json new file mode 100644 index 000000000000..e684d5f14270 --- /dev/null +++ b/services/rds/src/main/resources/META-INF/native-image/software.amazon.awssdk/rds/reflect-config.json @@ -0,0 +1,47 @@ +[ + { + "name": "software.amazon.awssdk.services.rds.internal.CopyDbClusterSnapshotPresignInterceptor", + "methods": [ + { + "name": "", + "parameterTypes": [] + } + ] + }, + { + "name": "software.amazon.awssdk.services.rds.internal.CopyDbSnapshotPresignInterceptor", + "methods": [ + { + "name": "", + "parameterTypes": [] + } + ] + }, + { + "name": "software.amazon.awssdk.services.rds.internal.CreateDbClusterPresignInterceptor", + "methods": [ + { + "name": "", + "parameterTypes": [] + } + ] + }, + { + "name": "software.amazon.awssdk.services.rds.internal.CreateDbInstanceReadReplicaPresignInterceptor", + "methods": [ + { + "name": "", + "parameterTypes": [] + } + ] + }, + { + "name": "software.amazon.awssdk.services.rds.internal.StartDbInstanceAutomatedBackupsReplicationPresignInterceptor", + "methods": [ + { + "name": "", + "parameterTypes": [] + } + ] + } +] \ No newline at end of file diff --git a/services/route53/src/main/resources/META-INF/software.amazon.awssdk.route53/reflect-config.json b/services/route53/src/main/resources/META-INF/software.amazon.awssdk.route53/reflect-config.json new file mode 100644 index 000000000000..85d779d7aa8a --- /dev/null +++ b/services/route53/src/main/resources/META-INF/software.amazon.awssdk.route53/reflect-config.json @@ -0,0 +1,11 @@ +[ + { + "name": "software.amazon.awssdk.services.route53.internal.Route53IdInterceptor", + "methods": [ + { + "name": "", + "parameterTypes": [] + } + ] + } +] \ No newline at end of file diff --git a/services/s3/src/main/resources/META-INF/native-image/software.amazon.awssdk/s3/reflect-config.json b/services/s3/src/main/resources/META-INF/native-image/software.amazon.awssdk/s3/reflect-config.json new file mode 100644 index 000000000000..27a7bbe640b9 --- /dev/null +++ b/services/s3/src/main/resources/META-INF/native-image/software.amazon.awssdk/s3/reflect-config.json @@ -0,0 +1,119 @@ +[ + { + "name": "software.amazon.awssdk.services.s3.internal.handlers.AsyncChecksumValidationInterceptor", + "methods": [ + { + "name": "", + "parameterTypes": [] + } + ] + }, + { + "name": "software.amazon.awssdk.services.s3.internal.handlers.CreateBucketInterceptor", + "methods": [ + { + "name": "", + "parameterTypes": [] + } + ] + }, + { + "name": "software.amazon.awssdk.services.s3.internal.handlers.CreateMultipartUploadRequestInterceptor", + "methods": [ + { + "name": "", + "parameterTypes": [] + } + ] + }, + { + "name": "software.amazon.awssdk.services.s3.internal.handlers.DecodeUrlEncodedResponseInterceptor", + "methods": [ + { + "name": "", + "parameterTypes": [] + } + ] + }, + { + "name": "software.amazon.awssdk.services.s3.internal.handlers.DisableDoubleUrlEncodingInterceptor", + "methods": [ + { + "name": "", + "parameterTypes": [] + } + ] + }, + { + "name": "software.amazon.awssdk.services.s3.internal.handlers.EnableChunkedEncodingInterceptor", + "methods": [ + { + "name": "", + "parameterTypes": [] + } + ] + }, + { + "name": "software.amazon.awssdk.services.s3.internal.handlers.EnableTrailingChecksumInterceptor", + "methods": [ + { + "name": "", + "parameterTypes": [] + } + ] + }, + { + "name": "software.amazon.awssdk.services.s3.internal.handlers.EndpointAddressInterceptor", + "methods": [ + { + "name": "", + "parameterTypes": [] + } + ] + }, + { + "name": "software.amazon.awssdk.services.s3.internal.handlers.ExceptionTranslationInterceptor", + "methods": [ + { + "name": "", + "parameterTypes": [] + } + ] + }, + { + "name": "software.amazon.awssdk.services.s3.internal.handlers.GetBucketPolicyInterceptor", + "methods": [ + { + "name": "", + "parameterTypes": [] + } + ] + }, + { + "name": "software.amazon.awssdk.services.s3.internal.handlers.GetObjectInterceptor", + "methods": [ + { + "name": "", + "parameterTypes": [] + } + ] + }, + { + "name": "software.amazon.awssdk.services.s3.internal.handlers.PutObjectInterceptor", + "methods": [ + { + "name": "", + "parameterTypes": [] + } + ] + }, + { + "name": "software.amazon.awssdk.services.s3.internal.handlers.SyncChecksumValidationInterceptor", + "methods": [ + { + "name": "", + "parameterTypes": [] + } + ] + } +] \ No newline at end of file diff --git a/services/s3control/src/main/resources/META-INF/native-image/software.amazon.awssdk/s3control/reflect-config.json b/services/s3control/src/main/resources/META-INF/native-image/software.amazon.awssdk/s3control/reflect-config.json new file mode 100644 index 000000000000..f38a478e9e7b --- /dev/null +++ b/services/s3control/src/main/resources/META-INF/native-image/software.amazon.awssdk/s3control/reflect-config.json @@ -0,0 +1,29 @@ +[ + { + "name": "software.amazon.awssdk.services.s3control.internal.interceptors.DisableDoubleUrlEncodingForSigningInterceptor", + "methods": [ + { + "name": "", + "parameterTypes": [] + } + ] + }, + { + "name": "software.amazon.awssdk.services.s3control.internal.interceptors.EndpointAddressInterceptor", + "methods": [ + { + "name": "", + "parameterTypes": [] + } + ] + }, + { + "name": "software.amazon.awssdk.services.s3control.internal.interceptors.PayloadSigningInterceptor", + "methods": [ + { + "name": "", + "parameterTypes": [] + } + ] + } +] \ No newline at end of file diff --git a/services/sqs/src/main/resources/META-INF/native-image/software.amazon.awssdk/sqs/reflect-config.json b/services/sqs/src/main/resources/META-INF/native-image/software.amazon.awssdk/sqs/reflect-config.json new file mode 100644 index 000000000000..ae738d1c4a71 --- /dev/null +++ b/services/sqs/src/main/resources/META-INF/native-image/software.amazon.awssdk/sqs/reflect-config.json @@ -0,0 +1,11 @@ +[ + { + "name": "software.amazon.awssdk.services.sqs.internal.MessageMD5ChecksumInterceptor", + "methods": [ + { + "name": "", + "parameterTypes": [] + } + ] + } +] \ No newline at end of file diff --git a/test/sdk-native-image-test/README.md b/test/sdk-native-image-test/README.md new file mode 100644 index 000000000000..52c39f29c6b0 --- /dev/null +++ b/test/sdk-native-image-test/README.md @@ -0,0 +1,22 @@ +# AWS SDK Native Image Test + +## Description +This module contains a sample application using AWS SDK for Java 2.x, and it +is used to test GraalVM Native Image compilation. + +## How to run +``` +mvn clean install -pl :sdk-native-image-test -P quick --am + +mvn clean install -pl :bom-internal,:bom + +cd test/sdk-native-image-test + +# build the image +mvn clean package -P native-image + +# execute the image +target/sdk-native-image-test +``` + + diff --git a/test/sdk-native-image-test/pom.xml b/test/sdk-native-image-test/pom.xml new file mode 100644 index 000000000000..83558fabbbb5 --- /dev/null +++ b/test/sdk-native-image-test/pom.xml @@ -0,0 +1,176 @@ + + + + + + aws-sdk-java-pom + software.amazon.awssdk + 2.16.1-SNAPSHOT + ../../pom.xml + + 4.0.0 + + sdk-native-image-test + AWS Java SDK :: Test :: Native Image Test + Tests GraalVM native images using AWS SDK for 2.x. + + + 3.6.1 + 1.6.0 + 1.7.28 + 21.0.0 + + + + + software.amazon.awssdk + s3 + ${awsjavasdk.version} + + + commons-logging + commons-logging + + + + + + software.amazon.awssdk + dynamodb-enhanced + ${awsjavasdk.version} + + + + software.amazon.awssdk + url-connection-client + ${awsjavasdk.version} + + + + software.amazon.awssdk + apache-client + ${awsjavasdk.version} + + + + + org.slf4j + slf4j-api + ${slf4j.version} + + + + org.slf4j + slf4j-simple + ${slf4j.version} + + + + + org.slf4j + jcl-over-slf4j + ${slf4j.version} + + + + org.graalvm.sdk + graal-sdk + ${graalvm.version} + provided + + + software.amazon.awssdk + service-test-utils + ${awsjavasdk.version} + + + software.amazon.awssdk + test-utils + ${awsjavasdk.version} + compile + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + ${maven.compiler.plugin.version} + + + com.github.spotbugs + spotbugs-maven-plugin + + + true + + + + org.apache.maven.plugins + maven-dependency-plugin + + + + analyze-only + + + + + + true + + + + + + + + native-image + + + + org.graalvm.nativeimage + native-image-maven-plugin + ${graalvm.version} + + + + native-image + + package + + + + sdk-native-image-test + software.amazon.awssdk.nativeimagetest.App + + + --verbose + --no-fallback + --initialize-at-build-time=org.slf4j + + + + + + + + + \ No newline at end of file diff --git a/test/sdk-native-image-test/src/main/java/software/amazon/awssdk/nativeimagetest/App.java b/test/sdk-native-image-test/src/main/java/software/amazon/awssdk/nativeimagetest/App.java new file mode 100644 index 000000000000..3a006a866fe5 --- /dev/null +++ b/test/sdk-native-image-test/src/main/java/software/amazon/awssdk/nativeimagetest/App.java @@ -0,0 +1,39 @@ +/* + * 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.nativeimagetest; + +import java.util.ArrayList; +import java.util.List; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class App { + private static final Logger logger = LoggerFactory.getLogger(App.class); + + private App() { + } + + public static void main(String... args) { + logger.info("Application starts"); + + List tests = new ArrayList<>(); + tests.add(new S3TestRunner()); + tests.add(new DynamoDbEnhancedClientTestRunner()); + + tests.forEach(t -> t.runTests()); + logger.info("Application ends"); + } +} diff --git a/test/sdk-native-image-test/src/main/java/software/amazon/awssdk/nativeimagetest/DependencyFactory.java b/test/sdk-native-image-test/src/main/java/software/amazon/awssdk/nativeimagetest/DependencyFactory.java new file mode 100644 index 000000000000..9e330ad33bbd --- /dev/null +++ b/test/sdk-native-image-test/src/main/java/software/amazon/awssdk/nativeimagetest/DependencyFactory.java @@ -0,0 +1,77 @@ +/* + * 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.nativeimagetest; + +import software.amazon.awssdk.enhanced.dynamodb.DynamoDbEnhancedClient; +import software.amazon.awssdk.http.apache.ApacheHttpClient; +import software.amazon.awssdk.http.urlconnection.UrlConnectionHttpClient; +import software.amazon.awssdk.metrics.LoggingMetricPublisher; +import software.amazon.awssdk.regions.Region; +import software.amazon.awssdk.services.dynamodb.DynamoDbClient; +import software.amazon.awssdk.services.s3.S3AsyncClient; +import software.amazon.awssdk.services.s3.S3Client; +import software.amazon.awssdk.testutils.service.AwsTestBase; + +/** + * The module containing all dependencies required by the {@link App}. + */ +public class DependencyFactory extends AwsTestBase { + + private DependencyFactory() { + } + + public static S3Client s3UrlConnectionHttpClient() { + return S3Client.builder() + .credentialsProvider(CREDENTIALS_PROVIDER_CHAIN) + .httpClientBuilder(UrlConnectionHttpClient.builder()) + .overrideConfiguration(o -> o.addMetricPublisher(LoggingMetricPublisher.create())) + .region(Region.US_WEST_2) + .build(); + } + + public static S3Client s3ApacheHttpClient() { + return S3Client.builder() + .credentialsProvider(CREDENTIALS_PROVIDER_CHAIN) + .httpClientBuilder(ApacheHttpClient.builder()) + .overrideConfiguration(o -> o.addMetricPublisher(LoggingMetricPublisher.create())) + .region(Region.US_WEST_2) + .build(); + } + + public static S3AsyncClient s3NettyClient() { + return S3AsyncClient.builder() + .credentialsProvider(CREDENTIALS_PROVIDER_CHAIN) + .overrideConfiguration(o -> o.addMetricPublisher(LoggingMetricPublisher.create())) + .region(Region.US_WEST_2) + .build(); + } + + public static DynamoDbClient ddbClient() { + return DynamoDbClient.builder() + .credentialsProvider(CREDENTIALS_PROVIDER_CHAIN) + .httpClientBuilder(ApacheHttpClient.builder()) + .overrideConfiguration(o -> o.addMetricPublisher(LoggingMetricPublisher.create())) + .region(Region.US_WEST_2) + .build(); + } + + public static DynamoDbEnhancedClient enhancedClient(DynamoDbClient ddbClient) { + return DynamoDbEnhancedClient.builder() + .dynamoDbClient(ddbClient) + .build(); + + } +} diff --git a/test/sdk-native-image-test/src/main/java/software/amazon/awssdk/nativeimagetest/DynamoDbEnhancedClientTestRunner.java b/test/sdk-native-image-test/src/main/java/software/amazon/awssdk/nativeimagetest/DynamoDbEnhancedClientTestRunner.java new file mode 100644 index 000000000000..3db290020984 --- /dev/null +++ b/test/sdk-native-image-test/src/main/java/software/amazon/awssdk/nativeimagetest/DynamoDbEnhancedClientTestRunner.java @@ -0,0 +1,160 @@ +/* + * 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.nativeimagetest; + +import static software.amazon.awssdk.enhanced.dynamodb.mapper.StaticAttributeTags.primaryPartitionKey; +import static software.amazon.awssdk.enhanced.dynamodb.mapper.StaticAttributeTags.primarySortKey; +import static software.amazon.awssdk.enhanced.dynamodb.mapper.StaticAttributeTags.secondaryPartitionKey; +import static software.amazon.awssdk.enhanced.dynamodb.mapper.StaticAttributeTags.secondarySortKey; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import software.amazon.awssdk.enhanced.dynamodb.DynamoDbEnhancedClient; +import software.amazon.awssdk.enhanced.dynamodb.DynamoDbTable; +import software.amazon.awssdk.enhanced.dynamodb.TableSchema; +import software.amazon.awssdk.enhanced.dynamodb.mapper.StaticTableSchema; +import software.amazon.awssdk.enhanced.dynamodb.model.EnhancedGlobalSecondaryIndex; +import software.amazon.awssdk.services.dynamodb.DynamoDbClient; +import software.amazon.awssdk.services.dynamodb.model.ProjectionType; +import software.amazon.awssdk.services.dynamodb.model.ProvisionedThroughput; + +public class DynamoDbEnhancedClientTestRunner implements TestRunner { + private static final String TABLE_NAME = "native-image" + System.currentTimeMillis(); + private static final String ATTRIBUTE_NAME_WITH_SPECIAL_CHARACTERS = "a*t:t.r-i#bute3"; + private static final Logger logger = LoggerFactory.getLogger(DynamoDbEnhancedClientTestRunner.class); + + private static final TableSchema TABLE_SCHEMA = + StaticTableSchema.builder(Record.class) + .newItemSupplier(Record::new) + .addAttribute(String.class, a -> a.name("id") + .getter(Record::getId) + .setter(Record::setId) + .tags(primaryPartitionKey())) + .addAttribute(String.class, a -> a.name("sort") + .getter(Record::getSort) + .setter(Record::setSort) + .tags(primarySortKey())) + .addAttribute(String.class, a -> a.name("attribute") + .getter(Record::getAttribute) + .setter(Record::setAttribute)) + .addAttribute(String.class, a -> a.name("attribute2*") + .getter(Record::getAttribute2) + .setter(Record::setAttribute2) + .tags(secondaryPartitionKey("gsi_1"))) + .addAttribute(String.class, a -> a.name(ATTRIBUTE_NAME_WITH_SPECIAL_CHARACTERS) + .getter(Record::getAttribute3) + .setter(Record::setAttribute3) + .tags(secondarySortKey("gsi_1"))) + .build(); + + + private static final ProvisionedThroughput DEFAULT_PROVISIONED_THROUGHPUT = + ProvisionedThroughput.builder() + .readCapacityUnits(50L) + .writeCapacityUnits(50L) + .build(); + + private final DynamoDbClient dynamoDbClient; + private final DynamoDbEnhancedClient enhancedClient; + + public DynamoDbEnhancedClientTestRunner() { + dynamoDbClient = DependencyFactory.ddbClient(); + enhancedClient = DependencyFactory.enhancedClient(dynamoDbClient); + } + + @Override + public void runTests() { + logger.info("starting to run DynamoDbEnhancedClient tests"); + try { + DynamoDbTable mappedTable = enhancedClient.table(TABLE_NAME, TABLE_SCHEMA); + mappedTable.createTable(r -> r.provisionedThroughput(DEFAULT_PROVISIONED_THROUGHPUT) + .globalSecondaryIndices( + EnhancedGlobalSecondaryIndex.builder() + .indexName("gsi_1") + .projection(p -> p.projectionType(ProjectionType.ALL)) + .provisionedThroughput(DEFAULT_PROVISIONED_THROUGHPUT) + .build())); + + dynamoDbClient.waiter().waitUntilTableExists(b -> b.tableName(TABLE_NAME)); + + Record record = new Record() + .setId("id-value") + .setSort("sort-value") + .setAttribute("one") + .setAttribute2("two") + .setAttribute3("three"); + + mappedTable.putItem(r -> r.item(record)); + + mappedTable.getItem(r -> r.key(k -> k.partitionValue("id-value").sortValue("sort-value"))); + } finally { + dynamoDbClient.deleteTable(b -> b.tableName(TABLE_NAME)); + } + } + + private static final class Record { + private String id; + private String sort; + private String attribute; + private String attribute2; + private String attribute3; + + private String getId() { + return id; + } + + private Record setId(String id) { + this.id = id; + return this; + } + + private String getSort() { + return sort; + } + + private Record setSort(String sort) { + this.sort = sort; + return this; + } + + private String getAttribute() { + return attribute; + } + + private Record setAttribute(String attribute) { + this.attribute = attribute; + return this; + } + + private String getAttribute2() { + return attribute2; + } + + private Record setAttribute2(String attribute2) { + this.attribute2 = attribute2; + return this; + } + + private String getAttribute3() { + return attribute3; + } + + private Record setAttribute3(String attribute3) { + this.attribute3 = attribute3; + return this; + } + } +} diff --git a/test/sdk-native-image-test/src/main/java/software/amazon/awssdk/nativeimagetest/S3TestRunner.java b/test/sdk-native-image-test/src/main/java/software/amazon/awssdk/nativeimagetest/S3TestRunner.java new file mode 100644 index 000000000000..2d117986ffcc --- /dev/null +++ b/test/sdk-native-image-test/src/main/java/software/amazon/awssdk/nativeimagetest/S3TestRunner.java @@ -0,0 +1,73 @@ +/* + * 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.nativeimagetest; + +import java.io.InputStream; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import software.amazon.awssdk.core.async.AsyncResponseTransformer; +import software.amazon.awssdk.core.sync.RequestBody; +import software.amazon.awssdk.services.s3.S3AsyncClient; +import software.amazon.awssdk.services.s3.S3Client; +import software.amazon.awssdk.services.s3.model.CreateBucketResponse; +import software.amazon.awssdk.testutils.RandomInputStream; +import software.amazon.awssdk.testutils.service.S3BucketUtils; +import software.amazon.awssdk.utils.IoUtils; + +public class S3TestRunner implements TestRunner { + private static final String BUCKET_NAME = S3BucketUtils.temporaryBucketName("native-image"); + private static final Logger logger = LoggerFactory.getLogger(DynamoDbEnhancedClientTestRunner.class); + private static final String KEY = "key"; + private final S3Client s3ApacheHttpClient; + private final S3Client s3UrlConnectionHttpClient; + private final S3AsyncClient s3NettyClient; + + public S3TestRunner() { + s3ApacheHttpClient = DependencyFactory.s3ApacheHttpClient(); + s3UrlConnectionHttpClient = DependencyFactory.s3UrlConnectionHttpClient(); + s3NettyClient = DependencyFactory.s3NettyClient(); + } + + @Override + public void runTests() { + logger.info("starting to run S3 tests"); + CreateBucketResponse bucketResponse = null; + InputStream inputStream = null; + try { + bucketResponse = s3UrlConnectionHttpClient.createBucket(b -> b.bucket(BUCKET_NAME)); + + s3UrlConnectionHttpClient.waiter().waitUntilBucketExists(b -> b.bucket(BUCKET_NAME)); + + inputStream = new RandomInputStream(10_000); + + RequestBody requestBody = RequestBody.fromInputStream(inputStream, 10_000); + + s3ApacheHttpClient.putObject(b -> b.bucket(BUCKET_NAME).key(KEY), + requestBody); + + s3NettyClient.getObject(b -> b.bucket(BUCKET_NAME).key(KEY), + AsyncResponseTransformer.toBytes()).join(); + + } finally { + if (bucketResponse != null) { + s3NettyClient.deleteObject(b -> b.bucket(BUCKET_NAME).key(KEY)).join(); + + s3NettyClient.deleteBucket(b -> b.bucket(BUCKET_NAME)).join(); + } + IoUtils.closeQuietly(inputStream, null); + } + } +} diff --git a/test/sdk-native-image-test/src/main/java/software/amazon/awssdk/nativeimagetest/TestRunner.java b/test/sdk-native-image-test/src/main/java/software/amazon/awssdk/nativeimagetest/TestRunner.java new file mode 100644 index 000000000000..103d2177bf01 --- /dev/null +++ b/test/sdk-native-image-test/src/main/java/software/amazon/awssdk/nativeimagetest/TestRunner.java @@ -0,0 +1,21 @@ +/* + * 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.nativeimagetest; + +public interface TestRunner { + + void runTests(); +} diff --git a/test/sdk-native-image-test/src/main/resources/simplelogger.properties b/test/sdk-native-image-test/src/main/resources/simplelogger.properties new file mode 100644 index 000000000000..ce74760c3d9b --- /dev/null +++ b/test/sdk-native-image-test/src/main/resources/simplelogger.properties @@ -0,0 +1,35 @@ +# SLF4J's SimpleLogger configuration file +# Simple implementation of Logger that sends all enabled log messages, for all defined loggers, to System.err. + +# Default logging detail level for all instances of SimpleLogger. +# Must be one of ("trace", "debug", "info", "warn", or "error"). +# If not specified, defaults to "info". +org.slf4j.simpleLogger.defaultLogLevel=info + +# Logging detail level for a SimpleLogger instance named "xxxxx". +# Must be one of ("trace", "debug", "info", "warn", or "error"). +# If not specified, the default logging detail level is used. +org.slf4j.simpleLogger.log.software.amazon.awssdk.request=debug +org.slf4j.simpleLogger.log.io.netty.channel.ChannelHandlerMask=error + +# Set to true if you want the current date and time to be included in output messages. +# Default is false, and will output the number of milliseconds elapsed since startup. +org.slf4j.simpleLogger.showDateTime=true + +# The date and time format to be used in the output messages. +# The pattern describing the date and time format is the same that is used in java.text.SimpleDateFormat. +# If the format is not specified or is invalid, the default format is used. +# The default format is yyyy-MM-dd HH:mm:ss:SSS Z. +org.slf4j.simpleLogger.dateTimeFormat=yyyy-MM-dd HH:mm:ss:SSS Z + +# Set to true if you want to output the current thread name. +# Defaults to true. +org.slf4j.simpleLogger.showThreadName=true + +# Set to true if you want the Logger instance name to be included in output messages. +# Defaults to true. +#org.slf4j.simpleLogger.showLogName=true + +# Set to true if you want the last component of the name to be included in output messages. +# Defaults to false. +org.slf4j.simpleLogger.showShortLogName=false \ No newline at end of file