Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Build] Update Gradle to 7.4.2 & AGP to 7.2.1 #24

Merged
merged 22 commits into from
Jul 6, 2023

Conversation

ParaskP7
Copy link

@ParaskP7 ParaskP7 commented Jul 4, 2023

This PR upgrades Gradle to 7.4.2 and AGP to 7.2.1.

FYI: This PR also relates to this FluxC #2766 PR and the fact that the com.android.support group dependency had to be excluded from the wellsql dependency to get the project to build without AndroidX and android.enableJetifier=true related warnings (see PR and commit description).

PS: In addition to this Gradle and AGP upgrade, the below changes were added in order to align this repo with the rest of such WordPress-Mobile Android library related repos.


Build List:

  1. Disable the android enable jetifier gradle property
  2. Replace com android support with androidx annotation dependency
  3. Replace com android support test with androidx test dependency
  4. Enable non transitive resources for the project
  5. Remove empty gradle properties file from well processor module
  6. Downgrade androidx annotation version to 1.2.0
  7. Add copy gradle properties command to all publishing steps

Lint List:

  1. Suppress expired target sdk version for all modules
  2. Add lint check to buildkite

Test Restructure List:

  1. Update junit to 4.13.2
  2. Remove all unit test related configuration from project

Dependency Versions Refactor List:

  1. Extract all sdk version to a separate ext block
  2. Extract google auto service version to root build gradle
  3. Extract squareup java poet version to root build gradle
  4. Extract androidx annotation version to root build gradle
  5. Extract junit version to root build gradle
  6. Extract androidx appcompat version to root build gradle
  7. Extract androidx test core version to root build gradle
  8. Add versions groups to root build gradle
  9. Extract automattic publish to s3 version to settings build gradle

To test:

  • There is nothing much to test here.
  • Verifying that all the CI checks are successful should be enough.
  • However, if you want to be thorough about reviewing this change, you could run ./gradlew build locally and verify that it is successful (see previous such update).

I also noticed the below AGP 8.0 warning, which relates to the new publishing DSL. This is maybe something we need to look into for this and all other such library related repos that utilize such publishing functionality. Wdyt @oguzkocer ?

> Configure project :wellsql
WARNING:Software Components will not be created automatically for Maven publishing
from Android Gradle Plugin 8.0. To opt-in to the future behavior, set the Gradle property
android.disableAutomaticComponentCreation=true in the `gradle.properties` file or use
the new publishing DSL.

Release Notes: https://docs.gradle.org/7.4.2/release-notes.html
Command: ./gradlew wrapper --gradle-version=7.4.2
Release Notes: https://developer.android.com/build/releases/
past-releases/agp-7-2-0-release-notes

This update also fixes the below build failure:

------------------------------------------------------------------------

> Task :well-sample:processDebugMainManifest FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':well-sample:processDebugMainManifest'.
> Unable to make field private final java.lang.String java.io.File.path
accessible: module java.base does not "opens java.io" to unnamed module
@28a15d52

------------------------------------------------------------------------
This also fixes the below 'AndroidX' related warning with
'android.enableJetifier=true'. This behavior will not be allowed in
Android Gradle plugin 8.0.

------------------------------------------------------------------------

> Task :well-sample:compileDebugJavaWithJavac
...

> Configure project :wellsql
...
WARNING:Your project has set `android.useAndroidX=true`, but
configuration `:well-sample:debugRuntimeClasspath` still contains legacy
support libraries, which may cause runtime issues.
This behavior will not be allowed in Android Gradle plugin 8.0.
Please use only AndroidX dependencies or set
`android.enableJetifier=true` in the `gradle.properties` file to migrate
your project to AndroidX (see https://developer.android.com/jetpack/
androidx/migrate for more info).
The following legacy support libraries are detected:
:well-sample:debugRuntimeClasspath -> project :wellsql ->
com.android.support:support-annotations:28.0.0

> Task :wellsql:generateDebugRFile UP-TO-DATE
WARNING:Your project has set `android.useAndroidX=true`, but
configuration `:wellsql:debugRuntimeClasspath` still contains legacy
support libraries, which may cause runtime issues.
This behavior will not be allowed in Android Gradle plugin 8.0.
Please use only AndroidX dependencies or set
`android.enableJetifier=true` in the `gradle.properties` file to migrate
your project to AndroidX (see https://developer.android.com/jetpack/
androidx/migrate for more info).
The following legacy support libraries are detected:
:wellsql:debugRuntimeClasspath ->
com.android.support:support-annotations:28.0.0

> Task :well-sample-addon:generateDebugRFile UP-TO-DATE
WARNING:Your project has set `android.useAndroidX=true`, but
configuration `:well-sample-addon:debugRuntimeClasspath` still contains
legacy support libraries, which may cause runtime issues.
This behavior will not be allowed in Android Gradle plugin 8.0.
Please use only AndroidX dependencies or set
`android.enableJetifier=true` in the `gradle.properties` file to migrate
your project to AndroidX (see https://developer.android.com/jetpack/
androidx/migrate for more info).
The following legacy support libraries are detected:
:well-sample-addon:debugRuntimeClasspath -> project :wellsql ->
com.android.support:support-annotations:28.0.0

