Class PluginHelper

java.lang.Object
com.offbynull.coroutines.instrumenter.PluginHelper

public final class PluginHelper extends Object
Helper class for use by build system plugins.
  • Constructor Details

    • PluginHelper

      private PluginHelper()
  • Method Details

    • mapPaths

      public static Map<File,File> mapPaths(File srcDir, File dstDir)
      Given a source and destination path, scans the source path for class files and translates them to the destination path. This method recursively scans the path.

      For example, imagine source path of /src and a destination path of /dst...

       /src/A.class -> /dst/A.class
       /src/a/B.class -> /dst/B.class
       /src/a/b/c/d/e/C.class -> /dst/a/b/c/d/e/C.class
       /src/a/b/c/d/e/D.class -> /dst/a/b/c/d/e/D.class
       
      Parameters:
      srcDir - source directory
      dstDir - destination directory
      Returns:
      source class to destination class mapping
      Throws:
      NullPointerException - if any argument is null
      IllegalArgumentException - if either of the paths passed in are not directories
    • instrument

      public static void instrument(Instrumenter instrumenter, InstrumentationSettings settings, Map<File,File> srcDstMapping, Consumer<String> logger) throws IOException
      Instruments class files and generates detail files. Detail files are placed alongside destination class files -- they have the same name but the extension will be changed to .coroutinesinfo.
      Parameters:
      instrumenter - instrumenter
      settings - instrumentation settings
      srcDstMapping - class files to instrument mapped to destination files where the final instrumented results will be placed
      logger - logger to dump messages to (if any)
      Throws:
      NullPointerException - if any argument is null or contains null
      IllegalArgumentException - if a source class file doesn't exist
      IOException - on IO error
    • instrument

      public static void instrument(Instrumenter instrumenter, InstrumentationSettings settings, File srcDir, File dstDir, Consumer<String> logger) throws IOException
      Instruments class files and generates detail files. This method is equivalent to calling...
       Map<File, File> srcDstMapping = mapPaths(srcDir, dstDir);
       instrument(instrumenter, settings, srcDstMapping, logger);
       
      Parameters:
      instrumenter - instrumenter
      settings - instrumentation settings
      srcDir - source directory
      dstDir - destination directory
      logger - logger to dump messages to (if any)
      Throws:
      NullPointerException - if any argument is null or contains null
      IllegalArgumentException - if either of the paths passed in are not directories (or if a file in srcDir was removed while this method is executing)
      IOException - on IO error