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

Update dependencies 04-2024 #63

Merged
merged 30 commits into from
Apr 22, 2024
Merged

Update dependencies 04-2024 #63

merged 30 commits into from
Apr 22, 2024

Conversation

smihalic
Copy link
Contributor

@smihalic smihalic commented Apr 15, 2024

📷 Screenshots

No images, but tested this on sample app and some project, no more crashes.

📄 Context

After upgrading AGP to 8.3 a problem appeared with resources sharing the same name, in this case it was menu and string resources. This will happen on all projects that are upgrading and either using this lib or having that problem themselves.

📝 Changes

First of all, resources with same name have been renamed so that is out of way. Next, we used the chance to also bump dependencies.

Desugaring has become somewhat MUST HAVE so I included it in every place compiler was complaining.

In settings.gradle you can see a few optional changes and I commented the reason behind them.

In config.gradle I changed version of sentinel as I was deploying and testing this locally. We should probably return that to 1.3.2, not sure how deployment works.

Tests are failing miserably 😄 . For now, I did something called Pro Developer Move and commented out those failing but when we align on priorities, we can start fixing them. I saw that you used a different approach for this in build.gradle but I couldn't compile it.

📎 Related PR

🚫 Breaking

🛠️ How to test

To test this you have to comment out signing{...} in all publish.gradle files and then run ./gradlew publishReleasePublicationToMavenLocal. I coudn't test this otherwise because I think that duplicated resources are part of last maven deployment.

⏱️ Next steps

We need to align on priorities between fixing tests and removal of desugaring. It seems Chucker also demands desugaring so we might not be able to do this though. Also, toml needs to be included in build.gradle(:sentinel).

@smihalic smihalic requested review from antunflas, KCeh and AsimRibo April 15, 2024 15:24
@smihalic smihalic marked this pull request as ready for review April 15, 2024 15:24
@KCeh KCeh changed the base branch from master to develop April 16, 2024 06:11
@KCeh KCeh changed the title Update dependencies Update dependencies 04-2024 Apr 16, 2024
@KCeh
Copy link
Collaborator

KCeh commented Apr 16, 2024

First of all, always great to see the initiative 💪

But next time pls contact the library owner (in this case me) before starting work on it. Why? Because I was aware of issue and already made fixes #61 . My solution was in draft because I ran out of time and I actually contacted Google about desugaring changes. Using that as starting point could have save some time.

A few more points:

  • are you sure gradle has been properly upgraded? I see in my PR AGP upgrade assistant did some changes to build scripts for modules
  • are you sure you covered all duplicated files? At quick glance in my PR it seems I renamed at least one more file

If you want you can us my PR as starting point. I renamed duplicated resources a bit differently, your approach is probably better.
As for desugaring I will leave comment on that PR

