focus icon indicating copy to clipboard operation
focus copied to clipboard

[SUPPORT] After running `:project:focus` unrelated projects fail to configure

Open Nava2 opened this issue 2 years ago • 8 comments

We're trying to use this plugin in a large repo. However, when the focus is applied, it generates a .focus file and focus.settings.gradle which appears to have all of the expected projects.

Though, when running ./gradlew clean, it attempts to configure projects that are not in the focus file.

I've been debugging this for a few hours and can't produce a minimal reproducible set. Any help would be appreciated in what to track down. If I hazard a guess, there's some Plugin that is pulling in dependencies recursively -- but I am unsure.

Nava2 avatar Jul 07 '23 20:07 Nava2

Hey Kevin. This is sort of a chicken and egg problem, and is know. clean removes task output, and the focus file is a task output. If we didn't remove it, we'd risk people getting stuck in a focus state without being able to get out of it. This is specific to clean, and possible just the top level clean. Other tasks should focus just fine.

On Fri, Jul 7, 2023, 15:30 Kevin Brightwell @.***> wrote:

We're trying to use this plugin in a large repo. However, when the focus is applied, it generates a .focus file and focus.settings.gradle which appears to have all of the expected projects.

Though, when running ./gradlew clean, it attempts to configure projects that are not in the focus file.

I've been debugging this for a few hours and can't produce a minimal reproducible set. Any help would be appreciated in what to track down. If I hazard a guess, there's some Plugin that is pulling in dependencies recursively -- but I am unsure.

— Reply to this email directly, view it on GitHub https://github.com/dropbox/focus/issues/37, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAJ4S3WTPYEQDYJDQVKXV43XPBWWBANCNFSM6AAAAAA2CICBPA . You are receiving this because you are subscribed to this thread.Message ID: @.***>

rharter avatar Jul 08 '23 15:07 rharter

Oh absolutely I don't think it's caused by the plugin. I'm curious if you've got any suggestions on chasing down the issue. I find it odd that we're getting projects applied that should be unfocused. I'm sure it's in our build, but the gradle logs are keeping their secrets to themselves.

Nava2 avatar Jul 08 '23 17:07 Nava2

Yeah, it's just the clean task specifically. Because of it's contract we have to remove the focus file when you clean. If you focus and then do other tasks it should work as expected.

On Sat, Jul 8, 2023, 12:25 Kevin Brightwell @.***> wrote:

Oh absolutely I don't think it's caused by the plugin. I'm curious if you've got any suggestions on chasing down the issue. I find it odd that we're getting projects applied that should be unfocused. I'm sure it's in our build, but the gradle logs are keeping their secrets to themselves.

— Reply to this email directly, view it on GitHub https://github.com/dropbox/focus/issues/37#issuecomment-1627433448, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAJ4S3XIJRRXHEMOB7HX6U3XPGJZLANCNFSM6AAAAAA2CICBPA . You are receiving this because you commented.Message ID: @.***>

rharter avatar Jul 09 '23 00:07 rharter

I'll verify soon, but that is pretty entertaining that I happened to randomly pick a task that happened to have the clean contract that's incompatible with the entire premise.

I really appreciate the time, I'll have to check this in a few days. I'll close off the issue after I verify. Thank you!

Nava2 avatar Jul 09 '23 03:07 Nava2

😢 Seems like that wasn't the issue. I'm unable to import the project into IntelliJ after :focus -- same error. I think I'll have to do some process of elimination with all the different plugins.

Nava2 avatar Jul 09 '23 12:07 Nava2

We finally figured out what the issue is. More details in https://github.com/gradle/gradle/issues/27115

In short, the problem is how the include function in settings.gradle.kts works:

"As an example, the path a:b adds a project with path a:b, name b and project directory $rootDir/a/b. It also adds the a project with path :a, name a and project directory $rootDir/a, if it does not exist already."

We have so many cases that a and a:b are both Gradle projects.

I am wondering if the Dropbox team faced this problem. If so how you went about resolving it? cc @rharter

elshad-faire avatar Dec 05 '23 16:12 elshad-faire

Hmm, are you saying that you have a project structure like

.
└── a/
    ├── build.gradle
    ├── src/
    │   └── main
    └── b/
        ├── build.gradle
        └── src/
            └── main

And your generated focus.settings.gradle contains include(":a:b"), but you don't want it to include :a and it does?

If so, that's not something we've seen at Dropbox and, unfortunately, I can't even think of a way to work around that. That suggests that there's no way to include project :a:b without including :a, and the point of the Focus plugin is to only include the required projects. If we were to consider :a a "required" project in this case then we would also have to include it's dependencies, and that quickly nullifies any benefit of the Focus plugin.

rharter avatar Dec 09 '23 23:12 rharter

Yes you have summarized the problem correctly. And yes this is not a focus plugin issue. It is a gradle issue.

I think this issue can be closed. Maybe action item could be to improve the documentation to mention about this case and then point to the suggestion at https://github.com/gradle/gradle/issues/27115#issuecomment-1834406831.

elshad-faire avatar Dec 11 '23 17:12 elshad-faire