Class DefaultPluginsDir

java.lang.Object
org.apache.tika.pipes.core.config.DefaultPluginsDir

public final class DefaultPluginsDir extends Object
Resolves the default plugins directory when plugin-roots is not configured (TIKA-4864). The probe order matches the install layouts Tika ships:
  1. next to the jar the anchor class was loaded from (a flat install, tika-grpc's docker image);
  2. next to that directory's parent (the unpacked distributions and the tika-server docker image load classes from lib/, the plugins sit beside lib/);
  3. a plugins directory in the current working directory.
The result is always absolute: the forked pipes server resolves the configured value against its own working directory, which need not be the parent's, so a relative default would make the two processes disagree.
  • Field Details

    • PLUGINS_DIR_NAME

      public static final String PLUGINS_DIR_NAME
      The directory name probed in each location.
      See Also:
  • Method Details

    • resolve

      public static String resolve(Class<?> anchor)
      Resolves the default plugins directory for the install layout of the given class.
      Parameters:
      anchor - the class whose code source anchors the probe, usually the caller
      Returns:
      the absolute path of the first plugins directory found, or the absolute path of plugins in the working directory if none exists yet
    • resolve

      public static Path resolve(Path codeSourceDir, Path cwd)
      The probe itself, separated from the code-source lookup for testing.
      Parameters:
      codeSourceDir - the directory holding the anchor's jar, or null
      cwd - the working directory to fall back to
      Returns:
      the absolute path of the resolved directory