Comment on lines +1 to +4
plugins {
id 'org.gradle.toolchains.foojay-resolver-convention' version '0.4.0'
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We had a conversation about this. I can't resolve toolchains so I have to use this as per documentation. I thought we could commit this maybe until this problem gets resolved [OPTIONAL].

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is a problem with the toolchains?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clear 👍

@@ -11,3 +15,5 @@ include ":tool-googleplay"
include ":tool-appgallery"
include ":tool-thimble"
include ":tool-timber"

gradle.startParameter.excludedTaskNames.add(":buildSrc:testClasses")
Copy link
Contributor

@AsimRibo AsimRibo Apr 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Newest AS has this problem where you can't compile anything. AS is blaming Gradle and vice versa. We have commited this on our project as we are waiting for it to be fixed, so it should be ok here? [OPTIONAL]

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So this solves the issue? Test classes won't be compiled?

Copy link
Contributor

@AsimRibo AsimRibo Apr 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, test classes are still compiled 😄 . This only allows you to mitigate this weird bug new AS has.
https://issuetracker.google.com/issues/315023802

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

RIP

@@ -1,6 +1,5 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.infinum.sentinel"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Package name inside of AndroidManifest is not supported anymore and we were getting errors/warnings, don't remember.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can set the namespace in build.gradle files.

Copy link
Collaborator

@KCeh KCeh Apr 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you don't need to set namespace for tests (manifest for tests), gradle will just append .test by default https://developer.android.com/build/configure-app-module#change-namespace-for-testing

Copy link
Member

@antunflas antunflas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider number of problems, maybe it makes more sense to just release a version without dependency updates, just with resources rename 🤷‍♂️

@@ -57,15 +57,17 @@ Then add the following dependencies in your app `build.gradle` or `build.gradle.
**Groovy**

```groovy
debugImplementation "com.infinum.sentinel:sentinel:1.3.1"
releaseImplementation "com.infinum.sentinel:sentinel-no-op:1.3.1"
def sentinelVersion = "1.3.2"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As the project already has 2 versions defined, would be good to go in a different direction than this and use a single version everywhere. On some libraries like PrinceOfVersions we have a gradle task to update readme with the current version.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is correctly updated on master, but it seems we forgot to merge this change on develop. But you are right, this would be an improvement.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will add idea for Gradle task to the list

@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

8.7 is the latest one, what is the reason to not use that one?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AGP assistant put this one. I will update it to the latest one.

@@ -1,6 +1,5 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.infinum.sentinel"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can set the namespace in build.gradle files.

@@ -10,6 +10,6 @@ import org.junit.runners.Suite.SuiteClasses
DeviceCollectorTestSuite::class,
ApplicationCollectorTests::class,
PermissionsCollectorTests::class,
PreferencesCollectorTests::class
// PreferencesCollectorTests::class
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this commented out?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems that tests haven't been maintained in a while or some changes were added, I am not in loop. For now I just commented out the problems with them since I don't think I will manage to fix them until Monday. Obviously it won't stay like this, but for now I can't do much since I have project expectations.
I don't want to delete anything since all these tests must pass written conditions once we find time to fix them (soon). I am waiting for Karlo's advice for further steps.

Same for all other comments.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, tests are causing a lot of issues, compiling sentinel (not sample app) seems to throw errors because of tests.
Some test logic was thrown out a couple of versions ago.
I definitely see values in test, but if they are blocking us we would either need to comment them out (and fix them at later point) or simply remove them

import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.infinum.sentinel.data.models.raw.DeviceData
//import com.infinum.sentinel.data.sources.raw.formatters.XmlStringBuilderTests
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove

import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.infinum.sentinel.data.models.raw.DeviceData
//import com.infinum.sentinel.data.sources.raw.formatters.XmlStringBuilderTests
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Run through the project and remove unused imports please

Comment on lines 7 to 15
//@RunWith(Suite::class)
//@SuiteClasses(
// PlainStringBuilderTests::class,
// MarkdownStringBuilderTests::class,
// JsonStringBuilderTests::class,
// XmlStringBuilderTests::class,
// HtmlStringBuilderTests::class
//)
//public class FormattersTestSuite
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the reason for removing quite many test classes?

Comment on lines +1 to +4
plugins {
id 'org.gradle.toolchains.foojay-resolver-convention' version '0.4.0'
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is a problem with the toolchains?

@@ -10,6 +10,6 @@ import org.junit.runners.Suite.SuiteClasses
DeviceCollectorTestSuite::class,
ApplicationCollectorTests::class,
PermissionsCollectorTests::class,
PreferencesCollectorTests::class
// PreferencesCollectorTests::class
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, tests are causing a lot of issues, compiling sentinel (not sample app) seems to throw errors because of tests.
Some test logic was thrown out a couple of versions ago.
I definitely see values in test, but if they are blocking us we would either need to comment them out (and fix them at later point) or simply remove them

@@ -18,7 +18,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="?attr/actionBarSize"
app:menu="@menu/sentinel_bundle_monitor"
app:menu="@menu/sentinel_bundle_monitor_menu"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice

Comment on lines 29 to 31
compileOptions {
coreLibraryDesugaringEnabled true
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see you added desugaring to each module.
I might be wrong, but it is not only needed for modules that depend on modules that use desugaring (sentinel module, sample app module and timber module?)?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will take a look at this

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah best to recheck if you can but compiler was complaining about desugaring not being enabled in every module.

@KCeh
Copy link
Collaborator

KCeh commented Apr 19, 2024

It seems that CR will fail because of one module using dependency on library from remote repo (new version is not available on remote repo)
https://github.com/infinum/android-sentinel/actions/runs/8740519874/job/23984378145?pr=63
I will look into this

@KCeh
Copy link
Collaborator

KCeh commented Apr 19, 2024

Consider number of problems, maybe it makes more sense to just release a version without dependency updates, just with resources rename 🤷‍♂️

I see your point, but I think 90% of issues are test related. If we remove test we should be fine.

@KCeh
Copy link
Collaborator

KCeh commented Apr 19, 2024

It seems that CR will fail because of one module using dependency on library from remote repo (new version is not available on remote repo) https://github.com/infinum/android-sentinel/actions/runs/8740519874/job/23984378145?pr=63 I will look into this

I see resource changes are all related to Sentinel module. So if we downgrade Sentinel version in libs.version we should be fine.

But,
@antunflas how does this impact library publishing? If in all modules we are always referencing "old" version of core Sentinel module? Again, it won't impact us this time since all changes are in Sentinel module, but it might in future

@antunflas
Copy link
Member

how does this impact library publishing? If in all modules we are always referencing "old" version of core Sentinel module? Again, it won't impact us this time since all changes are in Sentinel module, but it might in future

You can publish and check the pom.xml file to see what version of a dependency is referenced. Referencing the old Sentinel module is wrong because anyone adding only some tool dependency will get the old version.

I guess the idea with this setup was to:

  1. create a PR with all changes excluding a version change
  2. increment version and deploy to maven
  3. create a PR with the new version

@KCeh KCeh mentioned this pull request Apr 19, 2024
@KCeh KCeh requested review from AsimRibo and KCeh April 22, 2024 07:02
Copy link
Collaborator

@KCeh KCeh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not everything is the best solution (test, need for clients to add desugaring), but for intermediate fix version it will do the job

Copy link

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

@KCeh KCeh merged commit a9256b8 into develop Apr 22, 2024
6 checks passed
@KCeh KCeh deleted the update-dependencies-04-2024 branch August 20, 2024 19:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants