Search in sources :

Example 1 with AppEngineEnvironment

use of com.google.cloud.tools.intellij.appengine.cloud.AppEngineEnvironment in project google-cloud-intellij by GoogleCloudPlatform.

the class AppEngineUtil method createArtifactDeploymentSources.

/**
 * Creates a list of artifact deployment sources available for deployment to App Engine.
 *
 * <p>Artifacts either target the standard or the flexible environment. All standard artifacts are
 * added. Flexible artifacts are only added if there are no other standard artifacts associated
 * with the same module.
 *
 * @return a list of {@link AppEngineArtifactDeploymentSource}
 */
public static List<AppEngineArtifactDeploymentSource> createArtifactDeploymentSources(@NotNull final Project project) {
    List<AppEngineArtifactDeploymentSource> sources = Lists.newArrayList();
    AppEngineProjectService projectService = AppEngineProjectService.getInstance();
    for (Module module : ModuleManager.getInstance(project).getModules()) {
        FacetManager facetManager = FacetManager.getInstance(module);
        if (facetManager.getFacetByType(AppEngineStandardFacetType.ID) != null || facetManager.getFacetByType(AppEngineFlexibleFacetType.ID) != null) {
            final AppEngineEnvironment environment = projectService.getModuleAppEngineEnvironment(module).orElseThrow(() -> new RuntimeException("No environment."));
            Collection<Artifact> artifacts = ArtifactUtil.getArtifactsContainingModuleOutput(module);
            sources.addAll(artifacts.stream().filter(artifact -> doesArtifactMatchEnvironment(artifact, environment)).map(artifact -> AppEngineUtil.createArtifactDeploymentSource(project, artifact, environment)).collect(toList()));
        }
    }
    return sources;
}
Also used : ModulePointer(com.intellij.openapi.module.ModulePointer) AppEngineStandardFacetType(com.google.cloud.tools.intellij.appengine.facet.standard.AppEngineStandardFacetType) ModuleManager(com.intellij.openapi.module.ModuleManager) AppEngineProjectService(com.google.cloud.tools.intellij.appengine.project.AppEngineProjectService) Artifact(com.intellij.packaging.artifacts.Artifact) Lists(com.google.common.collect.Lists) ModuleDeploymentSource(com.intellij.remoteServer.configuration.deployment.ModuleDeploymentSource) Project(com.intellij.openapi.project.Project) ModuleType(com.intellij.openapi.module.ModuleType) Module(com.intellij.openapi.module.Module) AppEngineFlexibleFacetType(com.google.cloud.tools.intellij.appengine.facet.flexible.AppEngineFlexibleFacetType) JavaModuleType(com.intellij.openapi.module.JavaModuleType) AppEngineArtifactDeploymentSource(com.google.cloud.tools.intellij.appengine.cloud.AppEngineArtifactDeploymentSource) Collection(java.util.Collection) FacetManager(com.intellij.facet.FacetManager) ArtifactPointerManager(com.intellij.packaging.artifacts.ArtifactPointerManager) ModulePointerManager(com.intellij.openapi.module.ModulePointerManager) Nullable(org.jetbrains.annotations.Nullable) Collectors.toList(java.util.stream.Collectors.toList) UserSpecifiedPathDeploymentSource(com.google.cloud.tools.intellij.appengine.cloud.flexible.UserSpecifiedPathDeploymentSource) List(java.util.List) ArtifactUtil(com.intellij.packaging.impl.artifacts.ArtifactUtil) MavenBuildDeploymentSource(com.google.cloud.tools.intellij.appengine.cloud.MavenBuildDeploymentSource) NotNull(org.jetbrains.annotations.NotNull) AppEngineEnvironment(com.google.cloud.tools.intellij.appengine.cloud.AppEngineEnvironment) AppEngineProjectService(com.google.cloud.tools.intellij.appengine.project.AppEngineProjectService) AppEngineArtifactDeploymentSource(com.google.cloud.tools.intellij.appengine.cloud.AppEngineArtifactDeploymentSource) AppEngineEnvironment(com.google.cloud.tools.intellij.appengine.cloud.AppEngineEnvironment) Module(com.intellij.openapi.module.Module) FacetManager(com.intellij.facet.FacetManager) Artifact(com.intellij.packaging.artifacts.Artifact)

Example 2 with AppEngineEnvironment

use of com.google.cloud.tools.intellij.appengine.cloud.AppEngineEnvironment 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)

Example 3 with AppEngineEnvironment

use of com.google.cloud.tools.intellij.appengine.cloud.AppEngineEnvironment in project google-cloud-intellij by GoogleCloudPlatform.

the class AppEngineStandardDeploymentEditorTest method resetEditorFrom_doesSetEnvironment.

@Test
public void resetEditorFrom_doesSetEnvironment() {
    AppEngineEnvironment environment = AppEngineEnvironment.APP_ENGINE_FLEX_COMPAT;
    configuration.setEnvironment(environment);
    editor.resetEditorFrom(configuration);
    assertThat(editor.getCommonConfig().getEnvironmentLabel().getText()).isEqualTo(environment.localizedLabel());
}
Also used : AppEngineEnvironment(com.google.cloud.tools.intellij.appengine.cloud.AppEngineEnvironment) Test(org.junit.Test)

Aggregations

AppEngineEnvironment (com.google.cloud.tools.intellij.appengine.cloud.AppEngineEnvironment)3 AppEngineProjectService (com.google.cloud.tools.intellij.appengine.project.AppEngineProjectService)2 FacetManager (com.intellij.facet.FacetManager)2 Module (com.intellij.openapi.module.Module)2 ModuleDeploymentSource (com.intellij.remoteServer.configuration.deployment.ModuleDeploymentSource)2 AppEngineArtifactDeploymentSource (com.google.cloud.tools.intellij.appengine.cloud.AppEngineArtifactDeploymentSource)1 MavenBuildDeploymentSource (com.google.cloud.tools.intellij.appengine.cloud.MavenBuildDeploymentSource)1 UserSpecifiedPathDeploymentSource (com.google.cloud.tools.intellij.appengine.cloud.flexible.UserSpecifiedPathDeploymentSource)1 AppEngineFlexibleFacetType (com.google.cloud.tools.intellij.appengine.facet.flexible.AppEngineFlexibleFacetType)1 AppEngineStandardFacetType (com.google.cloud.tools.intellij.appengine.facet.standard.AppEngineStandardFacetType)1 Lists (com.google.common.collect.Lists)1 JavaModuleType (com.intellij.openapi.module.JavaModuleType)1 ModuleManager (com.intellij.openapi.module.ModuleManager)1 ModulePointer (com.intellij.openapi.module.ModulePointer)1 ModulePointerManager (com.intellij.openapi.module.ModulePointerManager)1 ModuleType (com.intellij.openapi.module.ModuleType)1 Project (com.intellij.openapi.project.Project)1 Artifact (com.intellij.packaging.artifacts.Artifact)1 ArtifactPointerManager (com.intellij.packaging.artifacts.ArtifactPointerManager)1 ArtifactUtil (com.intellij.packaging.impl.artifacts.ArtifactUtil)1