webjars / webjars-play

MIT License
80 stars 34 forks source link

[Request] Support for gradle play in 2.6.x release #81

Open Munzey opened 6 years ago

Munzey commented 6 years ago

Hi,

since the changes in this release: https://github.com/webjars/webjars-play/pull/71 , If I create a play 2.6.x project (where I inject components in the template and inject the template at the controller level) and compile and run with gradle I am getting this exception once I reload the page:

Caused by: com.google.inject.ProvisionException: Unable to provision

followed by the errors "Could not find a suitable constructor..." in any controller which has a template that injects org.webjars.play.WebJarsUtil. The app runs fine when I build with sbt.

In previous projects using play 2.5.x + gradle + webjars-play (where I injected WebJarAssets at controller level), the project compiled and ran fine. The main discernible difference (from a user perspective anyway) is that the routes have changed:

i.e in a working play 2.5.x build I was using: GET /webjars/*file controllers.WebJarAssets.at(file)

in the current failing play 2.6.x build Im using: -> /webjars webjars.Routes

From a bit of googling it looks like using a split route file is something specific to the sbt play plugin: not sure if there is a way to mimic this with the current gradle play plugin: https://github.com/webjars/webjars-play/blob/master/build.sbt#L15

So I'm hoping you can help me out! A fix so that I can continue to use 2.6.x branch of play with latest webjars-play, or if supporting gradle is off the cards, could we have a documented workaround for this use case? Even if that just means adding some documentation to https://www.webjars.org/documentation#play2 (such as just extracting webjars to lib folder with task or plugin like https://github.com/ia-toki/gradle-play-webjars)

Thanks for the plugin!

Munzey commented 6 years ago

on switching to https://github.com/ia-toki/gradle-play-webjars, it seems on further digging that my issue is also related to gradle play plugin not supporting injecting templates (still getting guice provision exceptions, but works fine when not using @this in templates). Ill try find the correct place to open a discussion of this with gradle team

jamesward commented 6 years ago

I haven't ever used the Gradle Play stuff but this project is definitely dependent on the latest Twirl and Play Routes compiler sbt plugins. I'm sure that those could be replicated as Gradle Plugins but I'm not sure what the state is.