-
Notifications
You must be signed in to change notification settings - Fork 135
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
BaselineExactDependencies applies to all source sets #1262
BaselineExactDependencies applies to all source sets #1262
Conversation
Generate changelog in
|
GUtil.toLowerCamelCase("checkUnusedDependencies " + sourceSet.getName()), | ||
CheckUnusedDependenciesTask.class, | ||
task -> { | ||
task.dependsOn(JavaPlugin.CLASSES_TASK_NAME); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should be per source set
Preconditions.checkArgument( | ||
configuration.isCanBeResolved(), | ||
"May only add sourceOnlyConfiguration if it is resolvable: %s", | ||
configuration); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To be fair this method shouldn't exist, because I don't know in what situation users might actually use it.
The name is confusing now too since it implies source-only configurations need to be added, but we already add (ignore) all compileOnly configurations from all source sets.
But for now, let's at least throw eagerly if the user gave us a bad configuration.
I don't really want to apply this to test source sets, as I think it will cause more noisy and frustration. The intention of this task is to reduce the cruft that people ship in prod, and requiring test sourcesets to be minimal I think is overly strict. |
So, as mentioned in person I think it's fine in principle to require people's tests to also have exact dependencies, as this is an opt-in thing and can help reduce the amount of stuff downloaded when running tests. However, having tried this in practice,
|
Ok, seems like we're not in sync on the desired outcome and it doesn't help solve the initial problem that got me looking at this. Happy to close this out |
I think we still want this outcome, it's just that we need to be clear on what dependencies we consider 'explicit' and thus markable as unused. |
// testImplementation extendsFrom(implementation) | ||
// \-- testCompile extendsFrom(compile) | ||
// We therefore want to look at only the dependencies _directly_ declared in the implementation and compile | ||
// configurations (belonging to our source set) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we write a test for this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, wrote one
'''.stripIndent() | ||
|
||
then: | ||
def result = with('checkUnusedDependencies', '--stacktrace').build() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Without my latest changes (with the previous implementation at https://github.com/palantir/gradle-baseline/pull/1262/files/bc8e9e2cca856833a02d3d8775c9641378a8953f) this test failed with:
* What went wrong:
Execution failed for task ':checkUnusedDependenciesTest'.
> Found 1 dependencies unused during compilation, please delete them from 'build.gradle' or choose one of the suggested fixes:
com.google.guava:guava
Released 3.7.0 |
Before this PR
BaselineExactDependencies only applied to the main source set
After this PR
==COMMIT_MSG==
BaselineExactDependencies applies to all source sets
==COMMIT_MSG==
Possible downsides?
This will flag even more unused dependencies (including in tests), and could block upgrades