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

Enable :reason task to get reason for specific gradle capabilities (e.g. testFixtures) #1097

Open
Nava2 opened this issue Jan 10, 2024 · 8 comments
Labels

Comments

@Nava2
Copy link

Nava2 commented Jan 10, 2024

Describe the solution you'd like
Some form of CLI parameters that enables specifying which gradle capability that is cared about. Such that, only that capability is shown.

For example,

./gradlew :project:reason --id ':other-project' --capability 'com.example:other-project-test-fixtures'

Describe alternatives you've considered
Add notation to siginify which capability an output belongs to if there are multiple usages. For example, showing that content comes from testFixtures vs. default.

Alternately, including all capabilities in the output of just --id ':other-project' would work!

Additional context

@autonomousapps
Copy link
Owner

I don't entirely follow this request. Could you share a sample of the expected output from such a feature?

@Nava2
Copy link
Author

Nava2 commented Jan 13, 2024

This may be user error, but if you have a build that leverages java-test-fixtures (Docs), it will add a dependency on a project with a capability rather than the normal project.

If you want to look at the "reason" output, i.e. figure out why that dependency is used in the project, there's no way to request it specifically today. Calling --id ':other-project' will return all usages from all capabilities.

Edit: I had the output wrong in my initial comment, but it still stands that there's no way to differentiate teh different capabilities/artifacts.

@Nava2
Copy link
Author

Nava2 commented Jan 13, 2024

Here's a project: https://github.com/Nava2/dependency-analysis-test-fixtures-project-example

$ ./gradlew :lib:reason --id ":other-project"

> Configure project :
WARNING: Unsupported Kotlin plugin version.
The `embedded-kotlin` and `kotlin-dsl` plugins rely on features of Kotlin `1.9.20` that might work differently than in the requested version `1.9.22`.

> Task :lib:reason

----------------------------------------
You asked about the dependency ':other-project'.
There is no advice regarding this dependency.
----------------------------------------

Shortest path from :lib to dependency-analysis-test-fixtures-project-example:other-project for compileClasspath:
:lib
\--- dependency-analysis-test-fixtures-project-example:other-project

Shortest path from :lib to dependency-analysis-test-fixtures-project-example:other-project for runtimeClasspath:
:lib
\--- dependency-analysis-test-fixtures-project-example:other-project

Shortest path from :lib to dependency-analysis-test-fixtures-project-example:other-project for testCompileClasspath:
:lib
\--- dependency-analysis-test-fixtures-project-example:other-project

Shortest path from :lib to dependency-analysis-test-fixtures-project-example:other-project for testRuntimeClasspath:
:lib
\--- dependency-analysis-test-fixtures-project-example:other-project

Source: main
------------
(no usages)

Source: test
------------
* Uses 1 class: com.example.dependency_analysis.TestFixture (implies testImplementation).

I'm unsure how to get advice for why the testFixture(project(":other-project")) is applied

@Nava2
Copy link
Author

Nava2 commented Jan 13, 2024

@autonomousapps I added some more context, I had my initial question incorrect as the test fixture content is there. It's just not marked/obvious what is coming from where. I updated the initial description and my previous comment! Apologies for confusion.

@autonomousapps
Copy link
Owner

@jjohannes this might be something interesting for us to take a look at.

@Nava2
Copy link
Author

Nava2 commented Jan 14, 2024

The capability information appears to be in the JSON output, so I hope this is just a visualization change 😅

@arthurrogel
Copy link

Hey, just noting here, I ran into this same issue today, the parameter proposed by @Nava2 would definitely be helpful to me as well!

@seregamorph
Copy link
Contributor

This seems to be related #1170

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants