|
| 1 | +# Generate an AWS SDK |
| 2 | + |
| 3 | +This page describes how to generate and build an AWS SDK. Generating an SDK from source may be useful in testing fixes, |
| 4 | +learning how AWS SDKs work internally, or just experimentation. |
| 5 | + |
| 6 | +### NOTE |
| 7 | + |
| 8 | +This process is not necessary to use an AWS SDK, as one can simply depend on the artifacts available in |
| 9 | +[Maven Central](https://search.maven.org/search?q=aws.sdk.kotlin). See the [getting started guide](GettingStarted.md) for details. |
| 10 | + |
| 11 | +## Prerequisites |
| 12 | +* Git |
| 13 | +* Java JDK 1.8+ |
| 14 | + |
| 15 | +## Generate an SDK |
| 16 | + |
| 17 | +In this example we'll build the AWS DynamoDB SDK. |
| 18 | + |
| 19 | +### Clone this repo |
| 20 | +```sh |
| 21 | +git clone https://github.com/awslabs/aws-sdk-kotlin.git |
| 22 | +cd aws-sdk-kotlin |
| 23 | +``` |
| 24 | + |
| 25 | +### Generate the SDK source |
| 26 | + |
| 27 | +Generate the DynamoDB SDK: |
| 28 | +```sh |
| 29 | +./gradlew -Paws.services=+dynamodb :codegen:sdk:bootstrap |
| 30 | +``` |
| 31 | +Notice we specify the name of the service as `dynamodb`. The names for all AWS services can be found in |
| 32 | +[`codegen/sdk/aws-models`](../codegen/sdk/aws-models). |
| 33 | +. So for example the name used for AWS CloudFormation's model `cloudformation.2010-05-15.json` |
| 34 | +would be `cloudformation`. The date and json extension are removed. |
| 35 | + |
| 36 | +### Compile and test the generated SDK |
| 37 | +```sh |
| 38 | +./gradlew :services:dynamodb:build |
| 39 | +``` |
| 40 | +Once this completes a compiled SDK for the AWS DynamoDB service has been generated. The version will vary depending |
| 41 | +on whatever is the latest version in the repository. |
| 42 | + |
| 43 | +```sh |
| 44 | +ls services/dynamodb/build/libs |
| 45 | +dynamodb-<version>.jar |
| 46 | +``` |
| 47 | + |
| 48 | +To use this compiled SDK from another program locally, the local Maven repository can be used. The following command |
| 49 | +will publish artifacts from `aws-sdk-kotlin` to the local maven repository, including the DynamoDB service and supporting |
| 50 | +runtime libraries: |
| 51 | + |
| 52 | +```sh |
| 53 | +./gradlew publishToMavenLocal |
| 54 | +``` |
| 55 | + |
| 56 | +## Using a locally-built SDK |
| 57 | + |
| 58 | +In order to use an SDK published to the local maven repository, the `mavenLocal()` repository must be added to the program's |
| 59 | +build file: |
| 60 | + |
| 61 | +``` |
| 62 | +repositories { |
| 63 | + mavenLocal() |
| 64 | +} |
| 65 | +``` |
| 66 | + |
| 67 | +And then simply add the dependency: |
| 68 | + |
| 69 | +``` |
| 70 | +dependencies { |
| 71 | + implementation("aws.sdk.kotlin:dynamodb:<version>") |
| 72 | +} |
| 73 | +``` |
| 74 | + |
| 75 | +## Summary |
| 76 | + |
| 77 | +This page covers building an AWS SDK using the `aws-sdk-kotlin` SDK generator. If you experience problems please [file |
| 78 | +an issue](https://github.com/awslabs/aws-sdk-kotlin/issues). If you have questions or ideas about how we can improve our |
| 79 | +SDKs, please join [our discussions](https://github.com/awslabs/aws-sdk-kotlin/discussions). |
0 commit comments