GoogleCloudPlatform / app-gradle-plugin

The library has moved to https://github.com/GoogleCloudPlatform/appengine-plugins/tree/main/app-gradle-plugin
Apache License 2.0
153 stars 40 forks source link

Plugin detection doesn't support overridden web directory #403

Closed angryziber closed 3 years ago

angryziber commented 3 years ago

It seems it looks for src/main/webapp, however war plugins supports overriding the location with:

webAppDirName = 'web'

It confuses the plugin and appengine-web.xml is not detected. By default, the yml version is selected, which doesn't have the appengineRun taks that is referenced in the documentation.

Workaround: specify the xml plugin explicitly: apply plugin: 'com.google.cloud.tools.appengine-appenginewebxml'

elefeint commented 3 years ago

It's interesting that this does not work. The code is actually trying to ask Gradle for the location of webAppDirName, but WarPluginConvention insists that the path is the default src/main/webapp.

Thank you for providing the workaround.

loosebazooka commented 3 years ago

Right, so this is an artifact of this plugin being originally written to do too much. The plugin is doing best effort to detect if there is an appengine-web.xml, however this detection happens before projects are configured. See configuration phases: https://docs.gradle.org/current/userguide/build_lifecycle.html#sec:build_phases

We can't see the custom webAppDirName because it is not set when we are trying to read the value (before project's are configured, and user configuration is loaded). We can't use the project.afterEvaluate{} block to make sure the variable is set, because it would be too late (after project configuration) to apply either the correct plugin (appenginewebxml or appyaml).

elefeint commented 3 years ago

Thanks, @loosebazooka ! I'll document this limitation.