in appengine-plugins-core/src/main/java/com/google/cloud/tools/appengine/operations/Deployment.java [58:100]
public void deploy(DeployConfiguration config) throws AppEngineException {
Preconditions.checkNotNull(config);
Preconditions.checkNotNull(config.getDeployables());
Preconditions.checkArgument(config.getDeployables().size() > 0);
Path workingDirectory = null;
List<String> arguments = new ArrayList<>();
String mode = processMode(config.getGcloudMode());
if (mode != null) {
arguments.add(mode);
}
arguments.add("app");
arguments.add("deploy");
// Unfortunately, 'gcloud app deploy' does not let you pass a staging directory as a deployable.
// Instead, we have to run 'gcloud app deploy' from the staging directory to achieve this.
// So, if we find that the only deployable in the list is a directory, we just run the command
// from that directory without passing in any deployables to gcloud.
if (config.getDeployables().size() == 1 && Files.isDirectory(config.getDeployables().get(0))) {
workingDirectory = config.getDeployables().get(0);
} else {
for (Path deployable : config.getDeployables()) {
if (!Files.exists(deployable)) {
throw new IllegalArgumentException("Deployable " + deployable + " does not exist.");
}
arguments.add(deployable.toString());
}
}
arguments.addAll(GcloudArgs.get("bucket", config.getBucket()));
arguments.addAll(GcloudArgs.get("image-url", config.getImageUrl()));
arguments.addAll(GcloudArgs.get("promote", config.getPromote()));
arguments.addAll(GcloudArgs.get("server", config.getServer()));
arguments.addAll(GcloudArgs.get("stop-previous-version", config.getStopPreviousVersion()));
arguments.addAll(GcloudArgs.get("version", config.getVersion()));
arguments.addAll(GcloudArgs.get("project", config.getProjectId()));
try {
runner.run(arguments, workingDirectory);
} catch (ProcessHandlerException | IOException ex) {
throw new AppEngineException(ex);
}
}