Skip to content

Commit dee1a81

Browse files
authored
chore: Upgrade Gradle, AGP, and KtLint (#2172)
* Remove deprecated maven project * Fix task name grep * Upgrade Gradle to 7.5.1 * Upgrade AGP * Add VERSION_NAME back to BuildConfig This was removed for library projects in AGP 4.1. We may consider renaming this in the future to disambiguate the Amplify version and the application version. * Update KtLint and fix all new lint errors * Use JDK11 on codebuild * Use JDK11 in workflows * Upgrade compileSdkVersion to 31 * Try using custom commands to install Android SDK 31 * Update device farm buildspec with manual Android SDK install * Fix additional ktlint errors * Upgrade Desugar to JDK11-compatible version * Upgrade Robolectric * Set locale explicitly to match expectation
1 parent dfb5b55 commit dee1a81

File tree

27 files changed

+324
-293
lines changed

27 files changed

+324
-293
lines changed

.github/workflows/codecov_code_coverage.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929
- name: Setup Java
3030
uses: actions/setup-java@v3
3131
with:
32-
java-version: '8'
32+
java-version: '11'
3333
distribution: 'corretto'
3434

3535
- name: Run test and generate jacoco report

.github/workflows/gradle.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ jobs:
1616

1717
steps:
1818
- uses: actions/checkout@v2
19-
- name: Set up JDK 1.8
19+
- name: Set up JDK 11
2020
uses: actions/setup-java@v1
2121
with:
22-
java-version: 1.8
22+
java-version: 11
2323
- name: Grant execute permission for gradlew
2424
run: chmod +x gradlew
2525
- name: Build with Gradle

.idea/codeStyles/Project.xml

+3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

aws-analytics-pinpoint/src/test/java/com/amplifyframework/analytics/pinpoint/models/PinpointEventTest.kt

+3-2
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
*/
1515
package com.amplifyframework.analytics.pinpoint.models
1616

17+
import java.util.Locale
1718
import org.junit.Assert.assertEquals
1819
import org.junit.Test
1920

@@ -41,7 +42,7 @@ class PinpointEventTest {
4142
eventTimestamp = 1657035956917L,
4243
uniqueId = "UNIQUE_ID",
4344
androidAppDetails = AndroidAppDetails("appId", "appTitle", "packageName", "versionCode", "versionName"),
44-
androidDeviceDetails = AndroidDeviceDetails()
45+
androidDeviceDetails = AndroidDeviceDetails(locale = Locale.US)
4546
)
4647
assertEquals(expectedOutput, pinpointEvent.toJsonString())
4748
}
@@ -58,7 +59,7 @@ class PinpointEventTest {
5859
eventTimestamp = 1657035956917L,
5960
uniqueId = "UNIQUE_ID",
6061
androidAppDetails = AndroidAppDetails("appId", "appTitle", "packageName", "versionCode", "versionName"),
61-
androidDeviceDetails = AndroidDeviceDetails()
62+
androidDeviceDetails = AndroidDeviceDetails(locale = Locale.US)
6263
)
6364

6465
val pinpointEventJson =

aws-auth-cognito/src/main/java/com/amplifyframework/auth/cognito/KotlinAuthFacadeInternal.kt

