/**
   * Execute the jsdoc toolkit executable.
   *
   * @param jsDocApp the location of the run.js within the jsDocToolkit
   * @param args the list of arguments for the jsdoc toolkit
   * @param extractDirectory The directory to set the execution from
   * @throws MavenReportException for any reporting exception
   */
  public static void executeJSDocToolkit(
      final File jsDocApp, final List<String> args, final File extractDirectory)
      throws MavenReportException {
    try {
      setConsoleOuput();
      LOGGER.info(
          "Executing with the following params: '" + args.toString().replaceAll(",", "") + "'");

      Context cx = Context.enter();
      cx.setLanguageVersion(Context.VERSION_1_6);
      Global global = new Global();
      PrintStream sysOut = new PrintStream(new Log4jOutputStream(LOGGER, Level.INFO), true);
      global.setErr(sysOut);
      global.setOut(sysOut);
      global.init(cx);

      Scriptable argsObj = cx.newArray(global, args.toArray(new Object[] {}));
      global.defineProperty("arguments", argsObj, ScriptableObject.DONTENUM);
      cx.evaluateReader(global, new FileReader(jsDocApp), jsDocApp.getName(), 1, null);
    } catch (FileNotFoundException e) {
      LOGGER.error("Not able to find jsdoc file at location " + jsDocApp.getAbsolutePath());
    } catch (IOException e) {
      LOGGER.error("Not able to read jsdoc file at location " + jsDocApp.getAbsolutePath());
    }
    LOGGER.info("JsDocToolkit Reporting completed.");
  }
Пример #2
0
 public static void main(String[] args) {
   errorReporter = new ToolErrorReporter(false, global.getErr());
   shellContextFactory.setErrorReporter(errorReporter);
   IProxy iproxy = new IProxy(IProxy.PROCESS_FILES, processOptions(args));
   global.init(shellContextFactory);
   shellContextFactory.call(iproxy);
 }