in app-gradle-plugin/src/main/java/com/google/cloud/tools/gradle/appengine/appyaml/AppEngineAppYamlPlugin.java [65:125]
private void configureExtensions() {
// create the app.yaml staging extension and set defaults.
stageExtension = appengineExtension.getStage();
File defaultStagedAppDir = new File(project.getBuildDir(), STAGED_APP_DIR_NAME);
stageExtension.setStagingDirectory(defaultStagedAppDir);
stageExtension.setAppEngineDirectory(new File(project.getProjectDir(), "src/main/appengine"));
File dockerOptionalDir = new File(project.getProjectDir(), "src/main/docker");
if (dockerOptionalDir.exists()) {
// only set the docker directory if we find it.
stageExtension.setDockerDirectory(dockerOptionalDir);
}
// tools extension required to initialize cloudSdkOperations
final ToolsExtension tools = appengineExtension.getTools();
project.afterEvaluate(
project -> {
// create the sdk builder factory after we know the location of the sdk
try {
new CloudSdkOperations(tools.getCloudSdkHome(), null, tools.getVerbosity());
} catch (CloudSdkNotFoundException ex) {
// this should be caught in AppEngineCorePluginConfig before it can ever reach here.
throw new GradleException("Could not find CloudSDK: ", ex);
}
// we can only set the default location of "archive" after project evaluation (callback)
if (stageExtension.getArtifact() == null) {
if (project.getPlugins().hasPlugin(WarPlugin.class)) {
War war = (War) project.getProperties().get(WarPlugin.WAR_TASK_NAME);
stageExtension.setArtifact(GradleCompatibility.getArchiveFile(war));
} else if (project.getPlugins().hasPlugin(JavaPlugin.class)) {
Jar jar = (Jar) project.getProperties().get(JavaPlugin.JAR_TASK_NAME);
stageExtension.setArtifact(GradleCompatibility.getArchiveFile(jar));
} else {
throw new GradleException("Could not find JAR or WAR configuration");
}
}
// obtain deploy extension set defaults
DeployExtension deploy = appengineExtension.getDeploy();
// grab default project configuration from staging default
if (deploy.getAppEngineDirectory() == null) {
deploy.setAppEngineDirectory(stageExtension.getAppEngineDirectory());
}
DeployAllTask deployAllTask =
(DeployAllTask)
project
.getTasks()
.getByName(AppEngineCorePluginConfiguration.DEPLOY_ALL_TASK_NAME);
deployAllTask.setStageDirectory(stageExtension.getStagingDirectory());
deployAllTask.setDeployExtension(deploy);
DeployTask deployTask =
(DeployTask)
project.getTasks().getByName(AppEngineCorePluginConfiguration.DEPLOY_TASK_NAME);
deployTask.setDeployConfig(deploy);
deployTask.setAppYaml(stageExtension.getStagingDirectory().toPath().resolve("app.yaml"));
});
}