Closed sparhomenko closed 2 years ago
Yeah so appengineStage is not a copy task because we share that code across gradle/maven plugins, so using the copy task filtering isn't possible. Your best bet right now is to use a custom task like you said and point stage to that directory.
If you haven't already done this, there are some ways you can wire it in directly into your build
appengine.stage.appEngineDirectory = "${buildDir}/filteredAppEngineDir"
task filterAppEngineDir(type: Copy) {
from ("src/main/appengine") {
filter {
it.replaceAll("@@some-token@@", "custom-value")
}
}
// use closures for late evaluation
into {
project.appengine.stage.appEngineDirectory
}
}
// make sure stage calls this filtering guy first
appengineStage.dependsOn filterAppEngineDir
Then run:
./gradlew appengineStage
OR You can inject the params from the command line using project properties
appengine.stage.appEngineDirectory = "${buildDir}/filteredAppEngineDir"
task filterAppEngineDir(type: Copy) {
// add as input so that when changed it triggers a rebuild
inputs.property("customProperty", project.customProperty)
from ("src/main/appengine") {
filter {
it.replaceAll("@@some-token@@", project.customProperty)
}
}
// use closures for late evaluation
into {
project.appengine.stage.appEngineDirectory
}
}
// make sure stage calls this filtering guy first
appengineStage.dependsOn filterAppEngineDir
Then run:
./gradlew appengineStage -PcustomProperty=foobar
might be worth considering for the core library.
On Thu, May 11, 2017 at 3:16 PM, Appu Goundan notifications@github.com wrote:
Yeah so appengineStage is not a copy task because we share that code across gradle/maven plugins, so using the copy task filtering isn't possible. Your best bet right now is to use a custom task like you said and point stage to that directory.
If you haven't already done this, there are some ways you can wire it in directly into your build
appengine.stage.appEngineDirectory = "${buildDir}/filteredAppEngineDir"
task filterAppEngineDir(type: Copy) { from ("src/main/appengine") { filter { it.replaceAll("@@some-token@@", "custom-value") } } // use closures for late evaluation into { project.appengine.stage.appEngineDirectory } } // make sure stage calls this filtering guy first appengineStage.dependsOn filterAppEngineDir
Then run:
./gradlew appengineStage
OR You can inject the params from the command line using project properties
appengine.stage.appEngineDirectory = "${buildDir}/filteredAppEngineDir"
task filterAppEngineDir(type: Copy) { // add as input so that when changed it triggers a rebuild inputs.property("customProperty", project.customProperty)
from ("src/main/appengine") { filter { it.replaceAll("@@some-token@@", project.customProperty) } } // use closures for late evaluation into { project.appengine.stage.appEngineDirectory } } // make sure stage calls this filtering guy first appengineStage.dependsOn filterAppEngineDir
Then run:
./gradlew appengineStage -PcustomProperty=foobar
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/GoogleCloudPlatform/app-gradle-plugin/issues/135#issuecomment-300889902, or mute the thread https://github.com/notifications/unsubscribe-auth/AHf5HZHkLiIvuknHlKu2aTovz8gewlqcks5r416jgaJpZM4NXUUN .
@loosebazooka We are already filtering in a build task, but thanks for the advice, property as an input to trigger a rebuild is a useful improvement. I understand that having to support both Maven and Gradle makes it complicated, so feel free to close if you feel like the benefit is not worth the effort.
@sparhomenko would you be able to share how you did this? I'm trying to accomplish something similar at the moment (https://github.com/GoogleCloudPlatform/app-gradle-plugin/issues/195).
We are trying to use
appengine-gradle-plugin
for deploying a web app to GAE Flexible. The app is using Google Cloud Endpoints 2 and has this inapp.yaml
:These parameters differ on different environments (test and production):
name
needs to have the correct project ID, andconfig_id
needs to be set to the API version currently deployed to this particular environment. Both values are available in our Gradle build, butappengineStage
task does not perform Gradle filtering (properties substitution) when copying deployables fromappEngineDirectory
tostagingDirectory
.We can work this around by pre-filtering with a custom Gradle task into a custom
appEngineDirectory
. But seeing how Gretty provides filtering forsrc/main/webapp
it would be convenient to have the same capability here. It will likely be useful for other deployables, likeenv_variables
inapp.yaml
and URLs indispatch.yaml
.Any alternative suggestions are very welcome.