-
Notifications
You must be signed in to change notification settings - Fork 805
build: remove needless permitTestUnusedDeclared #4048
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -255,3 +255,28 @@ file as a URL under a <license> tag if there is no reference to a repository | |
| in Maven Central, or in the artifact downloaded by maven when the library | ||
| is added as a dependency (in IntelliJ IDEA the libraries can be found | ||
| in the project view under External Libraries at the bottom). | ||
|
|
||
| Gradle analyzeDependencies and analyzeTestDependencies | ||
| ----------------------------------------- | ||
|
|
||
| We use the "cutterslade.analyze" build plugin to help maintain good dependency hygiene. | ||
| It tries to identify when a dependency is needlessly declared, and then fail the build to complain. | ||
| Unfortunately, it also requires us to add declarations that Gradle would otherwise deem unnecessary, | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @risdenk I saw a notification about a comment that I can't find in GitHub. You said:
How does an "api dependency" remove a dependency? RE "api": An illustrative example would be There's a spectrum of developer prerogative from conservative to liberal, in terms of use of "api". I say "likely to use in conjunction with" but another person's definition might simply be the mere existence of a public signature that includes the target lib. I've increasingly preferred to use it conservatively. At work it's used liberally in a mono-repo and the extensive dependency web that doing so creates is out of control.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| since the plugin isn't aware of the semantics of "api" scope. | ||
|
|
||
| Since the plugin is imperfect, there are rare scenarios where we need to use one of its many special | ||
| gradle configurations, such as permitUnusedDeclared and permitTestUnusedDeclared. | ||
| Please avoid them by finding alternatives (if possible) -- get peer review. | ||
|
|
||
| For example, did you declare something as implementation (or testImplementation) but it's not needed at compile time? | ||
| Remove it. | ||
| If it's needed at runtime, then add as runtimeOnly (or testRuntimeOnly), *if* it otherwise | ||
| doesn't come transitively as such. | ||
| Let passing tests be your guide. | ||
| Try to be minimalist, omitting dependency declarations unless a failing build requires that you add them. | ||
|
|
||
| At each iteration of experimentation doing any dependency change in a build, write the gradle dependency locks. | ||
| *Then* run checks or otherwise evaluate the results. | ||
| A failure due to dependency locks is generally a failure to remember to write locks; it usually doesn't mean your build edits are flawed. | ||
|
|
||
| For more info: https://github.com/gradle-dependency-analyze/gradle-dependency-analyze | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,13 +21,11 @@ description = 'Apache Solr Core' | |
|
|
||
| dependencies { | ||
| api platform(project(":platform")) | ||
| permitUnusedDeclared platform(project(":platform")) | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this was a bizarre one since it's a "platform" |
||
| // Spotbugs Annotations are only needed for old findbugs | ||
| // annotation usage like in Zookeeper during compilation time. | ||
| // It is not included in the release so exclude from checks. | ||
| compileOnly libs.spotbugs.annotations | ||
| testCompileOnly libs.spotbugs.annotations | ||
| permitUnusedDeclared libs.spotbugs.annotations | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. because recent plugin update considers compileOnly as such (i.e. automatically) |
||
| // Exclude these from jar validation and license checks. | ||
| configurations.jarValidation { | ||
| exclude group: "com.github.spotbugs", module: "spotbugs-annotations" | ||
|
|
@@ -54,17 +52,14 @@ dependencies { | |
|
|
||
| implementation libs.dropwizard.metrics.core | ||
|
|
||
| implementation(libs.jersey.containers.jettyhttp, { | ||
| runtimeOnly(libs.jersey.containers.jettyhttp, { | ||
| exclude group: "org.eclipse.jetty", module: "jetty-continuation" | ||
| exclude group: "org.glassfish.hk2.external", module: "jakarta.inject" | ||
| }) | ||
| permitUnusedDeclared libs.jersey.containers.jettyhttp | ||
| implementation libs.jersey.inject.hk2 | ||
| permitUnusedDeclared libs.jersey.inject.hk2 | ||
| runtimeOnly libs.jersey.inject.hk2 | ||
| implementation(libs.jersey.media.jsonjackson, { | ||
| exclude group: "jakarta.xml.bind", module: "jakarta.xml.bind-api" | ||
| }) | ||
| permitUnusedDeclared libs.jersey.media.jsonjackson | ||
| implementation libs.jersey.core.common | ||
| implementation libs.jersey.core.server | ||
| implementation libs.hk2.api | ||
|
|
@@ -79,8 +74,6 @@ dependencies { | |
| runtimeOnly libs.apache.lucene.analysis.phonetic | ||
| runtimeOnly libs.apache.lucene.backward.codecs | ||
| implementation libs.apache.lucene.codecs | ||
| implementation libs.apache.lucene.backward.codecs | ||
| permitUnusedDeclared libs.apache.lucene.backward.codecs | ||
|
Comment on lines
-82
to
-83
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nonetheless, it's still on the runtime classpath (lockfile is truth on such matters). |
||
| implementation libs.apache.lucene.classification | ||
| implementation libs.apache.lucene.expressions | ||
| implementation libs.apache.lucene.grouping | ||
|
|
||
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -28,15 +28,11 @@ dependencies { | |
| implementation project(':solr:core') | ||
| implementation project(':solr:solrj') | ||
| implementation libs.apache.lucene.core | ||
| implementation libs.apache.lucene.backward.codecs | ||
| implementation libs.slf4j.api | ||
|
|
||
| testImplementation project(':solr:test-framework') | ||
| testImplementation libs.apache.lucene.testframework | ||
| testImplementation libs.junit.junit | ||
| testImplementation libs.commonsio.commonsio | ||
|
|
||
| // lucene-backward-codecs is a transitive dependency from cuvs-lucene but required in lockfile | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This explanation doesn't make sense IMO; instead it tells me that the author of the comment doesn't know to write locks first. Maybe our build is complicated for many folks :-( |
||
| permitUnusedDeclared libs.apache.lucene.backward.codecs | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -38,9 +38,9 @@ dependencies { | |
|
|
||
| // For 'tikaserver' backend | ||
| implementation libs.eclipse.jetty.client | ||
| permitUsedUndeclared libs.eclipse.jetty.http | ||
| permitUsedUndeclared libs.eclipse.jetty.util | ||
| permitUsedUndeclared libs.eclipse.jetty.io | ||
| implementation libs.eclipse.jetty.http | ||
| implementation libs.eclipse.jetty.util | ||
| implementation libs.eclipse.jetty.io | ||
|
Comment on lines
-41
to
+43
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @janhoy were you trying to avoid simply using
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Strange. I must have added |
||
|
|
||
| testImplementation project(':solr:test-framework') | ||
| testImplementation libs.apache.lucene.testframework | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,7 +21,6 @@ description = 'SQL Module' | |
|
|
||
| dependencies { | ||
| implementation platform(project(':platform')) | ||
| permitUnusedDeclared platform(project(":platform")) | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Very weird -- using permitBlahBlah on a platform. A platform based declaration isn't really a dependency, it just imports constraints on dependencies (not actually depending on those things). |
||
| implementation project(':solr:core') | ||
| implementation project(':solr:solrj') | ||
| implementation project(':solr:solrj-streaming') | ||
|
|
@@ -42,8 +41,6 @@ dependencies { | |
| compileOnly libs.immutables.valueannotations // needed due to Calcite requiring this CALCITE-4787 | ||
| // sub-deps of calcite-core that we reference directly | ||
| implementation libs.apache.calcite.linq4j | ||
| implementation libs.apache.calcite.avatica.core | ||
| permitUnusedDeclared libs.apache.calcite.avatica.core | ||
|
|
||
| testImplementation project(':solr:test-framework') | ||
| testImplementation libs.apache.lucene.testframework | ||
|
|
||
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.
@risdenk please review this; I'd love to have your input
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 looks great. I went down this rabbit hole for a bit too the other day. I didn't make progress. I went through and ripped out all the "permit" and ended up with test failures that I didn't have time to debug. I agree with what you are trying to do. We should not have permit* anywhere for the most part. There may be a few cases where its needed but it should be very rare.