Esempio n. 1
0
 private ProcessExecutor createExecutor() {
   return () -> {
     JavaParameters parameters = buildMavenServerParameters();
     CommandLine command = parameters.createCommand();
     return new ProcessHandler(command.createProcess());
   };
 }
Esempio n. 2
0
  public JavaParameters buildMavenServerParameters() {
    JavaParameters parameters = new JavaParameters();
    parameters.setJavaExecutable("java");
    parameters.setWorkingDirectory(System.getProperty("java.io.tmpdir"));
    parameters.setMainClassName(MAVEN_SERVER_MAIN);
    // TODO read and set MAVEN_OPTS system properties

    List<String> classPath = new ArrayList<>();
    addDirToClasspath(classPath, new File(mavenServerPath));

    String mavenHome = System.getenv("M2_HOME");
    addDirToClasspath(classPath, new File(mavenHome, "lib"));
    File bootDir = new File(mavenHome, "boot");
    File[] classworlds =
        bootDir.listFiles(
            (dir, name) -> {
              return name.contains("classworlds");
            });

    if (classworlds != null) {
      for (File file : classworlds) {
        classPath.add(file.getAbsolutePath());
      }
    }

    parameters.getClassPath().addAll(classPath);

    parameters.getVmParameters().add("-Xmx512m");

    return parameters;
  }