Skip to content
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

Add gradle thirdPartyAudit to precommit tasks #15491

Merged
merged 3 commits into from
Dec 16, 2015

Conversation

rmuir
Copy link
Contributor

@rmuir rmuir commented Dec 16, 2015

Currently, we do all kinds of checks on our own code, but dependencies are no different. The computer does not care if you wrote it, or dragged it in via a dependency.

This task fails for two situations (implemented with forbidden apis checks):

  1. dependency classpath is incomplete: fails the build if third party dependencies refer to other classes that do not exist. Really, when classes are missing, this is just asking for trouble e.g. NoClassDefFoundError, but in some cases its actually intentional (e.g. optional dependency of a dependency). In those cases, this check can be disabled with thirdPartyAudit.lenient = true
  2. use of internal JDK classes: fails the build, unless exact third party class doing this is excluded in thirdPartyAudit.excludes. Wildcards are explicitly not permitted in exclusion lists.

We can expand in the future, e.g. add additional forbidden apis beyond just internal JDK apis for 3rd party jars if we want. Probably better to worry about sorting out the messes discovered here first (I don't fix em, i just document what they are).

@rmuir rmuir added :Delivery/Build Build or test infrastructure v5.0.0-alpha1 labels Dec 16, 2015
@nik9000
Copy link
Member

nik9000 commented Dec 16, 2015

thirdPartyAudit.lenient = true

thirdParyAudit.ignoreClassNotFound = true? lenient leaves a lot to the imagination.

@rmuir
Copy link
Contributor Author

rmuir commented Dec 16, 2015

That is intentional, because of this problem, we have to hide all forbidden APIs warnings (otherwise the thousands of missing classes would overflow your screen).

So yes, it should be leaving stuff to the imagination, like "what else could be wrong".

@rjernst
Copy link
Member

rjernst commented Dec 16, 2015

LGTM

@nik9000
Copy link
Member

nik9000 commented Dec 16, 2015

So yes, it should be leaving stuff to the imagination, like "what else could be wrong".

Got it.

@uschindler
Copy link
Contributor

The unzipping is not nice, but looks fine. The alternative would be to not use forbiddenapis ANT task, but instead instantiate the forbiddenapis Checker class directly, pass custom logger with INFO and ERROR, but no WARN, and finally feed all classes from a ZipInputStream or similar to prevent the "Ant O(n^2) zipfileset" bug. Backside: You need a bit more code to fix the Checker initialization (classloader, load classes from ZIP stream)

+1

@nik9000
Copy link
Member

nik9000 commented Dec 16, 2015

Tried it locally as well. LGTM.

@rmuir
Copy link
Contributor Author

rmuir commented Dec 16, 2015

Instead of lenient i would also be fine with CLASSES_ARE_MISSING

Basically if we have this situation, anything goes. I thought lenient would make it sound appropriately negative, but something in all-upper-case like that would be fine too. :)

rmuir added a commit that referenced this pull request Dec 16, 2015
Add gradle thirdPartyAudit to precommit tasks
@rmuir rmuir merged commit 4f9d410 into elastic:master Dec 16, 2015
@rmuir
Copy link
Contributor Author

rmuir commented Dec 17, 2015

I am working on improving it further, to eventually remove lenient. I think there should only be excludes, that is where you list classes, if classes are wrong in any way, including if they are missing. I also have some new checks to add that reveal additional problems.

This is better as it always "keeps tabs", which is what we need. It does require doing a little hack to parse the forbidden apis warnings :)

The me, the point of these checks right now is to have nice documentation of issues for every module, not necessarily even to try to fix them. We have to at least know what is happening and what code is or is not running!

@mark-vieira mark-vieira added the Team:Delivery Meta label for Delivery team label Nov 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Delivery/Build Build or test infrastructure Team:Delivery Meta label for Delivery team v5.0.0-alpha1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants