Can't build the same Play code with SBT and Gradle


#1

Hi all,
I have issues with moving from SBT to Gradle. After a few tests, here is the smallest issue I can describe. I believe it is the core issue.

Here is my issue :

Building it with SBT works like a charm, but fails with Gradle.

object getHeader is not a member of package play.api.mvc.request

I had a look in an IDE. With Gradle, as mentioned above, “@request” returns a play.api.mvc.request whereas, with SBT, I see a “Http.Context.Explicit” coming from “play.mvc” package.

Any insight ? Thanks a lot


(Marcos Pereira) #2

Hey @Utundu,

Better if you can create a reproducer. But it looks like there is a problem with the default imports. I can see the hello world example is wrong:

https://github.com/playframework/play-java-hello-world-tutorial/blob/091d67252e5a29e405aa6c3a1db6a5fcbd4ced72/build.gradle#L17

For Java projects, this needs to be:

// Notice it is using `JAVA` instead of `SCALA`.
defaultImports = TwirlImports.JAVA

Best.


#3
// Notice it is using `JAVA` instead of `SCALA`.
defaultImports = TwirlImports.JAVA

Working great !

Thanks a million !