Is there a way to find out which dependencies actu...
# gradle
m
Is there a way to find out which dependencies actually are in use by scan
build.gradle.kts
? Any idea how I can check which dependencies i can get rid of that are not in use. There a lot of dependencies and it would be great to do a scan and just remove which one not in use.
g
You mean as far as does any of your application code use the libraries?
s
That sounds more like an IDE feature
v
https://github.com/autonomousapps/dependency-analysis-android-gradle-plugin/ will tell you which are unused and which are not in the optimal configurations
Don't let you distract by the "Android" in the name, that was just unluckily chosen initially
g
This rocks, thanks for sharing!
@Vampire I notice this tells me that my JDBC drivers should all be
runtimeOnly
(which I've never used before). Is that correct?
Copy code
Dependencies which should be removed or changed to runtime-only:
  runtimeOnly("io.quarkus:quarkus-arc:2.14.2.Final") (was implementation)
  runtimeOnly("io.quarkus:quarkus-jdbc-postgresql:2.14.2.Final") (was implementation)
  runtimeOnly("io.quarkus:quarkus-vertx:2.14.2.Final") (was implementation)
  runtimeOnly("net.snowflake:snowflake-jdbc:3.13.21") (was implementation)
v
Most probably, yes. If you don't use any class inside directly, but needed it at runtime, it belongs to
runtimeOnly
. JDBC drivers usually match that criterion as they typically are selected by connection URL pattern. This makes the compile classpath smaller which improves compile speed and increases the chance of up-to-dateness and cache his
g
Ahh, thanks, I never knew!
m
This plugin is not working as expected. It tells me that I have 4 dependencies which are not in use, but in code its actually in use? Strange..
v
Never have seen that. If that is really the case, you should report it as issue if it is not listed in the limitations.
m
Ah i see now. I have a logback where I need two dependecies, they are in used but not in code but in logback.xml. Thats why it says that they are not in use.
v
Yes, of course, if things are only used in configuration files, or via reflection, or similar, then that's exactly when you would use
runtimeOnly
as you need those classes at runtime, but not to compile the code.
g
Similarly, it tells me that many of my Quarkus plugins are not in use -- but it's because they're only used during build-time metadata processor stuff, so it can't possibly know, haha Can't expect miracles I suppose 😅
v
If it is is just build-time metadata processor, I guess it is an annotation processor and should be in the annotation processor configuration, not in your acutal dependencies, no?