AWS SDK for Java
Developer Guide

The AWS Documentation website is getting a new look!
Try it now and let us know what you think. Switch to the new look >>

You can return to the original look by selecting English in the language selector above.

Using the SDK with Gradle

Since Gradle 4.6 it is possible to use Gradle's improved POM support feature for importing bill of materials (BOM) files by simply declaring a dependency on a BOM.

To configure the SDK for Gradle 4.6 and upper

  1. Enable IMPROVED_POM_SUPPORT feature in settings.gradle file (not needed in Gradle 5 and upper)

    enableFeaturePreview('IMPROVED_POM_SUPPORT')
  2. Import BOM as a usual dependency in the dependencies section

    dependencies { implementation platform('com.amazonaws:aws-java-sdk-bom:1.11.228') }
  3. Specify the SDK modules that you'll be using in the dependencies section

    dependencies { implementation 'com.amazonaws:aws-java-sdk-s3' testCompile group: 'junit', name: 'junit', version: '4.11' }

Gradle will automatically resolve the correct version of your SDK dependencies using the information from the BOM.

Here's the complete build.gradle file:

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.228') implementation 'com.amazonaws:aws-java-sdk-s3' testCompile group: 'junit', name: 'junit', version: '4.11' }

Gradle versions prior to 4.6 lack of native BOM support, so Spring's dependency management plugin for Gradle can be used to import the SDK's Maven Bill of Materials (BOM) to manage SDK dependencies for your project.

To configure the SDK for Gradle prior 4.6

  1. Add the dependency management plugin to your build.gradle file

    buildscript { repositories { mavenCentral() } dependencies { classpath "io.spring.gradle:dependency-management-plugin:1.0.3.RELEASE" } } apply plugin: "io.spring.dependency-management"
  2. Add the BOM to the dependencyManagement section of the file

    dependencyManagement { imports { mavenBom 'com.amazonaws:aws-java-sdk-bom:1.11.228' } }
  3. Specify the SDK modules that you'll be using in the dependencies section

    dependencies { compile 'com.amazonaws:aws-java-sdk-s3' testCompile group: 'junit', name: 'junit', version: '4.11' }

Gradle will automatically resolve the correct version of your SDK dependencies using the information from the BOM.

Here's the complete build.gradle file:

group 'aws.test' version '1.0-SNAPSHOT' apply plugin: 'java' sourceCompatibility = 1.8 repositories { mavenCentral() } buildscript { repositories { mavenCentral() } dependencies { classpath "io.spring.gradle:dependency-management-plugin:1.0.3.RELEASE" } } apply plugin: "io.spring.dependency-management" dependencyManagement { imports { mavenBom 'com.amazonaws:aws-java-sdk-bom:1.11.228' } } dependencies { compile 'com.amazonaws:aws-java-sdk-s3' testCompile group: 'junit', name: 'junit', version: '4.11' }

Note

For more detail about specifying SDK dependencies using the BOM, see Using the SDK with Apache Maven.