AWS Developer Tools Blog
Managing Dependencies in Gradle with AWS SDK for Java – Bill of Materials module (BOM)
In an earlier blog post, I discussed how a Maven bill of materials (BOM) module can be used to manage your Maven dependencies on the AWS SDK for Java.
In this blog post, I will provide an example of how you can use the Maven BOM in your Gradle projects to manage the dependencies on the SDK. I will use an open source Gradle dependency management plugin from Spring to import a BOM and then use its dependency management.
Here is the build.gradle
snippet to apply the dependency management plugin to the project:
buildscript { repositories { mavenCentral() } dependencies { classpath "io.spring.gradle:dependency-management-plugin:0.5.4.RELEASE" } } apply plugin: "io.spring.dependency-management"
Now, import the Maven BOM into the dependencyManagement
section and specify the SDK modules in the dependencies
section, as shown here:
dependencyManagement { imports { mavenBom 'com.amazonaws:aws-java-sdk-bom:1.10.47' } } dependencies { compile 'com.amazonaws:aws-java-sdk-s3' testCompile group: 'junit', name: 'junit', version: '4.11' }
Gradle resolves the aws-java-sdk-s3
module to the version specified in the BOM, as shown in the following dependency resolution diagram.
Have you been using the AWS SDK for Java in Gradle? If so, please leave us your feedback in the comments.