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();
}
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);
}
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.");
}
}
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);
}
}
}
Aggregations