Search in sources :

Example 1 with JavaParameters

use of org.eclipse.che.plugin.maven.server.execution.JavaParameters in project che by eclipse.

the class MavenServerManagerTest method testBuildMavenServerParametersMainWorkDirExec.

@Test
public void testBuildMavenServerParametersMainWorkDirExec() throws Exception {
    MavenServerManager test = new MavenServerManager("test");
    try {
        JavaParameters parameters = test.buildMavenServerParameters();
        assertThat(parameters.getMainClassName()).isEqualTo("org.eclipse.che.maven.server.MavenServerMain");
        assertThat(parameters.getWorkingDirectory()).isEqualTo(System.getProperty("java.io.tmpdir"));
        assertThat(parameters.getJavaExecutable()).isEqualTo("java");
    } finally {
        test.shutdown();
    }
}
Also used : JavaParameters(org.eclipse.che.plugin.maven.server.execution.JavaParameters) MavenServerManager(org.eclipse.che.plugin.maven.server.MavenServerManager) Test(org.testng.annotations.Test)

Example 2 with JavaParameters

use of org.eclipse.che.plugin.maven.server.execution.JavaParameters in project che by eclipse.

the class MavenServerManagerTest method testBuildMavenServerParametersClassPathMain.

@Test
public void testBuildMavenServerParametersClassPathMain() throws Exception {
    JavaParameters parameters = manager.buildMavenServerParameters();
    List<String> classPath = parameters.getClassPath();
    assertThat(classPath).contains(mavenServerPath + "/maven-server-impl.jar").contains(mavenServerPath + "/maven-server-api.jar");
}
Also used : JavaParameters(org.eclipse.che.plugin.maven.server.execution.JavaParameters) Test(org.testng.annotations.Test)

Example 3 with JavaParameters

use of org.eclipse.che.plugin.maven.server.execution.JavaParameters in project che by eclipse.

the class MavenServerManagerTest method testBuildMavenServerParametersClassPathMavenLib.

@Test
public void testBuildMavenServerParametersClassPathMavenLib() throws Exception {
    JavaParameters parameters = manager.buildMavenServerParameters();
    List<String> classPath = parameters.getClassPath();
    String mavenHome = System.getenv("M2_HOME");
    File libs = new File(mavenHome, "lib");
    File[] listFiles = libs.listFiles((dir, name) -> name.endsWith(".jar"));
    List<String> libPaths = Arrays.stream(listFiles).map(File::getAbsolutePath).collect(Collectors.toList());
    assertThat(classPath).contains(libPaths.toArray());
}
Also used : JavaParameters(org.eclipse.che.plugin.maven.server.execution.JavaParameters) File(java.io.File) Test(org.testng.annotations.Test)

Example 4 with JavaParameters

use of org.eclipse.che.plugin.maven.server.execution.JavaParameters in project che by eclipse.

the class MavenServerManager method buildMavenServerParameters.

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;
}
Also used : ArrayList(java.util.ArrayList) JavaParameters(org.eclipse.che.plugin.maven.server.execution.JavaParameters) File(java.io.File)

Aggregations

JavaParameters (org.eclipse.che.plugin.maven.server.execution.JavaParameters)4 Test (org.testng.annotations.Test)3 File (java.io.File)2 ArrayList (java.util.ArrayList)1 MavenServerManager (org.eclipse.che.plugin.maven.server.MavenServerManager)1