-
Notifications
You must be signed in to change notification settings - Fork 40
Convert to static extension building #192
Changes from 4 commits
9db6cee
24b303d
e476498
3bd1cdc
eae69dc
5e6153c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,6 +22,7 @@ | |
import java.io.File; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
import javax.inject.Inject; | ||
import org.gradle.api.Project; | ||
|
||
/** Extension element to define Deployable configurations for App Engine. */ | ||
|
@@ -41,6 +42,7 @@ public class DeployExtension | |
private String version; | ||
private File appEngineDirectory; | ||
|
||
@Inject | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What does this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh yeah I accidentally left that in there, with new versions of gradle, if you created an extension from the root, gradle would ask you to inject the params instead of passing them in. |
||
public DeployExtension(Project gradleProject) { | ||
this.gradleProject = gradleProject; | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
/* | ||
* Copyright (c) 2018 Google Inc. All Right Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
*/ | ||
|
||
package com.google.cloud.tools.gradle.appengine.flexible; | ||
|
||
import com.google.cloud.tools.gradle.appengine.core.AppEngineCoreExtensionProperties; | ||
import com.google.cloud.tools.gradle.appengine.core.DeployExtension; | ||
import com.google.cloud.tools.gradle.appengine.core.ToolsExtension; | ||
import org.gradle.api.Action; | ||
import org.gradle.api.Project; | ||
import org.gradle.api.plugins.ExtensionAware; | ||
|
||
public class AppEngineFlexibleExtension implements AppEngineCoreExtensionProperties { | ||
private ToolsExtension tools; | ||
private DeployExtension deploy; | ||
private StageFlexibleExtension stage; | ||
|
||
/** Create nested configuration blocks as Extensions. */ | ||
public void createSubExtensions(Project project) { | ||
tools = ((ExtensionAware) this).getExtensions().create("tools", ToolsExtension.class, project); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Might be good to place |
||
deploy = | ||
((ExtensionAware) this).getExtensions().create("deploy", DeployExtension.class, project); | ||
stage = | ||
((ExtensionAware) this) | ||
.getExtensions() | ||
.create("stage", StageFlexibleExtension.class, project); | ||
} | ||
|
||
public void tools(Action<? super ToolsExtension> action) { | ||
action.execute(tools); | ||
} | ||
|
||
public void deploy(Action<? super DeployExtension> action) { | ||
action.execute(deploy); | ||
} | ||
|
||
public void stage(Action<? super StageFlexibleExtension> action) { | ||
action.execute(stage); | ||
} | ||
|
||
@Override | ||
public ToolsExtension getTools() { | ||
return tools; | ||
} | ||
|
||
@Override | ||
public DeployExtension getDeploy() { | ||
return deploy; | ||
} | ||
|
||
public StageFlexibleExtension getStage() { | ||
return stage; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,16 +17,14 @@ | |
|
||
package com.google.cloud.tools.gradle.appengine.flexible; | ||
|
||
import com.google.cloud.tools.gradle.appengine.core.AppEngineCorePlugin; | ||
import com.google.cloud.tools.gradle.appengine.core.AppEngineCorePluginConfiguration; | ||
import com.google.cloud.tools.gradle.appengine.core.DeployExtension; | ||
import com.google.cloud.tools.gradle.appengine.util.ExtensionUtil; | ||
import java.io.File; | ||
import org.gradle.api.Action; | ||
import org.gradle.api.GradleException; | ||
import org.gradle.api.Plugin; | ||
import org.gradle.api.Project; | ||
import org.gradle.api.plugins.BasePlugin; | ||
import org.gradle.api.plugins.ExtensionAware; | ||
import org.gradle.api.plugins.JavaPlugin; | ||
import org.gradle.api.plugins.WarPlugin; | ||
import org.gradle.api.tasks.bundling.Jar; | ||
|
@@ -42,27 +40,27 @@ public class AppEngineFlexiblePlugin implements Plugin<Project> { | |
public static final String STAGE_EXTENSION = "stage"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. STAGE_EXTENSION seems to be unused now. |
||
|
||
private Project project; | ||
private AppEngineFlexibleExtension appengineExtension; | ||
private StageFlexibleExtension stageExtension; | ||
|
||
@Override | ||
public void apply(Project project) { | ||
this.project = project; | ||
project.getPluginManager().apply(AppEngineCorePlugin.class); | ||
appengineExtension = | ||
project.getExtensions().create("appengine", AppEngineFlexibleExtension.class); | ||
appengineExtension.createSubExtensions(project); | ||
|
||
new AppEngineCorePluginConfiguration() | ||
.configureCoreProperties(project, appengineExtension, APP_ENGINE_FLEXIBLE_TASK_GROUP); | ||
|
||
configureExtensions(); | ||
createStageTask(); | ||
|
||
AppEngineCorePlugin.overrideCoreTasksGroup(project, APP_ENGINE_FLEXIBLE_TASK_GROUP); | ||
} | ||
|
||
private void configureExtensions() { | ||
// obtain extensions defined by core plugin. | ||
ExtensionAware appengine = | ||
new ExtensionUtil(project).get(AppEngineCorePlugin.APPENGINE_EXTENSION); | ||
|
||
// create the flexible stage extension and set defaults. | ||
stageExtension = | ||
appengine.getExtensions().create(STAGE_EXTENSION, StageFlexibleExtension.class, project); | ||
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")); | ||
|
@@ -73,7 +71,7 @@ private void configureExtensions() { | |
} | ||
|
||
// obtain deploy extension set defaults | ||
DeployExtension deploy = new ExtensionUtil(appengine).get(AppEngineCorePlugin.DEPLOY_EXTENSION); | ||
DeployExtension deploy = appengineExtension.getDeploy(); | ||
deploy.setDeployables(new File(defaultStagedAppDir, "app.yaml")); | ||
// grab default project configuration from staging default | ||
deploy.setAppEngineDirectory(stageExtension.getAppEngineDirectory()); | ||
|
@@ -122,6 +120,9 @@ public void execute(Project project) { | |
}); | ||
} | ||
}); | ||
project.getTasks().getByName(AppEngineCorePlugin.DEPLOY_TASK_NAME).dependsOn(stageTask); | ||
project | ||
.getTasks() | ||
.getByName(AppEngineCorePluginConfiguration.DEPLOY_TASK_NAME) | ||
.dependsOn(stageTask); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
APP_ENGINE_TASK_GROUP
seems to be unused now.