use of com.google.cloud.tools.intellij.appengine.project.AppEngineProjectService 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;
}
use of com.google.cloud.tools.intellij.appengine.project.AppEngineProjectService in project google-cloud-intellij by GoogleCloudPlatform.
the class AppEngineFlexibleSupportProvider method addSupport.
/**
* Initializes the Flexible facet by settings the default paths for app.yaml and Dockerfile and
* generating the necessary run configurations.
*/
public static void addSupport(@NotNull AppEngineFlexibleFacet facet, @NotNull ModifiableRootModel rootModel, boolean generateConfigFiles) {
UsageTrackerProvider.getInstance().trackEvent(GctTracking.APP_ENGINE_ADD_SUPPORT).addMetadata("env", "flex");
// Allows suggesting app.yaml and Dockerfile locations in facet and deployment UIs.
VirtualFile[] contentRoots = rootModel.getContentRoots();
AppEngineProjectService appEngineProjectService = AppEngineProjectService.getInstance();
if (contentRoots.length > 0) {
Path appYamlPath = Paths.get(appEngineProjectService.getDefaultAppYamlPath(contentRoots[0].getPath()));
Path dockerDirectory = Paths.get(appEngineProjectService.getDefaultDockerDirectory(contentRoots[0].getPath()));
facet.getConfiguration().setAppYamlPath(appYamlPath.toString());
facet.getConfiguration().setDockerDirectory(dockerDirectory.toString());
if (generateConfigFiles) {
appEngineProjectService.generateAppYaml(FlexibleRuntime.JAVA, facet.getModule(), appYamlPath.getParent());
UsageTrackerProvider.getInstance().trackEvent(GctTracking.APP_ENGINE_GENERATE_FILE_APPYAML).addMetadata("source", "addedByFramework").addMetadata("env", "flex").ping();
}
}
// TODO(joaomartins): Add other run configurations here too.
// https://github.com/GoogleCloudPlatform/google-cloud-intellij/issues/1260
setupDeploymentRunConfiguration(facet.getModule());
}
use of com.google.cloud.tools.intellij.appengine.project.AppEngineProjectService in project google-cloud-intellij by GoogleCloudPlatform.
the class MavenBuildDeploymentSource method getFile.
@Nullable
@Override
public File getFile() {
if (getModule() == null) {
return null;
}
MavenProject mavenProject = MavenProjectsManager.getInstance(project).findProject(getModule());
if (mavenProject == null) {
return null;
}
final StringBuilder targetBuild = new StringBuilder(new File(mavenProject.getBuildDirectory()).getPath() + File.separator + mavenProject.getFinalName());
AppEngineProjectService projectService = AppEngineProjectService.getInstance();
// In this case, we need to try and reload the environment.
if (environment == null) {
projectService.getModuleAppEngineEnvironment(getModule()).ifPresent(env -> environment = env);
}
if (environment != null && environment.isFlexible()) {
targetBuild.append(".");
targetBuild.append(mavenProject.getPackaging());
}
return new File(targetBuild.toString());
}
use of com.google.cloud.tools.intellij.appengine.project.AppEngineProjectService 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;
}
Aggregations