Crazy IntelliJ with Play Integration

I am always a fun of Intellij until it throws at me a bomb when working with play framework.

This post is served at the purpose of solving (at least listing) some of the problems I encountered.

To reproduce:

  1. Play Console [p>]: play create myapp with Java by `play new [a project name]`
  2. Import play project using IntelliJ through play console by `idea with-sources=yes` and then import from intelliJ
  3. Follow the “todo” play tutorial

Problem List:

    • “cannot resolve symbol” for reverse routing: As in return redirect(routes.Application.tasks());. It is related to the fact that part of folder target, i.e. target/scala-2.10/src_managed (some scala code compiled by play compile) is not included as the source. So do “play compile” before importing into IntelliJ, and IntelliJ will notify you that

You have useless source roots which may corrupt resolve for play 2 framework in your project. Don’t delete but ignore the warnning.

Execute the following steps to update your dependencies [Solution provided in Github]:

    1. Run the update task from your play console
    2. Remove the .idea_modules and .idea/libraries directories
    3. Run the idea with-sources=yes command in the play console
  • “Cannot find Tools | Play with Playframework”: for Play 2.0 Support with version 0.36.431, the play console is not seen under tools, but accessible from context menu of play-based modules like controller application, by Run Play 2 App after installing play 2 plugin.
  • When running test from intellij, an error the underlying test class is not found: check the folder test-classes, it is possible that the underlying test class never get compiled before running, so do test:compile without actual running the test. It is a bug reported here. So for now, do play>test and then run test. — Unsolved. Relative background of compiler process
  • “cannot resolve symbol” for reverse routing in “index.scala.html”: @form(routes.Application.newTask()): simply add class_managed to the class path.
  • to run test when accessing db is needed: put it with in a fakeApplication() and Runnable. Refer here
  • type mismatch @inputText(taskForm("label"))Unsolved

Working on play 2.3.0 with IntelliJ

Install plugin, scala, Play 2.0 support, SBT(optional)

activator> compile > test:compile > idea withsources=yes

open build.sbt > IntelliJ asks me to associate this build.sbt with project, do import

change IDE language levels if necessary.

Check IDE preference for play, sbt, scala.

Run a JUnit method test by IDE; Debug with Play 2 better than activator -jvm-debug 9999 run.

IDE will automatically create root and root-build in project modules.

NOTE: 2.10.4 is used instead of scalaVersion specified in build.sbt (Unsolved)

Install https://github.com/jrudolph/sbt-dependency-graph following the readme ‘s two steps, and within play run the tasks.

Warning: Class path contains multiple SLF4J bindings. slf4j-log4j12 conflicts with logback. Use dependency-graph to identify who is using log4j.

Advertisements

One thought on “Crazy IntelliJ with Play Integration

  1. It’s nearly impossible to find educated people in this particular subject, however, you seem like you know
    what you’re talking about! Thanks

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: