Search in sources :

Example 41 with RuntimeConfigurationError

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

the class TestDirectory method checkConfiguration.

@Override
public void checkConfiguration() throws RuntimeConfigurationException {
    JavaParametersUtil.checkAlternativeJRE(getConfiguration());
    ProgramParametersUtil.checkWorkingDirectoryExist(getConfiguration(), getConfiguration().getProject(), getConfiguration().getConfigurationModule().getModule());
    final String dirName = getConfiguration().getPersistentData().getDirName();
    if (dirName == null || dirName.isEmpty()) {
        throw new RuntimeConfigurationError("Directory is not specified");
    }
    final VirtualFile file = LocalFileSystem.getInstance().findFileByPath(FileUtil.toSystemIndependentName(dirName));
    if (file == null) {
        throw new RuntimeConfigurationWarning("Directory \'" + dirName + "\' is not found");
    }
    final Module module = getConfiguration().getConfigurationModule().getModule();
    if (module == null) {
        throw new RuntimeConfigurationError("Module to choose classpath from is not specified");
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) RuntimeConfigurationWarning(com.intellij.execution.configurations.RuntimeConfigurationWarning) Module(com.intellij.openapi.module.Module) RuntimeConfigurationError(com.intellij.execution.configurations.RuntimeConfigurationError)

Example 42 with RuntimeConfigurationError

use of com.intellij.execution.configurations.RuntimeConfigurationError in project google-cloud-intellij by GoogleCloudPlatform.

the class AppEngineDeploymentConfiguration method checkFlexConfig.

/**
 * Checks that this configuration is valid for a flex deployment, otherwise throws a {@link
 * RuntimeConfigurationError}.
 *
 * @param deployable the {@link AppEngineDeployable deployment source} that was selected by the
 *     user to deploy
 * @param project the {@link Project} that this configuration belongs to
 * @throws RuntimeConfigurationError if this configuration is not valid for a flex deployment
 */
private void checkFlexConfig(AppEngineDeployable deployable, Project project) throws RuntimeConfigurationError {
    check(!(deployable instanceof UserSpecifiedPathDeploymentSource) || (!StringUtil.isEmpty(userSpecifiedArtifactPath) && isJarOrWar(userSpecifiedArtifactPath)), "appengine.flex.config.user.specified.artifact.error");
    check(StringUtils.isNotBlank(moduleName), "appengine.flex.config.select.module");
    AppEngineFlexibleFacet facet = AppEngineFlexibleFacet.getFacetByModuleName(moduleName, project);
    check(facet != null, "appengine.flex.config.select.module");
    String appYamlPath = facet.getConfiguration().getAppYamlPath();
    check(StringUtils.isNotBlank(appYamlPath), "appengine.flex.config.browse.app.yaml");
    check(Files.exists(Paths.get(appYamlPath)), "appengine.deployment.config.appyaml.error");
    try {
        Optional<FlexibleRuntime> runtime = AppEngineProjectService.getInstance().getFlexibleRuntimeFromAppYaml(appYamlPath);
        if (runtime.isPresent() && runtime.get().isCustom()) {
            String dockerDirectory = facet.getConfiguration().getDockerDirectory();
            check(StringUtils.isNotBlank(dockerDirectory), "appengine.flex.config.browse.docker.directory");
            check(Files.exists(Paths.get(dockerDirectory, DOCKERFILE_NAME)), "appengine.deployment.config.dockerfile.error");
        }
    } catch (MalformedYamlFileException e) {
        throw new RuntimeConfigurationError(GctBundle.message("appengine.appyaml.malformed"));
    }
}
Also used : UserSpecifiedPathDeploymentSource(com.google.cloud.tools.intellij.appengine.cloud.flexible.UserSpecifiedPathDeploymentSource) MalformedYamlFileException(com.google.cloud.tools.intellij.appengine.project.MalformedYamlFileException) AppEngineFlexibleFacet(com.google.cloud.tools.intellij.appengine.facet.flexible.AppEngineFlexibleFacet) FlexibleRuntime(com.google.cloud.tools.intellij.appengine.project.AppEngineProjectService.FlexibleRuntime) RuntimeConfigurationError(com.intellij.execution.configurations.RuntimeConfigurationError)

Example 43 with RuntimeConfigurationError

use of com.intellij.execution.configurations.RuntimeConfigurationError in project google-cloud-intellij by GoogleCloudPlatform.

the class AppEngineDeploymentConfiguration method checkCommonConfig.

private void checkCommonConfig(AppEngineDeployable deployable) throws RuntimeConfigurationError {
    // do not check SDK if it supports dynamic install - the deployment runner will block itself
    // until installation is done.
    CloudSdkService cloudSdkService = CloudSdkService.getInstance();
    SdkStatus sdkStatus = cloudSdkService.getStatus();
    if (sdkStatus != SdkStatus.READY && !cloudSdkService.isInstallSupported()) {
        Set<CloudSdkValidationResult> sdkValidationResult = CloudSdkValidator.getInstance().validateCloudSdk();
        if (!sdkValidationResult.isEmpty()) {
            CloudSdkValidationResult result = Iterables.getFirst(sdkValidationResult, null);
            throw new RuntimeConfigurationError(GctBundle.message("appengine.flex.config.server.error", result.getMessage()));
        }
    }
    check(deployable instanceof UserSpecifiedPathDeploymentSource || deployable.isValid(), "appengine.config.deployment.source.error");
    check(StringUtils.isNotBlank(cloudProjectName), "appengine.flex.config.project.missing.message");
}
Also used : UserSpecifiedPathDeploymentSource(com.google.cloud.tools.intellij.appengine.cloud.flexible.UserSpecifiedPathDeploymentSource) CloudSdkService(com.google.cloud.tools.intellij.appengine.sdk.CloudSdkService) RuntimeConfigurationError(com.intellij.execution.configurations.RuntimeConfigurationError) SdkStatus(com.google.cloud.tools.intellij.appengine.sdk.CloudSdkService.SdkStatus) CloudSdkValidationResult(com.google.cloud.tools.intellij.appengine.sdk.CloudSdkValidationResult)

Example 44 with RuntimeConfigurationError

use of com.intellij.execution.configurations.RuntimeConfigurationError in project google-cloud-intellij by GoogleCloudPlatform.

the class AppEngineDeploymentConfigurationTest method checkConfiguration_withInvalidModuleName_throwsException.

@Test
public void checkConfiguration_withInvalidModuleName_throwsException() throws Exception {
    setUpValidFlexConfiguration();
    configuration.setModuleName("some invalid module");
    RuntimeConfigurationError error = expectThrows(RuntimeConfigurationError.class, () -> configuration.checkConfiguration(mockRemoteServer, mockAppEngineDeployable, project));
    assertThat(error).hasMessage("Select a module with the App Engine flexible facet.");
}
Also used : RuntimeConfigurationError(com.intellij.execution.configurations.RuntimeConfigurationError) Test(org.junit.Test)

Example 45 with RuntimeConfigurationError

use of com.intellij.execution.configurations.RuntimeConfigurationError in project google-cloud-intellij by GoogleCloudPlatform.

the class AppEngineDeploymentConfigurationTest method checkConfiguration_withUserSpecifiedSource_andDirectory_throwsException.

@Test
public void checkConfiguration_withUserSpecifiedSource_andDirectory_throwsException() {
    setUpValidFlexConfigurationWithUserSpecifiedSource();
    configuration.setUserSpecifiedArtifactPath(someWar.getParent());
    RuntimeConfigurationError error = expectThrows(RuntimeConfigurationError.class, () -> configuration.checkConfiguration(mockRemoteServer, mockUserSpecifiedPathDeploymentSource, project));
    assertThat(error).hasMessage("Browse to a JAR or WAR file.");
}
Also used : RuntimeConfigurationError(com.intellij.execution.configurations.RuntimeConfigurationError) Test(org.junit.Test)

Aggregations

RuntimeConfigurationError (com.intellij.execution.configurations.RuntimeConfigurationError)57 VirtualFile (com.intellij.openapi.vfs.VirtualFile)22 Test (org.junit.Test)16 Module (com.intellij.openapi.module.Module)10 ExecutionException (com.intellij.execution.ExecutionException)7 File (java.io.File)7 DartSdk (com.jetbrains.lang.dart.sdk.DartSdk)6 FlexBuildConfiguration (com.intellij.lang.javascript.flex.projectStructure.model.FlexBuildConfiguration)5 PsiFile (com.intellij.psi.PsiFile)5 NotNull (org.jetbrains.annotations.NotNull)5 GeneralCommandLine (com.intellij.execution.configurations.GeneralCommandLine)4 RuntimeConfigurationWarning (com.intellij.execution.configurations.RuntimeConfigurationWarning)4 JSClass (com.intellij.lang.javascript.psi.ecmal4.JSClass)4 Project (com.intellij.openapi.project.Project)4 Sdk (com.intellij.openapi.projectRoots.Sdk)4 CommandLineTokenizer (com.intellij.execution.configurations.CommandLineTokenizer)3 RunConfiguration (com.intellij.execution.configurations.RunConfiguration)3 JSFile (com.intellij.lang.javascript.psi.JSFile)3 PsiElement (com.intellij.psi.PsiElement)3 UserSpecifiedPathDeploymentSource (com.google.cloud.tools.intellij.appengine.cloud.flexible.UserSpecifiedPathDeploymentSource)2