Forbiddenapis: Split the guava16-only signatures file from main signatures file #12170
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Improves workaround introduced in #12158.
Description
In #12158 the fix to workaround an issue with forbiddenapis parsing a missing signature in later Guava versions (actualy it is two of them) was to enable a now-deprecated maven plugin setting:
<failOnUnresolvableSignatures>false</failOnUnresolvableSignatures>
This flag is very risky as it ignores signatures with typos in it. This was made as a workaround for subprojects where some dependencies are missing, but birngs the risk of not cathcing bugs because of typos.
In forbiddenapis 3.1 / 3.2 a new setting was added
ignoreSignaturesOfMissingClasses=true
, as this still prevents typos in signatures and just ignores those where the class is not existent. It then also prints no warnings anymore!The problem with that is that in case of Guava, which uses a newer version of Guava in telemetry-emitter, a deprecated method was removed, so it triggers "class found, but method missing".
The "correct" fix for those issues is to use separate signatures files per dependency and only load them in sub-projects when the dependency is used. For guava there should be 2 separate files. Unfortunately Maven is a bit limited, as you cannot make the signatures file names dynamic based on dependency versions. Lucene has gone this approach (we have a set of files per dependency) and based on the Maven coordinates our Gradle build script enables them.
In this PR I used a hack, which requires a bit copypaste, because you can't modify configurations of plugin, just replace (default) or add new list items, but not remove them:
guava16-forbidden-apis.txt
This PR has: