The AWS SDK for Java team is hiring software development engineers
Using the SDK with Gradle
To manage SDK dependencies for your Gradlebuild.gradle
file.
In the following examples, replace 1.12.1 in the build file with a valid version of the AWS SDK for Java. Find the latest version in the AWS SDK for Java 1.x Reference.
Project setup for Gradle 4.6 or higher
Since Gradle 4.6
-
If you’re using Gradle 5.0 or later, skip to step 2. Otherwise, enable the IMPROVED_POM_SUPPORT feature in the
settings.gradle
file.enableFeaturePreview('IMPROVED_POM_SUPPORT')
-
Add the BOM to the dependencies section of the
build.gradle
file.... dependencies { implementation platform('com.amazonaws:aws-java-sdk-bom:1.11.1000') // Declare individual SDK dependencies without version ... }
-
Specify the SDK modules to use in the dependencies section. For example, the following includes a dependency for Amazon Simple Storage Service (Amazon S3).
... dependencies { implementation 'com.amazonaws:aws-java-sdk-s3' ... }
Gradle automatically resolves the correct version of your SDK dependencies by using the information from the BOM.
The following is an example of a complete build.gradle
file that includes a dependency
for Amazon S3.
group 'aws.test' version '1.0-SNAPSHOT' apply plugin: 'java' sourceCompatibility = 1.8 repositories { mavenCentral() } dependencies { implementation platform('com.amazonaws:aws-java-sdk-bom:1.11.1000') implementation 'com.amazonaws:aws-java-sdk-s3' testCompile group: 'junit', name: 'junit', version: '4.11' }
In the previous example, replace the dependency for Amazon S3 with the dependencies of the AWS
services you will use in your project. The modules (dependencies) that are managed by the
AWS SDK for Java BOM are listed on Maven central repository
(https://mvnrepository.com/artifact/com.amazonaws/aws-java-sdk-bom/latest
Project setup for Gradle versions earlier than 4.6
Gradle versions earlier than 4.6 lack native BOM support. To manage AWS SDK for Java dependencies for
your project, use Spring’s
dependency management plugin
-
Add the dependency management plugin to your
build.gradle
file.buildscript { repositories { mavenCentral() } dependencies { classpath "io.spring.gradle:dependency-management-plugin:1.0.9.RELEASE" } } apply plugin: "io.spring.dependency-management"
-
Add the BOM to the dependencyManagement section of the file.
dependencyManagement { imports { mavenBom 'com.amazonaws:aws-java-sdk-bom:1.11.1000' } }
-
Specify the SDK modules that you’ll use in the dependencies section. For example, the following includes a dependency for Amazon S3.
dependencies { compile 'com.amazonaws:aws-java-sdk-s3' }
Gradle automatically resolves the correct version of your SDK dependencies by using the information from the BOM.
The following is an example of a complete build.gradle
file that includes a dependency
for Amazon S3.
group 'aws.test' version '1.0' apply plugin: 'java' sourceCompatibility = 1.8 repositories { mavenCentral() } buildscript { repositories { mavenCentral() } dependencies { classpath "io.spring.gradle:dependency-management-plugin:1.0.9.RELEASE" } } apply plugin: "io.spring.dependency-management" dependencyManagement { imports { mavenBom 'com.amazonaws:aws-java-sdk-bom:1.11.1000' } } dependencies { compile 'com.amazonaws:aws-java-sdk-s3' testCompile group: 'junit', name: 'junit', version: '4.11' }
In the previous example, replace the dependency for Amazon S3 with the dependencies of the AWS
service you will use in your project. The modules (dependencies) that are managed by the
AWS SDK for Java BOM are listed on Maven central repository
(https://mvnrepository.com/artifact/com.amazonaws/aws-java-sdk-bom/latest
For more information about specifying SDK dependencies by using the BOM, see Using the SDK with Apache Maven.