+19-21
Original file line numberDiff line numberDiff line change
@@ -181,34 +181,32 @@ internal class KotlinAuthFacadeInternal(private val delegate: RealAWSCognitoAuth
181181
suspend fun signInWithSocialWebUI(
182182
provider: AuthProvider,
183183
callingActivity: Activity
184-
):
185-
AuthSignInResult {
186-
return suspendCoroutine { continuation ->
187-
delegate.signInWithSocialWebUI(
188-
provider,
189-
callingActivity,
190-
{ continuation.resume(it) },
191-
{ continuation.resumeWithException(it) }
192-
)
193-
}
184+
): AuthSignInResult {
185+
return suspendCoroutine { continuation ->
186+
delegate.signInWithSocialWebUI(
187+
provider,
188+
callingActivity,
189+
{ continuation.resume(it) },
190+
{ continuation.resumeWithException(it) }
191+
)
194192
}
193+
}
195194

196195
suspend fun signInWithSocialWebUI(
197196
provider: AuthProvider,
198197
callingActivity: Activity,
199198
options: AuthWebUISignInOptions
200-
):
201-
AuthSignInResult {
202-
return suspendCoroutine { continuation ->
203-
delegate.signInWithSocialWebUI(
204-
provider,
205-
callingActivity,
206-
options,
207-
{ continuation.resume(it) },
208-
{ continuation.resumeWithException(it) }
209-
)
210-
}
199+
): AuthSignInResult {
200+
return suspendCoroutine { continuation ->
201+
delegate.signInWithSocialWebUI(
202+
provider,
203+
callingActivity,
204+
options,
205+
{ continuation.resume(it) },
206+
{ continuation.resumeWithException(it) }
207+
)
211208
}
209+
}
212210

213211
suspend fun signInWithWebUI(
214212
callingActivity: Activity

aws-auth-cognito/src/main/java/com/amplifyframework/auth/cognito/RealAWSCognitoAuthPlugin.kt

+13-14
Original file line numberDiff line numberDiff line change
@@ -519,8 +519,8 @@ internal class RealAWSCognitoAuthPlugin(
519519
}
520520
}
521521
}
522-
authNState is AuthenticationState.SignedIn
523-
&& authZState is AuthorizationState.SessionEstablished -> {
522+
authNState is AuthenticationState.SignedIn &&
523+
authZState is AuthorizationState.SessionEstablished -> {
524524
authStateMachine.cancel(token)
525525
val authSignInResult = AuthSignInResult(
526526
true,
@@ -594,8 +594,8 @@ internal class RealAWSCognitoAuthPlugin(
594594
val signInState = (authNState as? AuthenticationState.SigningIn)?.signInState
595595
val challengeState = (signInState as? SignInState.ResolvingChallenge)?.challengeState
596596
when {
597-
authNState is AuthenticationState.SignedIn
598-
&& authZState is AuthorizationState.SessionEstablished -> {
597+
authNState is AuthenticationState.SignedIn &&
598+
authZState is AuthorizationState.SessionEstablished -> {
599599
authStateMachine.cancel(token)
600600
val authSignInResult = AuthSignInResult(
601601
true,
@@ -740,8 +740,8 @@ internal class RealAWSCognitoAuthPlugin(
740740
authStateMachine.send(AuthenticationEvent(AuthenticationEvent.EventType.CancelSignIn()))
741741
}
742742
}
743-
authNState is AuthenticationState.SignedIn
744-
&& authZState is AuthorizationState.SessionEstablished -> {
743+
authNState is AuthenticationState.SignedIn &&
744+
authZState is AuthorizationState.SessionEstablished -> {
745745
authStateMachine.cancel(token)
746746
val authSignInResult =
747747
AuthSignInResult(
@@ -1798,8 +1798,8 @@ internal class RealAWSCognitoAuthPlugin(
17981798
val authNState = authState.authNState
17991799
val authZState = authState.authZState
18001800
when {
1801-
authNState is AuthenticationState.FederatedToIdentityPool
1802-
&& authZState is AuthorizationState.SessionEstablished -> {
1801+
authNState is AuthenticationState.FederatedToIdentityPool &&
1802+
authZState is AuthorizationState.SessionEstablished -> {
18031803
authStateMachine.cancel(token)
18041804
val credential = authZState.amplifyCredential as? AmplifyCredential.IdentityPoolFederated
18051805
val identityId = credential?.identityId
@@ -1853,12 +1853,11 @@ internal class RealAWSCognitoAuthPlugin(
18531853
(
18541854
authNState is AuthenticationState.FederatedToIdentityPool &&
18551855
authZState is AuthorizationState.SessionEstablished
1856-
) ||
1857-
(
1858-
authZState is AuthorizationState.Error &&
1859-
authZState.exception is SessionError &&
1860-
authZState.exception.amplifyCredential is AmplifyCredential.IdentityPoolFederated
1861-
) -> {
1856+
) || (
1857+
authZState is AuthorizationState.Error &&
1858+
authZState.exception is SessionError &&
1859+
authZState.exception.amplifyCredential is AmplifyCredential.IdentityPoolFederated
1860+
) -> {
18621861
val event = AuthenticationEvent(AuthenticationEvent.EventType.ClearFederationToIdentityPool())
18631862
authStateMachine.send(event)
18641863
_clearFederationToIdentityPool(onSuccess, onError)

aws-auth-cognito/src/main/java/com/amplifyframework/auth/cognito/helpers/HostedUIHttpHelper.kt

+30-28
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ import java.net.HttpURLConnection
2727
import java.net.URL
2828
import java.net.URLEncoder
2929
import javax.net.ssl.HttpsURLConnection
30-
import kotlin.jvm.Throws
3130
import kotlin.time.Duration.Companion.seconds
3231
import kotlinx.serialization.SerialName
3332
import kotlinx.serialization.Serializable
@@ -39,39 +38,42 @@ internal object HostedUIHttpHelper {
3938
private val json = Json { ignoreUnknownKeys = true }
4039

4140
@Throws(Exception::class)
42-
fun fetchTokens(url: URL, headerParams: Map<String, String>, bodyParams: Map<String, String>):
43-
CognitoUserPoolTokens {
44-
val connection = (url.openConnection() as HttpsURLConnection).apply {
45-
requestMethod = "POST"
46-
doOutput = true
47-
// add headers
48-
headerParams.map { addRequestProperty(it.key, it.value) }
49-
// add body
50-
DataOutputStream(outputStream).use { dos ->
51-
val requestBody = bodyParams.map {
52-
"${URLEncoder.encode(it.key, "UTF-8")}=${URLEncoder.encode(it.value, "UTF-8")}"
53-
}.joinToString("&")
54-
dos.writeBytes(requestBody)
55-
}
41+
fun fetchTokens(
42+
url: URL,
43+
headerParams: Map<String, String>,
44+
bodyParams: Map<String, String>
45+
): CognitoUserPoolTokens {
46+
val connection = (url.openConnection() as HttpsURLConnection).apply {
47+
requestMethod = "POST"
48+
doOutput = true
49+
// add headers
50+
headerParams.map { addRequestProperty(it.key, it.value) }
51+
// add body
52+
DataOutputStream(outputStream).use { dos ->
53+
val requestBody = bodyParams.map {
54+
"${URLEncoder.encode(it.key, "UTF-8")}=${URLEncoder.encode(it.value, "UTF-8")}"
55+
}.joinToString("&")
56+
dos.writeBytes(requestBody)
5657
}
58+
}
5759

58-
val responseCode = connection.responseCode
60+
val responseCode = connection.responseCode
5961

60-
if (responseCode >= HttpURLConnection.HTTP_OK && responseCode < HttpURLConnection.HTTP_INTERNAL_ERROR) {
61-
val responseStream = if (responseCode < HttpURLConnection.HTTP_MULT_CHOICE) {
62-
connection.inputStream
63-
} else {
64-
connection.errorStream
65-
}
66-
val responseString = responseStream.bufferedReader().use(BufferedReader::readText)
67-
return parseTokenResponse(responseString)
62+
if (responseCode >= HttpURLConnection.HTTP_OK && responseCode < HttpURLConnection.HTTP_INTERNAL_ERROR) {
63+
val responseStream = if (responseCode < HttpURLConnection.HTTP_MULT_CHOICE) {
64+
connection.inputStream
6865
} else {
69-
throw ServiceException(
70-
message = connection.responseMessage,
71-
recoverySuggestion = AmplifyException.TODO_RECOVERY_SUGGESTION
72-
)
66+
connection.errorStream
7367
}
68+
val responseString = responseStream.bufferedReader().use(BufferedReader::readText)
69+
return parseTokenResponse(responseString)
70+
} else {
71+
throw ServiceException(
72+
message = connection.responseMessage,
73+
recoverySuggestion = AmplifyException.TODO_RECOVERY_SUGGESTION
74+
)
7475
}
76+
}
7577

7678
private fun parseTokenResponse(responseString: String): CognitoUserPoolTokens {
7779

aws-auth-cognito/src/main/java/com/amplifyframework/auth/cognito/helpers/SignInChallengeHelper.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ internal object SignInChallengeHelper {
7777
}
7878
}
7979
challengeNameType is ChallengeNameType.SmsMfa ||
80-
challengeNameType is ChallengeNameType.CustomChallenge
81-
|| challengeNameType is ChallengeNameType.NewPasswordRequired -> {
80+
challengeNameType is ChallengeNameType.CustomChallenge ||
81+
challengeNameType is ChallengeNameType.NewPasswordRequired -> {
8282
val challenge =
8383
AuthChallenge(challengeNameType.value, username, session, challengeParameters)
8484
SignInEvent(SignInEvent.EventType.ReceivedChallenge(challenge))

aws-auth-cognito/src/test/java/com/amplifyframework/auth/cognito/featuretest/generators/testcasegenerators/SignUpTestCaseGenerator.kt

+21-22
Original file line numberDiff line numberDiff line change
@@ -86,20 +86,19 @@ object SignUpTestCaseGenerator : SerializableProvider {
8686
ExpectationShapes.Amplify(
8787
apiName = AuthAPI.signUp,
8888
responseType = ResponseType.Success,
89-
response =
90-
AuthSignUpResult(
91-
false,
92-
AuthNextSignUpStep(
93-
AuthSignUpStep.CONFIRM_SIGN_UP_STEP,
94-
emptyMap(),
95-
AuthCodeDeliveryDetails(
96-
email,
97-
AuthCodeDeliveryDetails.DeliveryMedium.EMAIL,
98-
"attributeName"
99-
)
100-
),
101-
null
102-
).toJsonElement()
89+
response = AuthSignUpResult(
90+
false,
91+
AuthNextSignUpStep(
92+
AuthSignUpStep.CONFIRM_SIGN_UP_STEP,
93+
emptyMap(),
94+
AuthCodeDeliveryDetails(
95+
email,
96+
AuthCodeDeliveryDetails.DeliveryMedium.EMAIL,
97+
"attributeName"
98+
)
99+
),
100+
null
101+
).toJsonElement()
103102
)
104103
)
105104
)
@@ -131,15 +130,15 @@ object SignUpTestCaseGenerator : SerializableProvider {
131130
apiName = AuthAPI.signUp,
132131
responseType = ResponseType.Success,
133132
response =
134-
AuthSignUpResult(
135-
true,
136-
AuthNextSignUpStep(
137-
AuthSignUpStep.DONE,
138-
emptyMap(),
139-
null
140-
),
133+
AuthSignUpResult(
134+
true,
135+
AuthNextSignUpStep(
136+
AuthSignUpStep.DONE,
137+
emptyMap(),
141138
null
142-
).toJsonElement()
139+
),
140+
null
141+
).toJsonElement()
143142
)
144143
)
145144
)

aws-storage-s3/src/main/java/com/amplifyframework/storage/s3/configuration/AWSS3StoragePluginConfiguration.kt

+5-6
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,11 @@ class AWSS3StoragePluginConfiguration private constructor(builder: Builder) {
2828
.build()
2929
}
3030

31-
fun getAWSS3PluginPrefixResolver(authCredentialsProvider: AuthCredentialsProvider):
32-
AWSS3PluginPrefixResolver {
33-
return awsS3PluginPrefixResolver ?: StorageAccessLevelAwarePrefixResolver(
34-
authCredentialsProvider
35-
)
36-
}
31+
fun getAWSS3PluginPrefixResolver(authCredentialsProvider: AuthCredentialsProvider): AWSS3PluginPrefixResolver {
32+
return awsS3PluginPrefixResolver ?: StorageAccessLevelAwarePrefixResolver(
33+
authCredentialsProvider
34+
)
35+
}
3736

3837
class Builder {
3938
var awsS3PluginPrefixResolver: AWSS3PluginPrefixResolver? = null

build.gradle

+7-5
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ buildscript {
2323
}
2424

2525
dependencies {
26-
classpath 'com.android.tools.build:gradle:4.0.2'
26+
classpath 'com.android.tools.build:gradle:7.3.1'
2727
classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.10'
2828
classpath "org.jetbrains.dokka:dokka-gradle-plugin:1.7.10"
29-
classpath 'org.jlleitschuh.gradle:ktlint-gradle:9.4.1'
29+
classpath 'org.jlleitschuh.gradle:ktlint-gradle:11.0.0'
3030
classpath "org.gradle:test-retry-gradle-plugin:1.4.1"
3131
}
3232
}
@@ -66,15 +66,15 @@ task clean(type: Delete) {
6666

6767
ext {
6868
buildToolsVersion = "30.0.2"
69-
compileSdkVersion = 30
69+
compileSdkVersion = 31
7070
minSdkVersion = 24
7171
targetSdkVersion = 30
7272
awsKotlinSdkVersion = '0.17.12-beta'
7373
fragmentVersion = '1.3.1'
7474
navigationVersion = '2.3.4'
7575
dependency = [
7676
android: [
77-
desugartools: 'com.android.tools:desugar_jdk_libs:1.0.9',
77+
desugartools: 'com.android.tools:desugar_jdk_libs:1.2.0',
7878
],
7979
androidx: [
8080
v4support: 'androidx.legacy:legacy-support-v4:1.0.0',
@@ -153,7 +153,7 @@ ext {
153153
mockkandroid: 'io.mockk:mockk-android:1.12.3',
154154
mockwebserver: 'com.squareup.okhttp3:mockwebserver:5.0.0-alpha.9',
155155
mockitoinline: 'org.mockito:mockito-inline:3.11.2',
156-
robolectric: 'org.robolectric:robolectric:4.5.1',
156+
robolectric: 'org.robolectric:robolectric:4.7',
157157
jsonassert: 'org.skyscreamer:jsonassert:1.5.0'
158158
]
159159
}
@@ -224,6 +224,8 @@ private void configureAndroidLibrary(Project project) {
224224
includeAndroidResources = true
225225
}
226226
}
227+
228+
buildConfigField "String", "VERSION_NAME", "\"${project.ext.VERSION_NAME}\""
227229
}
228230

229231
lintOptions {

0 commit comments

Comments
 (0)