[Question] Suppress twirl template deprecation method warnings

47 views
Skip to first unread message

Vitalii Stein

unread,
Jun 21, 2017, 6:48:20 AM6/21/17
to Play Framework

Hi all!


After migration from play 2.4 to 2.5, we faced with deprecation warnings inside twirl templates: ...web/templates/index.scala.html:2: method get in object Messages is deprecated: see corresponding Javadoc for more information. [warn] <a href="@routes.Auth.login()">@Messages.get("login") </a> [warn] 1501 warnings found


-deprecation flag inside scalaOptions works fine for classes, but looks like it doesn't affect *.scala.html files.


Twirl wiki says about withtwirlRecompilationLogger TaskKey (twirlRecompilationLogger = TaskKey[(File, File) => Unit]), but play 2.5 doesn't contain it (play.twirl.sbt.Import.TwirlKeys._).


Any ideas how to suppress deprecation warnings inside templates? 


Thanks


Will Sargent

unread,
Jun 21, 2017, 12:45:18 PM6/21/17
to play-fr...@googlegroups.com

--
Will Sargent
Engineer, Lightbend, Inc.


--
You received this message because you are subscribed to the Google Groups "Play Framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to play-framework+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/play-framework/e159865c-d5e1-4785-aba3-7bd466f75354%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Vitalii Stein

unread,
Jun 21, 2017, 8:31:42 PM6/21/17
to Play Framework
Thank you for your answer. 
And I'm sorry for my typo, I meant scalacOptions instead of scalaOptions.

My settings look next:
   scalacOptions ++= Seq(
      "-feature",
      "-deprecation",
      "-unchecked",
      "-language:reflectiveCalls",
      "-language:postfixOps",
      "-language:implicitConversions"
   ),

I supposed that flags don't work at all. 
As an experiment, I tried to add -Xfatal-warnings and it failed the build - looks like they are fine and scalac uses them. 

Also, I have successfully reproduced it using next project sample from documentation: https://github.com/adrianhurt/play-multidomain-seed

With next changes (import Messages and use deprecated method get):
diff --git a/modules/web/app/views/web/index.scala.html b/modules/web/app/views/web/index.scala.html
index 43773e5..1e81429 100644
--- a/modules/web/app/views/web/index.scala.html
+++ b/modules/web/app/views/web/index.scala.html
@@ -1,6 +1,7 @@
 @(message: String, computers: List[Computer], configThisFile: String)(implicit messages: Messages)
 
 @import controllers.web.routes
+@import play.i18n.{Messages => MessagesDep}
 
 @theModals = {
  <div class="modal fade" id="myWebModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
@@ -12,6 +13,7 @@
       </div>
       <div class="modal-body">
         <p>@Messages("modal.text")</p>
+        <p>@MessagesDep.get("modal.text")</p>
       </div>
       <div class="modal-footer">
         <button type="button" class="btn btn-default" data-dismiss="modal">@Messages("modal.close")</button>
@@ -59,4 +61,4 @@
  </tr>
  }
  </table>
-}
\ No newline at end of file
+}

I got next warning:
/play-multidomain-seed/modules/web/app/views/web/index.scala.html:17: method get in object Messages is deprecated: see corresponding Javadoc for more information.
[warn] <p>@MessagesDep.get("modal.text")</p>

scalacOptions in project sample(play-multidomain-seed) uses -deprecation flag as well (project/Common.scala):
scalacOptions ++= Seq("-feature", "-deprecation", "-unchecked", "-language:reflectiveCalls", "-language:postfixOps", "-language:implicitConversions"),

Could you please check that?

Best,
Vitalii

среда, 21 июня 2017 г., 19:45:18 UTC+3 пользователь Will Sargent написал:

--
Will Sargent
Engineer, Lightbend, Inc.


On Wed, Jun 21, 2017 at 3:13 AM, Vitalii Stein <unkno...@gmail.com> wrote:

Hi all!


After migration from play 2.4 to 2.5, we faced with deprecation warnings inside twirl templates: ...web/templates/index.scala.html:2: method get in object Messages is deprecated: see corresponding Javadoc for more information. [warn] <a href="@routes.Auth.login()">@Messages.get("login") </a> [warn] 1501 warnings found


-deprecation flag inside scalaOptions works fine for classes, but looks like it doesn't affect *.scala.html files.


Twirl wiki says about withtwirlRecompilationLogger TaskKey (twirlRecompilationLogger = TaskKey[(File, File) => Unit]), but play 2.5 doesn't contain it (play.twirl.sbt.Import.TwirlKeys._).


Any ideas how to suppress deprecation warnings inside templates? 


Thanks


--
You received this message because you are subscribed to the Google Groups "Play Framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to play-framewor...@googlegroups.com.

Greg Methvin

unread,
Jun 21, 2017, 9:00:34 PM6/21/17
to play-framework
From what I can see the -deprecation flag is being respected. -deprecation is equivalent to -deprecation:true, which turns on deprecation warnings. You would use -deprecation:false to turn off deprecation warnings.




To unsubscribe from this group and stop receiving emails from it, send an email to play-framework+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/play-framework/b449ee34-a27a-48d3-ba6c-5daf6f797133%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Greg Methvin
Tech Lead - Play Framework

Vitalii Stein

unread,
Jun 22, 2017, 3:52:11 AM6/22/17
to Play Framework
Thank you for your answer. `-deprecation:false` works! 

I recompiled project with/without `-deprecation` flag and got the same messages: `method get in object Messages is deprecated: see corresponding Javadoc for more information.`.
That is why I decided to ask here.. Looks like current flag is redundant in scalacOptions, because it's true as default, but it's another story.

BTW, thank you for help. :)

Best,
Vitalii


четверг, 22 июня 2017 г., 4:00:34 UTC+3 пользователь Greg Methvin написал:
Reply all
Reply to author
Forward
0 new messages