Why do we use Maven in Java

Using the SDK with Apache Maven

You can use Apache Maven to configure and build AWS SDK for Java projects, as well as build the SDK yourself.

To follow the instructions in this topic, you should have Maven installed. If Maven is not already installed, visit http://maven.apache.org/ to download and install it.

Create a new Maven package

You can create a simple Maven package by opening a terminal window (a command line) and running:

Replace org.example.basicapp with your application's full package namespace and myapp with the project name (will be used for the directory name of your project).

By default, it creates a project template with the quickstart archetype - a good starting point for many projects. Other archetypes are available; a list of packed archetypes can be found on the Maven archetypes page. You can choose a specific archetype to use by appending the argument to the command. Example:

Configure the SDK as a Maven dependency

The only way to use the AWS SDK for Java in your project is to declare it as a dependency in your project's file. From version 1.9.0 you can import individual components or the entire SDK.

Specify individual SDK modules

To select individual SDK modules, use the AWS SDK for Java Bill of Materials (BOM) for Maven. This ensures that the specified modules use the same SDK version and are compatible with each other.

To use the BOM, add a section to your application's file. Add as a dependency and specify the SDK version that you want to use:

You can view the latest version of the AWS SDK for Java BOM available on Maven Central here: https://mvnrepository.com/artifact/com.amazonaws/aws-java-sdk-bom. On this page you can also see which modules (dependencies) managed by the BOM you can insert in the section of the file of your project.

You can now select individual modules from the SDK for use in your application. Since you have already declared the SDK version in the BOM, you no longer need to specify the version number for each component.

You can also use the AWS Code Catalog read which dependencies to use for a particular AWS service. For more information, see the POM file for a specific service example. For example, if you're interested in the dependencies for the AWS S3 service, check out the full sample on GitHub. (Take a look at the POM at / java / example_code / s3).

Import all SDK modules

If you do that entire SDK as a dependency, do not use the BOM method. Instead, just declare it like this in:

Create your project

Once your project is set up, you can use the Maven command to build it:

This creates the file in the directory.

Building the SDK with Maven

You can use Apache Maven to build the SDK from the sources. Download the SDK code from GitHub, extract it locally, then run the following Maven command: