Add common support for writing/running Java-based tools.
Review Request #11585 — Created April 8, 2021 and submitted — Latest diff uploaded
Some tools require Java to be set up and for
.jarfiles to be made
available. These tend to be more complicated than typical tools. We only
have one in the codebase right now, Checkstyle, which was written to
have its own special configuration key for specifying the.jarfile to
use, but it was a bit hacky and painful to manage.This change introduces new configuration and a mixin for Java-based
tools.A new
java_classpathsetting in the worker configuration can be set to
a list of.jarfiles or directories containing.jarfiles. These
will all be added to the class path when running Java programs.A new
JavaToolMixinhandles all the Java runtime management for a
tool. Subclasses set the name of the class that will run the program.
The mixin takes care of building a base command line and a class path
(based on the configuration and on the$CLASSPATHenvironment
variable). It also handles dependency checks, making sure thatjava
and the class defined on the tool can both be run.This will soon be used by
CheckstyleTool.
All unit tests passed on Python 2.7 and 3.x.
Used this with the upcoming
CheckstyleToolchange.