------------------------------------------------------------------------
This is done for exactly the same reason, to remove any references of
non 'AndroidX' dependencies from this project.
This is done to temporarily make Lint build success, even though the
current this project points to 'targetSdkVersion 29', which is no longer
supported, see below:

------------------------------------------------------------------------

Explanation for issues of type "ExpiredTargetSdkVersion":
As of the second half of 2018, Google Play requires that new apps and
app updates target API level 26 or higher.

Configuring your app to target a recent API level ensures that users
benefit from significant security and performance improvements, while
still allowing your app to run on older Android versions (down to the
minSdkVersion).

To update your targetSdkVersion, follow the steps from "Meeting Google
Play requirements for target API level",
https://developer.android.com/distribute/best-practices/develop/
target-sdk.html

https://support.google.com/googleplay/android-developer/answer/
113469#targetsdk
https://developer.android.com/distribute/best-practices/develop/
target-sdk.html
Since the are no unit tests written for this project, there is no point
in supporting a unit test related configuration. Supporting that adds an
additional level of maintenance that is not really necessary for this
project at this point of time.

PS: The only test written for this project is this 'WellSqlTest' UI
related test.
Release Notes: https://developer.android.com/jetpack/androidx/releases/
annotation#version_120_5

------------------------------------------------------------------------

FYI: Having a newer version of 'androidx.annotation:annotation' creates
some non-fatal Kotlin 'META-INF' related errors (see below), which is
better to avoid at this point of time, that is, until both
'androidx.appcompat:appcompat', 'androidx.annotation:annotation' and any
other library that utilized Kotlin it updated accordingly.

PS: The newest 'annotation' version (currently '1.6.0') add this extra
'annotation-jvm', which is the one bringing this new Kotlin '1.8.0'
version in.

------------------------------------------------------------------------

> Task :wellsql:extractReleaseAnnotations
e: /Users/.../annotation-jvm-1.6.0.jar!/META-INF/
annotation.kotlin_module: Module was compiled with an incompatible
version of Kotlin. The binary version of its metadata is 1.8.0, expected
version is 1.6.0.
e: /Users/.../kotlin-stdlib-1.8.0.jar!/META-INF/
kotlin-stdlib.kotlin_module: Module was compiled with an incompatible
version of Kotlin. The binary version of its metadata is 1.8.0, expected
version is 1.6.0.
e: /Users/.../kotlin-stdlib-1.8.0.jar!/META-INF/
kotlin-stdlib-jdk8.kotlin_module: Module was compiled with an
incompatible version of Kotlin. The binary version of its metadata is
1.8.0, expected version is 1.6.0.
e: /Users/.../kotlin-stdlib-1.8.0.jar!/META-INF/
kotlin-stdlib-jdk7.kotlin_module: Module was compiled with an
incompatible version of Kotlin. The binary version of its metadata is
1.8.0, expected version is 1.6.0.
e: /Users/.../kotlin-stdlib-common-1.8.0.jar!/META-INF/
kotlin-stdlib-common.kotlin_module: Module was compiled with an
incompatible version of Kotlin. The binary version of its metadata is
1.8.0, expected version is 1.6.0.

------------------------------------------------------------------------

Also, this is done to make sure that both, the 'annotation' and
'appcompat' (version '1.3.1') dependencies point to a version of
'annotation' that is close to each other.
This is done because otherwise the CI  build fails during the 'Publish
:wellsql' step with the below execution failure:

------------------------------------------------------------------------

> Task :wellsql:generateReleaseRFile FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':wellsql:generateReleaseRFile'.
> Configuration `:wellsql:releaseRuntimeClasspath` contains AndroidX
dependencies, but the `android.useAndroidX` property is not enabled,
which may cause runtime issues.
  Set `android.useAndroidX=true` in the `gradle.properties` file and
   retry.
  The following AndroidX dependencies are detected:
  :wellsql:releaseRuntimeClasspath ->
   androidx.annotation:annotation:1.6.0
  :wellsql:releaseRuntimeClasspath ->
    androidx.annotation:annotation:1.6.0 ->
     androidx.annotation:annotation-jvm:1.6.0

------------------------------------------------------------------------
@oguzkocer
Copy link

I also noticed the below AGP 8.0 warning, which relates to the new publishing DSL. This is maybe something we need to look into for this and all other such library related repos that utilize such publishing functionality. Wdyt @oguzkocer ?

Yeap, this is in my todo list. However, it feels like the more I work the longer my todo list has been getting, so not sure what's happening there 😅

@ParaskP7
Copy link
Author

ParaskP7 commented Jul 6, 2023

Yeap, this is in my todo list. However, it feels like the more I work the longer my todo list has been getting, so not sure what's happening there 😅

I feel you @oguzkocer ! 😅

PS: This ever-growing todo list of mine is staring at me too! 🙄 🤷 🛒

@ParaskP7
Copy link
Author

ParaskP7 commented Jul 6, 2023

Thank you for reviewing and testing this @oguzkocer , you rock! 🙇 ❤️ 🚀

@ParaskP7 ParaskP7 merged commit 5cfd162 into trunk Jul 6, 2023
2 checks passed
@ParaskP7 ParaskP7 deleted the build/update-gradle-to-7.4.2-agp-to-7.2.1 branch July 6, 2023 10:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants