Search in sources :

Example 1 with AppEngineException

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

the class CloudSdkAppEngineHelper method createSdk.

@Override
public CloudSdk createSdk(LoggingHandler loggingHandler, ProcessStartListener startListener, ProcessOutputLineListener logListener, ProcessOutputLineListener outputListener, ProcessExitListener exitListener) {
    if (credentialsPath == null) {
        loggingHandler.print(GctBundle.message("appengine.action.credential.not.found") + "\n");
        throw new AppEngineException("Failed to create application default credentials.");
    }
    PluginInfoService pluginInfoService = ServiceManager.getService(PluginInfoService.class);
    CloudSdk.Builder sdkBuilder = new CloudSdk.Builder().sdkPath(CloudSdkService.getInstance().getSdkHomePath()).async(true).addStdErrLineListener(logListener).addStdOutLineListener(outputListener).exitListener(exitListener).startListener(startListener).appCommandCredentialFile(credentialsPath.toFile()).appCommandMetricsEnvironment(pluginInfoService.getExternalPluginName()).appCommandMetricsEnvironmentVersion(pluginInfoService.getPluginVersion()).appCommandOutputFormat("json");
    getProjectJavaSdk(project).ifPresent(sdkBuilder::javaHome);
    return sdkBuilder.build();
}
Also used : PluginInfoService(com.google.cloud.tools.intellij.service.PluginInfoService) CloudSdk(com.google.cloud.tools.appengine.cloudsdk.CloudSdk) AppEngineException(com.google.cloud.tools.appengine.api.AppEngineException)

Example 2 with AppEngineException

use of com.google.cloud.tools.appengine.api.AppEngineException in project app-maven-plugin by GoogleCloudPlatform.

the class GenRepoInfoFileMojoTest method testExecute_noIgnoreErrors.

@Test(expected = MojoExecutionException.class)
public void testExecute_noIgnoreErrors() throws MojoFailureException, MojoExecutionException, AppEngineException {
    doThrow(new AppEngineException("Bad")).when(genMock).generate(genMojo);
    genMojo.execute();
    verify(genMock).generate(genMojo);
}
Also used : AppEngineException(com.google.cloud.tools.appengine.api.AppEngineException) Test(org.junit.Test)

Example 3 with AppEngineException

use of com.google.cloud.tools.appengine.api.AppEngineException in project app-maven-plugin by GoogleCloudPlatform.

the class CloudSdkLoginMojo method execute.

@Override
public void execute() throws MojoExecutionException, MojoFailureException {
    try {
        CloudSdk sdk = getAppEngineFactory().defaultCloudSdkBuilder().build();
        new CloudSdkAuth(sdk).login();
    } catch (AppEngineException ex) {
        throw new RuntimeException(ex);
    }
    if (getServiceAccountKeyFile() != null) {
        getLog().warn("serviceAccountKeyFile is configured and will be used instead of Cloud SDK auth " + "state.");
    }
}
Also used : CloudSdkAuth(com.google.cloud.tools.appengine.cloudsdk.CloudSdkAuth) CloudSdk(com.google.cloud.tools.appengine.cloudsdk.CloudSdk) AppEngineException(com.google.cloud.tools.appengine.api.AppEngineException)

Example 4 with AppEngineException

use of com.google.cloud.tools.appengine.api.AppEngineException in project app-maven-plugin by GoogleCloudPlatform.

the class StageMojo method execute.

@Override
public void execute() throws MojoExecutionException, MojoFailureException {
    if (!"war".equals(getPackaging()) && !"jar".equals(getPackaging())) {
        // https://github.com/GoogleCloudPlatform/app-maven-plugin/issues/85
        getLog().info("Staging is only executed for war and jar modules.");
        return;
    }
    // delete staging directory if it exists
    if (stagingDirectory.exists()) {
        getLog().info("Deleting the staging directory: " + stagingDirectory);
        try {
            FileUtils.deleteDirectory(stagingDirectory);
        } catch (IOException e) {
            throw new MojoFailureException("Unable to delete staging directory.", e);
        }
    }
    if (!stagingDirectory.mkdir()) {
        throw new MojoExecutionException("Unable to create staging directory");
    }
    getLog().info("Staging the application to: " + stagingDirectory);
    appengineWebXml = new AppEngineWebXml(new File(sourceDirectory.toString() + "/WEB-INF/appengine-web.xml"));
    configureAppEngineDirectory();
    if (isStandardStaging()) {
        getLog().info("Detected App Engine standard environment application.");
        // force runtime to 'java' for compat projects using Java version >1.7
        if (Float.parseFloat(getCompileTargetVersion()) > 1.7f && appengineWebXml.isVm()) {
            runtime = "java";
        }
        // Dockerfile default location
        configureDockerfileDefaultLocation();
        try {
            getAppEngineFactory().standardStaging().stageStandard(this);
        } catch (AppEngineException ex) {
            throw new RuntimeException(ex);
        }
    } else {
        getLog().info("Detected App Engine flexible environment application.");
        try {
            getAppEngineFactory().flexibleStaging().stageFlexible(this);
        } catch (AppEngineException ex) {
            throw new RuntimeException(ex);
        }
    }
}
Also used : MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) MojoFailureException(org.apache.maven.plugin.MojoFailureException) IOException(java.io.IOException) File(java.io.File) AppEngineException(com.google.cloud.tools.appengine.api.AppEngineException)

Aggregations

AppEngineException (com.google.cloud.tools.appengine.api.AppEngineException)4 CloudSdk (com.google.cloud.tools.appengine.cloudsdk.CloudSdk)2 CloudSdkAuth (com.google.cloud.tools.appengine.cloudsdk.CloudSdkAuth)1 PluginInfoService (com.google.cloud.tools.intellij.service.PluginInfoService)1 File (java.io.File)1 IOException (java.io.IOException)1 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)1 MojoFailureException (org.apache.maven.plugin.MojoFailureException)1 Test (org.junit.Test)1