-
-
Notifications
You must be signed in to change notification settings - Fork 124
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
Don't suggest adding a (test) project dependency on the project itself (since 1.23.1) #972
Comments
Thanks for the issue. |
Can confirm that I can repro this locally, having checked out the branch on your repo. |
Thanks for taking a look, I just noticed that this doesn't happen anymore with 1.24.0 freeletics/khonshu#558 |
Oh, great! Can we close this then? |
Yes, just clicked the wrong comment button |
It actually still happens with 1.24.0. Renovate bot was weird and only updated the sample app in the project which didn't have the issue. Here is the pr that updates the main part to 1.24 freeletics/khonshu#560 |
Technically, this advice is most likely correct. When you apply the
If we look at these things as different variants of one project, as soon as you directly refer to classes in "main" from "test" you should declare a dependency. If we strictly follow the rules. I can however understand that this seems unintuitive. Especially, because there is special handling of "test" already (#900), which is most likely the reason why this advice was not seen before the support for "test-fixtures" was added. You can ignore this kind of advices in your project. For example by doing this:
I wonder if it would be enough to document that. |
Jendrik, thanks for that detailed explanation. I like to balance strictness with ergonomics, and since Gradle is unlikely to ever require users to add a dependency from the test source to the main source, I think this plugin should respect that as well. It might be enough to add that exclusion globally as you suggested in your comment, or maybe we can do something "deeper". I'm happy to take this on with the help of the reproducer provided. |
@gabrielittner can you re-test with 1.26.0? |
It's still reproducible. You can test by removing this line here https://github.com/freeletics/khonshu/blob/main/codegen-compiler/codegen-compiler.gradle.kts#L36-L37 |
With 1.27.0 as well. Advice for :tdd-in-kotlin
These transitive dependencies should be declared directly:
testImplementation(project(":tdd-in-kotlin")) https://github.com/sdkotlin/sd-kotlin-talks/tree/a7571fc464831fc23124e52cd8ce0fc445339326 |
I'd vote for special handling. Otherwise it's, "add the Breaking from the convention of the default "test" suite, the JVM Test Suite Plugin does require adding an explicit dependency to project outputs, though I haven't noticed this plugin advising If memory serves, I also don't believe any advise is given when the "test" suite of one project refers to the "testFixtures" of another. |
The special handling of how the dependency scopes of "test" and "main" are glued together has history – orginating in how the scopes But from a user perspective, I agree that the special handling is probably a good idea. Although ideally I would like to see this being configurable (see #900) to satisfy different use cases.
This should work with the current version (#854). |
Just FYI, with 1.30.0 I had a couple projects where even if I added the self references for the advised configurations verbatim, the plugin still listed them as undeclared, transitively used dependencies. I had to apply the |
I ran into this issue on one of my projects and resolved it here. I'm going to consider this issue closed. |
Build scan link
https://scans.gradle.com/s/qoumnifidl3h6
Project is open source, you can see the failure on this pr freeletics/khonshu#554
Plugin version
1.23.1
Gradle version
8.3
(Optional) Android Gradle Plugin (AGP) version
8.1.2
reason
output for bugs relating to incorrect adviceDescribe the bug
I believe this happens if the tests of a project are using the testFixtures defined in the same project which then leads the plugin to believe that the shortest path from the test source set to the main source set goes through the test fixture source set even though no dependency is needed.
To Reproduce
Expected behavior
No advice is given
The text was updated successfully, but these errors were encountered: