Example #1
0
 private static void ensureModuleBaseDir(HostedModeOptions options) {
   File dir = options.getModuleBaseDir();
   if (!dir.isDirectory()) {
     dir.mkdirs();
     if (!dir.isDirectory()) {
       throw new RuntimeException(
           "unable to create module base directory: " + dir.getAbsolutePath());
     }
   }
 }
Example #2
0
 private static int chooseCodeServerPort(TreeLogger logger, HostedModeOptions options) {
   int port = options.getCodeServerPort();
   if (port == 0) {
     // Automatically choose an unused port.
     try {
       ServerSocket serverSocket = new ServerSocket(0);
       port = serverSocket.getLocalPort();
       serverSocket.close();
       return port;
     } catch (IOException e) {
       logger.log(TreeLogger.ERROR, "Unable to get an unnused port.");
       throw new RuntimeException(e);
     }
   } else if (port < 0 || port == 9997) {
     // 9997 is the default non-SuperDevMode port from DevModeBase. TODO: use constant.
     return 9876; // Default Super Dev Mode port
   } else {
     return port; // User-specified port
   }
 }
Example #3
0
  private static List<String> makeCodeServerArgs(HostedModeOptions options, int port) {
    List<String> args = new ArrayList<String>();
    args.add("-noprecompile");
    args.add("-port");
    args.add(String.valueOf(port));
    args.add("-sourceLevel");
    args.add(String.valueOf(options.getSourceLevel()));
    if (options.getBindAddress() != null) {
      args.add("-bindAddress");
      args.add(options.getBindAddress());
    }
    if (options.getWorkDir() != null) {
      args.add("-workDir");
      args.add(String.valueOf(options.getWorkDir()));
    }
    args.add("-launcherDir");
    args.add(options.getModuleBaseDir().getAbsolutePath());
    if (options.getLogLevel() != null) {
      args.add("-logLevel");
      args.add(String.valueOf(options.getLogLevel()));
    }
    if (options.getJsInteropMode() != OptionJsInteropMode.Mode.JS_RC) {
      args.add("-XjsInteropMode");
      args.add(options.getJsInteropMode().name());
    }
    if (options.shouldGenerateJsInteropExports()) {
      args.add("-generateJsInteropExports");
    }
    if (!options.isIncrementalCompileEnabled()) {
      args.add("-noincremental");
    }
    if (options.getMethodNameDisplayMode() != OptionMethodNameDisplayMode.Mode.NONE) {
      args.add("-XmethodNameDisplayMode");
      args.add(options.getMethodNameDisplayMode().name());
    }

    args.add("-style");
    args.add(options.getOutput().name());

    if (options.getProperties().size() > 0) {
      args.addAll(makeSetPropertyArgs(options.getProperties()));
    }
    for (String mod : options.getModuleNames()) {
      args.add(mod);
    }
    return args;
  }