Add common support for writing/running Java-based tools.

Review Request #11585 — Created April 8, 2021 and updated

chipx86
ReviewBot
release-3.0.x
reviewbot

Some tools require Java to be set up and for .jar files 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 .jar file 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_classpath setting in the worker configuration can be set to
a list of .jar files or directories containing .jar files. These
will all be added to the class path when running Java programs.

A new JavaToolMixin handles 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 $CLASSPATH environment
variable). It also handles dependency checks, making sure that java
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 CheckstyleTool change.

Summary
Add common support for writing/running Java-based tools.
Description From Last Updated

Based on my limited knowledge of Java terminology, this should probably be "classpath" without the space.

daviddavid
Checks run (2 succeeded)
flake8 passed.
JSHint passed.
david
  1. 
      
  2. bot/reviewbot/config.py (Diff revision 1)
     
     

    Based on my limited knowledge of Java terminology, this should probably be "classpath" without the space.

  3. 
      
Loading...