lucidsoftware / rules_twirl

Bazel rules for compiling Twirl templates
Apache License 2.0
3 stars 9 forks source link

NullPointerException when trying to build with rules_twirl #34

Open Srikrishna31 opened 3 years ago

Srikrishna31 commented 3 years ago

This issue is continuation of https://github.com/lucidsoftware/rules_twirl/issues/32 After upgrading the version, I have a new problem.

bazel build :App
INFO: Analyzed target //:App (0 packages loaded, 0 targets configured).
INFO: Found 1 target...
ERROR: /home/l-8296/github_projects/scala_play/app/BUILD:40:1: Compiling twirl template failed (Exit 1): compiler-cli failed: error executing command 
  (cd /home/l-8296/.cache/bazel/_bazel_l-8296/76d33ba2f8986abe556e65dc46b40a5c/execroot/__main__ && \
  exec env - \
  bazel-out/host/bin/external/io_bazel_rules_twirl/compiler-cli/compiler-cli @bazel-out/k8-fastbuild/bin/app/gen/twirl-templates/app/src/main/scala/views/main.html.scala-0.params)
Execution platform: @local_config_platform//:host
java.lang.NullPointerException
        at play.twirl.compiler.TwirlCompiler$.source2TemplateName(TwirlCompiler.scala:245)
        at play.twirl.compiler.TwirlCompiler$.generatedFileVirtual(TwirlCompiler.scala:229)
        at play.twirl.compiler.TwirlCompiler$.compileVirtual(TwirlCompiler.scala:185)
        at rulestwirl.twirl.CommandLineTwirlTemplateCompiler$.work(CommandLineTwirlTemplateCompiler.scala:64)
        at rulestwirl.twirl.CommandLineTwirlTemplateCompiler$.work(CommandLineTwirlTemplateCompiler.scala:9)
        at higherkindness.rules_scala.common.worker.WorkerMain.process$1(WorkerMain.scala:53)
        at higherkindness.rules_scala.common.worker.WorkerMain.main(WorkerMain.scala:73)
        at higherkindness.rules_scala.common.worker.WorkerMain.main$(WorkerMain.scala:22)
        at rulestwirl.twirl.CommandLineTwirlTemplateCompiler$.main(CommandLineTwirlTemplateCompiler.scala:9)
        at rulestwirl.twirl.CommandLineTwirlTemplateCompiler.main(CommandLineTwirlTemplateCompiler.scala)
Target //:App failed to build
INFO: Elapsed time: 10.974s, Critical Path: 10.29s
INFO: 15 processes: 14 linux-sandbox, 1 worker.
FAILED: Build did NOT complete successfully

My index.scala.html and main.scala.html are very simple files. main.scala.html doesn't take any parameters, and that might be causing a NullPointerException? It's the same PR: Srikrishna31/scala_play#9 Thanks, Krishna Addepalli

SrodriguezO commented 3 years ago

Hey @Srikrishna31, the issue is that you're specifying an incorrect source_directory; the source directory must point to where the templates live. In your case, this should be src/main/scala/views

Srikrishna31 commented 3 years ago

Hi @SrodriguezO , thank you for pointing that out. Changing the source_directory fixed the issue. I think the documentation needs to be updated to reflect this fact. It is not clear from reading it.