Skip to content

Commit 878d8f2

Browse files
committed
updating Gradle setup instructions
1 parent 0a7b4cc commit 878d8f2

File tree

1 file changed

+55
-35
lines changed

1 file changed

+55
-35
lines changed
Lines changed: 55 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.. Copyright 2010-2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
1+
.. Copyright 2010-2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
22
33
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0
44
International License (the "License"). You may not use this file except in compliance with the
@@ -12,41 +12,52 @@
1212
Using the SDK with Gradle
1313
#########################
1414

15+
16+
Project setup for Gradle 4.6 or higher
17+
===============
18+
1519
`Since Gradle 4.6 <https://docs.gradle.org/4.6/release-notes.html#bom-import>`_ it is possible to
1620
use Gradle's improved POM support feature for importing bill of materials (BOM) files by simply declaring a dependency on a BOM.
1721

18-
.. topic:: To configure the SDK for Gradle 4.6 and upper
22+
To manage SDK dependencies for your Gradle_ project, import the |sdk-java|'s Maven Bill of Materials (BOM) into the :file:`build.gradle` file.
23+
24+
.. note:: Replace *1.11.X* in the build file examples below with a valid version of the |sdk-java|. Find the latest version in the
25+
`AWS SDK for Java 1.11.x Reference <https://docs.aws.amazon.com/AWSJavaSDK/latest/javadoc/index.html>`_
26+
1927

20-
#. Enable `IMPROVED_POM_SUPPORT` feature in :file:`settings.gradle` file (not needed in Gradle 5 and upper)
28+
.. topic:: To configure the |sdk-java| for Gradle 4.6 or higher:
29+
30+
#. If you are using Gradle 5.0 or higher, skip to Step 2. Otherwise, enable the `IMPROVED_POM_SUPPORT` feature in the :file:`settings.gradle` file
2131

2232
.. code-block:: groovy
2333
2434
enableFeaturePreview('IMPROVED_POM_SUPPORT')
2535
26-
#. Import BOM as a usual dependency in the *dependencies* section
36+
#. Add the BOM to the *dependencies* section of the :file:`build.gradle` file.
2737

2838
.. code-block:: groovy
2939
40+
...
3041
dependencies {
31-
implementation platform('com.amazonaws:aws-java-sdk-bom:1.11.228')
42+
implementation platform('com.amazonaws:aws-java-sdk-bom:1.11.X')
43+
44+
// Declare individual SDK dependencies without version
45+
...
3246
}
3347
34-
#. Specify the SDK modules that you'll be using in the *dependencies* section
48+
#. Specify the SDK modules you want to use in the *dependencies* section. For example, the following includes a dependency for |S3long|.
3549

3650
.. code-block:: groovy
3751
52+
...
3853
dependencies {
3954
implementation 'com.amazonaws:aws-java-sdk-s3'
40-
testCompile group: 'junit', name: 'junit', version: '4.11'
55+
...
4156
}
4257
43-
Gradle will automatically resolve the correct version of your SDK dependencies using the information
44-
from the BOM.
45-
46-
You can also refer to the *AWS Code Catalog* to learn what dependencies to use for a given AWS service. Refer to the POM file under a specific service example.
47-
For example, if you are interested in the dependencies for the AWS S3 service (as shown in the previous dependencies example), see the :sdk-examples-java-s3:`complete example <GetAcl.java>` on GitHub. (Look at the pom under /java/example_code/s3).
58+
Gradle automatically resolves the correct version of your SDK dependencies using the information from the BOM.
4859

49-
Here's the complete :file:`build.gradle` file:
60+
The following is an example of a complete :file:`build.gradle` file that includes a dependency for |S3|:
5061

