Search in sources :

Example 1 with ModuleDeploymentSource

use of com.intellij.remoteServer.configuration.deployment.ModuleDeploymentSource in project intellij-community by JetBrains.

the class CloudModuleDeploymentRuntimeProviderBase method createDeploymentRuntime.

@Override
public CloudDeploymentRuntime createDeploymentRuntime(DeploymentSource source, CloudMultiSourceServerRuntimeInstance serverRuntime, DeploymentTask<? extends CloudDeploymentNameConfiguration> deploymentTask, DeploymentLogManager logManager) throws ServerRuntimeException {
    if (!(source instanceof ModuleDeploymentSource)) {
        return null;
    }
    ModuleDeploymentSource moduleSource = (ModuleDeploymentSource) source;
    Module module = moduleSource.getModule();
    if (module == null) {
        throw new ServerRuntimeException("Module not found: " + moduleSource.getModulePointer().getModuleName());
    }
    File contentRootFile = source.getFile();
    LOG.assertTrue(contentRootFile != null, "Content root file is not found");
    return doCreateDeploymentRuntime(moduleSource, contentRootFile, serverRuntime, deploymentTask, logManager);
}
Also used : ModuleDeploymentSource(com.intellij.remoteServer.configuration.deployment.ModuleDeploymentSource) Module(com.intellij.openapi.module.Module) File(java.io.File)

Example 2 with ModuleDeploymentSource

use of com.intellij.remoteServer.configuration.deployment.ModuleDeploymentSource in project intellij-community by JetBrains.

the class CloudGitDeploymentChecker method checkGitUrl.

public void checkGitUrl(final RemoteServer<SC> server, final DeploymentSource deploymentSource, final T settings) throws RuntimeConfigurationException {
    if (!(deploymentSource instanceof ModuleDeploymentSource)) {
        return;
    }
    ModuleDeploymentSource moduleSource = (ModuleDeploymentSource) deploymentSource;
    Module module = moduleSource.getModule();
    if (module == null) {
        return;
    }
    File contentRootFile = deploymentSource.getFile();
    if (contentRootFile == null) {
        return;
    }
    final Project project = module.getProject();
    VirtualFile contentRoot = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(contentRootFile);
    if (contentRoot == null) {
        return;
    }
    GitRepository repository = GitUtil.getRepositoryManager(project).getRepositoryForRoot(contentRoot);
    if (repository == null) {
        return;
    }
    String expectedName = settings.getDeploymentSourceName(deploymentSource);
    List<String> appNames = myDetector.collectApplicationNames(repository);
    if (appNames.isEmpty() || appNames.contains(expectedName)) {
        return;
    }
    RuntimeConfigurationWarning warning = new RuntimeConfigurationWarning("Cloud Git URL found in repository, but it doesn't match the run configuration");
    warning.setQuickFix(() -> {
        CloudGitApplication application = new CloudConnectionTask<CloudGitApplication, SC, T, SR>(project, "Searching for application", server) {

            @Override
            protected CloudGitApplication run(SR serverRuntime) throws ServerRuntimeException {
                CloudGitDeploymentRuntime deploymentRuntime = (CloudGitDeploymentRuntime) serverRuntime.createDeploymentRuntime(deploymentSource, settings, project);
                return deploymentRuntime.findApplication4Repository();
            }
        }.performSync();
        if (application == null) {
            Messages.showErrorDialog(project, "No application matching repository URL(s) found in account", server.getName());
        } else {
            settings.setDefaultDeploymentName(false);
            settings.setDeploymentName(application.getName());
        }
    });
    throw warning;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) CloudGitApplication(com.intellij.remoteServer.agent.util.CloudGitApplication) Project(com.intellij.openapi.project.Project) GitRepository(git4idea.repo.GitRepository) ModuleDeploymentSource(com.intellij.remoteServer.configuration.deployment.ModuleDeploymentSource) RuntimeConfigurationWarning(com.intellij.execution.configurations.RuntimeConfigurationWarning) Module(com.intellij.openapi.module.Module) VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File)

Example 3 with ModuleDeploymentSource

use of com.intellij.remoteServer.configuration.deployment.ModuleDeploymentSource in project google-cloud-intellij by GoogleCloudPlatform.

the class AppEngineUtil method createModuleDeploymentSources.

/**
 * Creates a list of module deployment sources available for deployment to App Engine:
 *
 * <p>Maven based deployment sources are included for both flexible and standard projects if
 * applicable.
 *
 * <p>User browsable jar/war deployment sources are included only if there are no App Engine
 * standard modules.
 *
 * @return a list of {@link ModuleDeploymentSource}'s
 */
public static List<ModuleDeploymentSource> createModuleDeploymentSources(@NotNull Project project) {
    AppEngineProjectService projectService = AppEngineProjectService.getInstance();
    List<ModuleDeploymentSource> moduleDeploymentSources = Lists.newArrayList();
    boolean hasStandardModules = false;
    for (Module module : ModuleManager.getInstance(project).getModules()) {
        FacetManager facetManager = FacetManager.getInstance(module);
        if (facetManager.getFacetByType(AppEngineStandardFacetType.ID) != null || facetManager.getFacetByType(AppEngineFlexibleFacetType.ID) != null) {
            AppEngineEnvironment environment = projectService.getModuleAppEngineEnvironment(module).orElseThrow(() -> new RuntimeException("No environment."));
            if (ModuleType.is(module, JavaModuleType.getModuleType()) && projectService.isJarOrWarMavenBuild(module)) {
                moduleDeploymentSources.add(createMavenBuildDeploymentSource(project, module, environment));
            }
            if (environment.isStandard() || environment.isFlexCompat()) {
                hasStandardModules = true;
            }
        }
    }
    if (!hasStandardModules) {
        moduleDeploymentSources.add(createUserSpecifiedPathDeploymentSource(project));
    }
    return moduleDeploymentSources;
}
Also used : ModuleDeploymentSource(com.intellij.remoteServer.configuration.deployment.ModuleDeploymentSource) AppEngineProjectService(com.google.cloud.tools.intellij.appengine.project.AppEngineProjectService) AppEngineEnvironment(com.google.cloud.tools.intellij.appengine.cloud.AppEngineEnvironment) Module(com.intellij.openapi.module.Module) FacetManager(com.intellij.facet.FacetManager)

Aggregations

Module (com.intellij.openapi.module.Module)3 ModuleDeploymentSource (com.intellij.remoteServer.configuration.deployment.ModuleDeploymentSource)3 File (java.io.File)2 AppEngineEnvironment (com.google.cloud.tools.intellij.appengine.cloud.AppEngineEnvironment)1 AppEngineProjectService (com.google.cloud.tools.intellij.appengine.project.AppEngineProjectService)1 RuntimeConfigurationWarning (com.intellij.execution.configurations.RuntimeConfigurationWarning)1 FacetManager (com.intellij.facet.FacetManager)1 Project (com.intellij.openapi.project.Project)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 CloudGitApplication (com.intellij.remoteServer.agent.util.CloudGitApplication)1 GitRepository (git4idea.repo.GitRepository)1