autonomousapps / dependency-analysis-gradle-plugin

Gradle plugin for JVM projects written in Java, Kotlin, Groovy, or Scala; and Android projects written in Java or Kotlin. Provides advice for managing dependencies and other applied plugins
Apache License 2.0
1.67k stars 115 forks source link

feat: allow to exclude ABI by source path #1160

Open Vampire opened 2 months ago

Vampire commented 2 months ago

Following up the comment in #1141:

I don't recall. I think this was implemented by someone else and they didn't have the bandwidth to implement that component, so left it commented out as a reminder. If you want to contribute it, I'm happy to take a look.

I had a quick look at the history.

158 introduce these changes with the comment that for it to work the source file location is missing up to now and the two todos at https://github.com/autonomousapps/dependency-analysis-gradle-plugin/commit/e4e1d2a5e1221686ad2e9e139ea025b94d0e49ec#diff-44d4684fe90105b8c2f6bfcb9ed566be03e60c3f2464db27b22fd8b0c6f5c207R159-R162 and https://github.com/autonomousapps/dependency-analysis-gradle-plugin/commit/e4e1d2a5e1221686ad2e9e139ea025b94d0e49ec#diff-2bacf6be9cf95dbf682271812bc7338662b3ccaf7952b6880d65d0f89c6fe2e0R74-R75 remained.

The second of these todo which is about missing source location you seem to have fixed in https://github.com/autonomousapps/dependency-analysis-gradle-plugin/commit/7d006caf6fd3aff1ec70cfbd4beab2b050e7599f#diff-2bacf6be9cf95dbf682271812bc7338662b3ccaf7952b6880d65d0f89c6fe2e0L117-L118, but just incompletely, as it only puts the source file name in there as read from the class file, but not the source path as initially intended and necessary for this feature.

This is a first shot at an implementation that realizes the feature. Please have a look. Of course tests are missing, but I'd like to get feedback first, especially as the logic only provides the correct sourcefiles with an heuristic on a best-effort basis. If you totally dislike it and don't have a better idea, it might not be worth putting more effort into it.