5162
.. code-block:: groovy
5263
@@ -62,18 +73,27 @@ Here's the complete :file:`build.gradle` file:
6273
}
6374
6475
dependencies {
65-
implementation platform('com.amazonaws:aws-java-sdk-bom:1.11.228')
66-
implementation 'com.amazonaws:aws-java-sdk-s3'
67-
testCompile group: 'junit', name: 'junit', version: '4.11'
76+
implementation platform('com.amazonaws:aws-java-sdk-bom:1.11.X')
77+
implementation 'com.amazonaws:aws-java-sdk-s3'
78+
testCompile group: 'junit', name: 'junit', version: '4.11'
6879
}
6980
70-
Gradle versions prior to 4.6 lack of native BOM support, so Spring's `dependency management plugin
71-
<https://github.com/spring-gradle-plugins/dependency-management-plugin>`_ for Gradle can be used
72-
to import the SDK's Maven Bill of Materials (BOM) to manage SDK dependencies for your project.
81+
.. note:: Replace the dependency for |S3| above with the dependency or dependencies of the Amazon service(s) you will be using in your project. The modules (dependencies) that are managed by the |sdk-java| BOM are listed on Maven Central (https://mvnrepository.com/artifact/com.amazonaws/aws-java-sdk-bom/latest).
82+
83+
84+
Project setup for Gradle versions prior to 4.6
85+
===============
86+
87+
Gradle versions prior to 4.6 lack native BOM support. To manage |sdk-java| dependencies for your project,
88+
use Spring's `dependency management plugin
89+
<https://github.com/spring-gradle-plugins/dependency-management-plugin>`_ for Gradle to import the SDK's Maven Bill of Materials (BOM).
7390

74-
.. topic:: To configure the SDK for Gradle prior 4.6
91+
.. note:: Replace *1.11.X* in the build file examples below with a valid version of the |sdk-java|. Find the latest version in the
92+
`AWS SDK for Java 1.11.x Reference <https://docs.aws.amazon.com/AWSJavaSDK/latest/javadoc/index.html>`_
7593

76-
#. Add the dependency management plugin to your :file:`build.gradle` file
94+
.. topic:: To configure the SDK for Gradle versions prior to 4.6:
95+
96+
#. Add the dependency management plugin to your :file:`build.gradle` file.
7797

7898
.. code-block:: groovy
7999
@@ -82,40 +102,38 @@ to import the SDK's Maven Bill of Materials (BOM) to manage SDK dependencies for
82102
mavenCentral()
83103
}
84104
dependencies {
85-
classpath "io.spring.gradle:dependency-management-plugin:1.0.3.RELEASE"
105+
classpath "io.spring.gradle:dependency-management-plugin:1.0.9.RELEASE"
86106
}
87107
}
88108
89109
apply plugin: "io.spring.dependency-management"
90110
91-
#. Add the BOM to the *dependencyManagement* section of the file
111+
#. Add the BOM to the *dependencyManagement* section of the file.
92112

93113
.. code-block:: groovy
94114
95115
dependencyManagement {
96116
imports {
97-
mavenBom 'com.amazonaws:aws-java-sdk-bom:1.11.228'
117+
mavenBom 'com.amazonaws:aws-java-sdk-bom:1.11.X'
98118
}
99119
}
100120
101-
#. Specify the SDK modules that you'll be using in the *dependencies* section
121+
#. Specify the SDK modules that you'll be using in the *dependencies* section. For example, the following includes a dependency for |S3long|.
102122

103123
.. code-block:: groovy
104124
105125
dependencies {
106126
compile 'com.amazonaws:aws-java-sdk-s3'
107-
testCompile group: 'junit', name: 'junit', version: '4.11'
108127
}
109128
110-
Gradle will automatically resolve the correct version of your SDK dependencies using the information
111-
from the BOM.
129+
Gradle automatically resolves the correct version of your SDK dependencies using the information from the BOM.
112130

113-
Here's the complete :file:`build.gradle` file:
131+
The following is an example of a complete :file:`build.gradle` file that includes a dependency for |S3|:
114132

115133
.. code-block:: groovy
116134
117135
group 'aws.test'
118-
version '1.0-SNAPSHOT'
136+
version '1.0'
119137
120138
apply plugin: 'java'
121139
@@ -127,18 +145,18 @@ Here's the complete :file:`build.gradle` file:
127145
128146
buildscript {
129147
repositories {
130-
mavenCentral()
148+
mavenCentral()
131149
}
132150
dependencies {
133-
classpath "io.spring.gradle:dependency-management-plugin:1.0.3.RELEASE"
151+
classpath "io.spring.gradle:dependency-management-plugin:1.0.9.RELEASE"
134152
}
135153
}
136154
137155
apply plugin: "io.spring.dependency-management"
138156
139157
dependencyManagement {
140158
imports {
141-
mavenBom 'com.amazonaws:aws-java-sdk-bom:1.11.228'
159+
mavenBom 'com.amazonaws:aws-java-sdk-bom:1.11.X'
142160
}
143161
}
144162
@@ -147,5 +165,7 @@ Here's the complete :file:`build.gradle` file:
147165
testCompile group: 'junit', name: 'junit', version: '4.11'
148166
}
149167
150-
.. note:: For more detail about specifying SDK dependencies using the BOM, see
151-
:doc:`setup-project-maven`.
168+
.. note:: Replace the dependency for |S3| above with the dependency or dependencies of the Amazon service(s) you will be using in your project. The modules (dependencies) that are managed by the |sdk-java| BOM are listed on Maven Central (https://mvnrepository.com/artifact/com.amazonaws/aws-java-sdk-bom/latest).
169+
170+
For more detail about specifying SDK dependencies using the BOM, see
171+
:doc:`setup-project-maven`.

0 commit comments

Comments
 (0)