Search in sources :

Example 1 with ProcessOutputLineListener

use of com.google.cloud.tools.appengine.cloudsdk.process.ProcessOutputLineListener in project google-cloud-intellij by GoogleCloudPlatform.

the class AppEngineStop method stop.

/**
 * Stops the given module / version of an App Engine application.
 */
public void stop(@NotNull String module, @NotNull String version, @NotNull ProcessStartListener startListener) {
    ProcessOutputLineListener outputListener = new ProcessOutputLineListener() {

        @Override
        public void onOutputLine(String line) {
            loggingHandler.print(line + "\n");
        }
    };
    ProcessExitListener stopExitListener = new StopExitListener();
    CloudSdk sdk = helper.createSdk(loggingHandler, startListener, outputListener, outputListener, stopExitListener);
    DefaultVersionsSelectionConfiguration configuration = new DefaultVersionsSelectionConfiguration();
    configuration.setVersions(Collections.singletonList(version));
    configuration.setService(module);
    configuration.setProject(deploymentConfiguration.getCloudProjectName());
    CloudSdkAppEngineVersions command = new CloudSdkAppEngineVersions(sdk);
    command.stop(configuration);
}
Also used : ProcessExitListener(com.google.cloud.tools.appengine.cloudsdk.process.ProcessExitListener) DefaultVersionsSelectionConfiguration(com.google.cloud.tools.appengine.api.versions.DefaultVersionsSelectionConfiguration) CloudSdkAppEngineVersions(com.google.cloud.tools.appengine.cloudsdk.CloudSdkAppEngineVersions) ProcessOutputLineListener(com.google.cloud.tools.appengine.cloudsdk.process.ProcessOutputLineListener) CloudSdk(com.google.cloud.tools.appengine.cloudsdk.CloudSdk)

Example 2 with ProcessOutputLineListener

use of com.google.cloud.tools.appengine.cloudsdk.process.ProcessOutputLineListener in project app-maven-plugin by GoogleCloudPlatform.

the class CloudSdkAppEngineFactory method defaultCloudSdkBuilder.

protected CloudSdk.Builder defaultCloudSdkBuilder() {
    mojo.handleCloudSdkPathDeprecation();
    Path sdkPath = mojo.getCloudSdkHome();
    if (mojo.getCloudSdkHome() == null) {
        sdkPath = cloudSdkOperationsFactory.newDownloader(mojo.getCloudSdkVersion()).downloadCloudSdk(mojo.getLog());
    }
    CloudSdk.Builder cloudSdkBuilder = cloudSdkFactory.cloudSdkBuilder().sdkPath(sdkPath);
    if (mojo.getCloudSdkHome() != null && mojo.getCloudSdkVersion() != null) {
        try {
            cloudSdkOperationsFactory.newChecker(mojo.getCloudSdkVersion()).checkCloudSdk(cloudSdkBuilder.build());
        } catch (CloudSdkNotFoundException | CloudSdkVersionFileException | InvalidJavaSdkException | AppEngineJavaComponentsNotInstalledException | CloudSdkOutOfDateException ex) {
            throw new RuntimeException(ex);
        }
    }
    ProcessOutputLineListener lineListener = new DefaultProcessOutputLineListener(mojo.getLog());
    return cloudSdkBuilder.addStdOutLineListener(lineListener).addStdErrLineListener(lineListener).exitListener(new NonZeroExceptionExitListener()).appCommandMetricsEnvironment(mojo.getArtifactId()).appCommandMetricsEnvironmentVersion(mojo.getArtifactVersion()).appCommandCredentialFile(mojo.getServiceAccountKeyFile());
}
Also used : Path(java.nio.file.Path) CloudSdkOutOfDateException(com.google.cloud.tools.appengine.cloudsdk.CloudSdkOutOfDateException) CloudSdkNotFoundException(com.google.cloud.tools.appengine.cloudsdk.CloudSdkNotFoundException) AppEngineJavaComponentsNotInstalledException(com.google.cloud.tools.appengine.cloudsdk.AppEngineJavaComponentsNotInstalledException) NonZeroExceptionExitListener(com.google.cloud.tools.appengine.cloudsdk.process.NonZeroExceptionExitListener) CloudSdkVersionFileException(com.google.cloud.tools.appengine.cloudsdk.CloudSdkVersionFileException) ProcessOutputLineListener(com.google.cloud.tools.appengine.cloudsdk.process.ProcessOutputLineListener) CloudSdk(com.google.cloud.tools.appengine.cloudsdk.CloudSdk) InvalidJavaSdkException(com.google.cloud.tools.appengine.cloudsdk.InvalidJavaSdkException)

