Roughly 7 years after greasemonkey was introduced, I’ve started to make effective use of the Firefox extension. This past weekend I published my first script to userscripts.org: MavenCentral Gradle-Format Search.
The script is quite simple. It does just one thing with the following steps:
- Poll the search box when your browser is pointed at search.maven.org
- Detect when the value has changed from the previous value
- When the value has changed, and its format matches the gradle-format
of dependency strings (e.g.
group:artifact:version
), it replaces the value with the format MavenCentral wants (e.g.g:"group" AND a:"artifact" AND v:"version"
)
Backstory
At work we were moving our non-transitively-resolved dependencies to
transitively-resolved dependencies and were unsure of what we could delete from
our build.gradle
. Our method involved searching for dependencies that seemed
top-level on MavenCentral, looking at the POM’s
declared dependencies, and removing any of those from our build.gradle
.