Search in sources :

Example 16 with JavaParameters

use of com.intellij.execution.configurations.JavaParameters in project intellij-community by JetBrains.

the class GroovyScriptRunner method getClassPathFromRootModel.

@Nullable
public static PathsList getClassPathFromRootModel(Module module, boolean isTests, JavaParameters params, boolean allowDuplication, PathsList pathList) throws CantRunException {
    if (module == null) {
        return null;
    }
    pathList.add(".");
    final JavaParameters tmp = new JavaParameters();
    tmp.configureByModule(module, isTests ? JavaParameters.CLASSES_AND_TESTS : JavaParameters.CLASSES_ONLY);
    if (tmp.getClassPath().getVirtualFiles().isEmpty()) {
        return null;
    }
    Set<VirtualFile> core = new HashSet<>(params.getClassPath().getVirtualFiles());
    for (VirtualFile virtualFile : tmp.getClassPath().getVirtualFiles()) {
        if (allowDuplication || !core.contains(virtualFile)) {
            pathList.add(virtualFile);
        }
    }
    return pathList;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) JavaParameters(com.intellij.execution.configurations.JavaParameters) HashSet(java.util.HashSet) Nullable(org.jetbrains.annotations.Nullable)

Example 17 with JavaParameters

use of com.intellij.execution.configurations.JavaParameters in project intellij-community by JetBrains.

the class GroovyShellRunnerImpl method createProcess.

@Override
protected Process createProcess() throws ExecutionException {
    JavaParameters javaParameters = myShellRunner.createJavaParameters(myModule);
    javaParameters.setUseDynamicClasspath(true);
    myCommandLine = javaParameters.toCommandLine();
    return myCommandLine.createProcess();
}
Also used : JavaParameters(com.intellij.execution.configurations.JavaParameters)

Example 18 with JavaParameters

use of com.intellij.execution.configurations.JavaParameters in project intellij-community by JetBrains.

the class TestNGRunnableState method createJavaParameters.

@Override
protected JavaParameters createJavaParameters() throws ExecutionException {
    final JavaParameters javaParameters = super.createJavaParameters();
    javaParameters.setMainClass("org.testng.RemoteTestNGStarter");
    try {
        port = NetUtils.findAvailableSocketPort();
    } catch (IOException e) {
        throw new ExecutionException("Unable to bind to port " + port, e);
    }
    final TestData data = getConfiguration().getPersistantData();
    if (data.getOutputDirectory() != null && !data.getOutputDirectory().isEmpty()) {
        javaParameters.getProgramParametersList().add(CommandLineArgs.OUTPUT_DIRECTORY, data.getOutputDirectory());
    }
    javaParameters.getProgramParametersList().add(CommandLineArgs.USE_DEFAULT_LISTENERS, String.valueOf(data.USE_DEFAULT_REPORTERS));
    @NonNls final StringBuilder buf = new StringBuilder();
    if (data.TEST_LISTENERS != null && !data.TEST_LISTENERS.isEmpty()) {
        buf.append(StringUtil.join(data.TEST_LISTENERS, ";"));
    }
    collectListeners(javaParameters, buf, IDEATestNGListener.EP_NAME, ";");
    if (buf.length() > 0)
        javaParameters.getProgramParametersList().add(CommandLineArgs.LISTENER, buf.toString());
    createServerSocket(javaParameters);
    createTempFiles(javaParameters);
    return javaParameters;
}
Also used : NonNls(org.jetbrains.annotations.NonNls) TestData(com.theoryinpractice.testng.model.TestData) JavaParameters(com.intellij.execution.configurations.JavaParameters) IOException(java.io.IOException) ExecutionException(com.intellij.execution.ExecutionException)

Example 19 with JavaParameters

use of com.intellij.execution.configurations.JavaParameters in project intellij-community by JetBrains.

the class TestMethods method createJavaParameters.

@Override
protected JavaParameters createJavaParameters() throws ExecutionException {
    final JavaParameters javaParameters = super.createDefaultJavaParameters();
    final JUnitConfiguration.Data data = getConfiguration().getPersistentData();
    final RunConfigurationModule configurationModule = getConfiguration().getConfigurationModule();
    final Project project = configurationModule.getProject();
    final Module module = configurationModule.getModule();
    final GlobalSearchScope searchScope = module != null ? module.getModuleRuntimeScope(true) : GlobalSearchScope.allScope(project);
    addClassesListToJavaParameters(myFailedTests, testInfo -> testInfo != null ? getTestPresentation(testInfo, project, searchScope) : null, data.getPackageName(), true, javaParameters);
    return javaParameters;
}
Also used : Project(com.intellij.openapi.project.Project) RunConfigurationModule(com.intellij.execution.configurations.RunConfigurationModule) GlobalSearchScope(com.intellij.psi.search.GlobalSearchScope) JavaParameters(com.intellij.execution.configurations.JavaParameters) RunConfigurationModule(com.intellij.execution.configurations.RunConfigurationModule) Module(com.intellij.openapi.module.Module)