Example 3 with ProcessOutputLineListener

use of com.google.cloud.tools.appengine.cloudsdk.process.ProcessOutputLineListener in project google-cloud-intellij by GoogleCloudPlatform.

the class AppEngineStandardStage method stage.

/**
 * Stage the application in preparation for deployment to the App Engine standard environment.
 *
 * @param stagingDirectory the local staging directory
 * @param onStageComplete a callback for executing actions on completion of staging
 */
public void stage(@NotNull Path stagingDirectory, @NotNull ProcessStartListener startListener, @NotNull ProcessExitListener onStageComplete) {
    ProcessOutputLineListener outputListener = new ProcessOutputLineListener() {

        @Override
        public void onOutputLine(String line) {
            loggingHandler.print(line + "\n");
        }
    };
    CloudSdk sdk = helper.createSdk(loggingHandler, startListener, outputListener, outputListener, onStageComplete);
    // TODO determine the default set of flags we want to set for AE standard staging
    DefaultStageStandardConfiguration stageConfig = new DefaultStageStandardConfiguration();
    stageConfig.setEnableJarSplitting(true);
    // TODO(joaomartins): Change File to Path on library configs.
    stageConfig.setStagingDirectory(stagingDirectory.toFile());
    stageConfig.setSourceDirectory(deploymentArtifactPath.toFile());
    CloudSdkAppEngineStandardStaging staging = new CloudSdkAppEngineStandardStaging(sdk);
    staging.stageStandard(stageConfig);
}
Also used : DefaultStageStandardConfiguration(com.google.cloud.tools.appengine.api.deploy.DefaultStageStandardConfiguration) ProcessOutputLineListener(com.google.cloud.tools.appengine.cloudsdk.process.ProcessOutputLineListener) CloudSdkAppEngineStandardStaging(com.google.cloud.tools.appengine.cloudsdk.CloudSdkAppEngineStandardStaging) CloudSdk(com.google.cloud.tools.appengine.cloudsdk.CloudSdk)

Aggregations

CloudSdk (com.google.cloud.tools.appengine.cloudsdk.CloudSdk)3 ProcessOutputLineListener (com.google.cloud.tools.appengine.cloudsdk.process.ProcessOutputLineListener)3 DefaultStageStandardConfiguration (com.google.cloud.tools.appengine.api.deploy.DefaultStageStandardConfiguration)1 DefaultVersionsSelectionConfiguration (com.google.cloud.tools.appengine.api.versions.DefaultVersionsSelectionConfiguration)1 AppEngineJavaComponentsNotInstalledException (com.google.cloud.tools.appengine.cloudsdk.AppEngineJavaComponentsNotInstalledException)1 CloudSdkAppEngineStandardStaging (com.google.cloud.tools.appengine.cloudsdk.CloudSdkAppEngineStandardStaging)1 CloudSdkAppEngineVersions (com.google.cloud.tools.appengine.cloudsdk.CloudSdkAppEngineVersions)1 CloudSdkNotFoundException (com.google.cloud.tools.appengine.cloudsdk.CloudSdkNotFoundException)1 CloudSdkOutOfDateException (com.google.cloud.tools.appengine.cloudsdk.CloudSdkOutOfDateException)1 CloudSdkVersionFileException (com.google.cloud.tools.appengine.cloudsdk.CloudSdkVersionFileException)1 InvalidJavaSdkException (com.google.cloud.tools.appengine.cloudsdk.InvalidJavaSdkException)1 NonZeroExceptionExitListener (com.google.cloud.tools.appengine.cloudsdk.process.NonZeroExceptionExitListener)1 ProcessExitListener (com.google.cloud.tools.appengine.cloudsdk.process.ProcessExitListener)1 Path (java.nio.file.Path)1