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

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

Information

ReviewBot
release-3.0.x

Reviewers

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 ID
Add common support for writing/running Java-based tools.
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`.
c3dc53b984bb28e83ed30eadfcfb5d3f5bb8e6fb
Description From Last Updated

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

daviddavid
david
  1. 
      
  2. bot/reviewbot/config.py (Diff revision 1)
     
     
    Show all issues

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

  3. 
      
chipx86
Review request changed
Status:
Completed
Change Summary:
Pushed to release-3.0.x (33ddfb3)