Example 20 with JavaParameters

use of com.intellij.execution.configurations.JavaParameters in project intellij-community by JetBrains.

the class TestObject method createJavaParameters.

@Override
protected JavaParameters createJavaParameters() throws ExecutionException {
    JavaParameters javaParameters = super.createJavaParameters();
    javaParameters.setMainClass(JUnitConfiguration.JUNIT_START_CLASS);
    javaParameters.getProgramParametersList().add(JUnitStarter.IDE_VERSION + JUnitStarter.VERSION);
    final StringBuilder buf = new StringBuilder();
    collectListeners(javaParameters, buf, IDEAJUnitListener.EP_NAME, "\n");
    if (buf.length() > 0) {
        try {
            myListenersFile = FileUtil.createTempFile("junit_listeners_", "", true);
            javaParameters.getProgramParametersList().add("@@" + myListenersFile.getPath());
            FileUtil.writeToFile(myListenersFile, buf.toString().getBytes(CharsetToolkit.UTF8_CHARSET));
        } catch (IOException e) {
            LOG.error(e);
        }
    }
    final Project project = getConfiguration().getProject();
    final SourceScope sourceScope = getSourceScope();
    if (isJUnit5(getConfiguration().getConfigurationModule().getModule(), sourceScope, project)) {
        javaParameters.getProgramParametersList().add(JUnitStarter.JUNIT5_PARAMETER);
        javaParameters.getClassPath().add(PathUtil.getJarPathForClass(JUnit5IdeaTestRunner.class));
        final PathsList classPath = javaParameters.getClassPath();
        classPath.add(PathUtil.getJarPathForClass(TestExecutionListener.class));
        classPath.add(PathUtil.getJarPathForClass(JupiterTestEngine.class));
        classPath.add(PathUtil.getJarPathForClass(JUnitException.class));
        classPath.add(PathUtil.getJarPathForClass(TestEngine.class));
        classPath.add(PathUtil.getJarPathForClass(JUnitPlatform.class));
        try {
            JUnitUtil.getTestCaseClass(sourceScope);
            classPath.add(PathUtil.getJarPathForClass(VintageTestEngine.class));
        } catch (JUnitUtil.NoJUnitException ignore) {
        }
    }
    return javaParameters;
}
Also used : JupiterTestEngine(org.junit.jupiter.engine.JupiterTestEngine) TestExecutionListener(org.junit.platform.launcher.TestExecutionListener) JUnitException(org.junit.platform.commons.JUnitException) JUnit5IdeaTestRunner(com.intellij.junit5.JUnit5IdeaTestRunner) IOException(java.io.IOException) VintageTestEngine(org.junit.vintage.engine.VintageTestEngine) Project(com.intellij.openapi.project.Project) SourceScope(com.intellij.execution.testframework.SourceScope) PathsList(com.intellij.util.PathsList) JavaParameters(com.intellij.execution.configurations.JavaParameters) TestEngine(org.junit.platform.engine.TestEngine) JupiterTestEngine(org.junit.jupiter.engine.JupiterTestEngine) VintageTestEngine(org.junit.vintage.engine.VintageTestEngine) JUnitPlatform(org.junit.platform.runner.JUnitPlatform)

Aggregations

JavaParameters (com.intellij.execution.configurations.JavaParameters)30 Module (com.intellij.openapi.module.Module)9 VirtualFile (com.intellij.openapi.vfs.VirtualFile)8 ExecutionException (com.intellij.execution.ExecutionException)7 Project (com.intellij.openapi.project.Project)6 File (java.io.File)5 Nullable (org.jetbrains.annotations.Nullable)5 CantRunException (com.intellij.execution.CantRunException)4 GeneralCommandLine (com.intellij.execution.configurations.GeneralCommandLine)4 NotNull (org.jetbrains.annotations.NotNull)4 ParametersList (com.intellij.execution.configurations.ParametersList)3 ExecutionEnvironment (com.intellij.execution.runners.ExecutionEnvironment)3 SourceScope (com.intellij.execution.testframework.SourceScope)3 Sdk (com.intellij.openapi.projectRoots.Sdk)3 PathsList (com.intellij.util.PathsList)3 IOException (java.io.IOException)3 OSProcessHandler (com.intellij.execution.process.OSProcessHandler)2 JUnit5IdeaTestRunner (com.intellij.junit5.JUnit5IdeaTestRunner)2 GlobalSearchScope (com.intellij.psi.search.GlobalSearchScope)2 NonNls (org.jetbrains.annotations.NonNls)2