0

I have done the following:

  1. Created a new project with the activator command: activator new play-java
  2. Imported the project to Idea community edition 15, following the description here: https://www.playframework.com/documentation/2.4.x/IDE

I cannot build the project though, as the packages play.* org.junit etc. are not recognized/imported in idea. I can execute "activator run" without problems though. If I execute "activator idea", I get the following error message:

[error] Not a valid command: idea (similar: eval, alias)
[error] Not a valid project ID: idea
[error] Expected ':' (if selecting a configuration)
[error] Not a valid key: idea (similar: clean)
[error] idea
[error]     ^

When I import the websocket example defined here https://devcenter.heroku.com/articles/play-java-websockets I can succesfully build in Idea without any issues.

Lull
  • 365
  • 3
  • 14

1 Answers1

1

idea command is added by a plugin, which is not installed out of the box. Depending on your internet connection, IDEA can take some time to resolve all dependencies and made them available in your project. See at the progress bar (at the bottom) if the resolver already finished. Also, check if the play-java template adds all the dependencies you are expecting to see.

Moreover, these discussions can be useful to you:

  1. How to create SBT project with IntelliJ Idea?
  2. Play with Activator Issue on IntelliJ Idea 14
  3. IntelliJ and Play framework

You can add the plugin yourself, as described here:

https://github.com/mpeltonen/sbt-idea

You just need to add the following line to your project/plugins.sbt file:

addSbtPlugin("com.github.mpeltonen" % "sbt-idea" % "1.6.0")

But keep in mind that this will not keep the IDEA project in sync with your SBT project. In other words, when you add a new dependency or change something else, you will need to manually run "idea" command again.

Community
  • 1
  • 1
marcospereira
  • 12,045
  • 3
  • 46
  • 52
  • Thanks, but a) The plugin is not installed. I do not think this is the case as the command worked for the websocket tutorial as mentioned. b) The template does not add all dependencies. The same dependencies are added for the websocket example, and I can compile the websocket example 1) I already followed the steps in this post, and this creates a project that does not compile, as e.g. junit and play packages are not recognized. 2) This post suggests "activator idea" command - and this is exactly the command that is not recognized c.f. my description. 3) My problem is not missing source files – Lull Feb 19 '16 at 16:48
  • The websockets examples you posted is using Play 2.2.0, which adds the idea plugin and then the "idea" command. 2.4 version does not adds the plugin. Anyway, I've added more information to the answer. – marcospereira Feb 19 '16 at 17:03
  • Ah ok, thanks for clarifying. I tried adding the dependency, and this lets me execute "gen-idea" but not "idea". Executing "gen-idea" still does not give a compilable project in Idea, after reloading the project. Any other ideas? – Lull Feb 19 '16 at 17:13
  • Ensure that you are using an updated version of IDEA Scala Plugin and trying again. What do you mean by "compilable project in IDEA"? – marcospereira Feb 19 '16 at 17:23
  • I'm using the 2.2.0 Scala plugin. By compilable in Idea, I mean that Idea can resolve e.g. play and junit packages/dependencies which it cannot currently. – Lull Feb 19 '16 at 17:25
  • More questions: are you importing as a SBT project? Are you checking auto-import option? Does IDEA shows any errors at "Event Log" panel? – marcospereira Feb 19 '16 at 17:29
  • Yes I am importing as SBT project, and checking auto-import. The event log says: SBT project import [warn] Multiple dependencies with the same organization/name but different versions. To avoid conflict, pick one version: Looks like it is an SBT issue: https://github.com/sbt/sbt/issues/1933 – Lull Feb 20 '16 at 11:47
  • I still have no idea how to create a new play framework project where dependencies are resolved properly in IntelliJ Idea - does anybody have a simple step-by-step description of this? – Lull Feb 20 '16 at 14:47
  • Does anybody else have some input - I cannot see why it should be this difficult to create a new project... I see others have the same issue: http://stackoverflow.com/questions/34048009/play-2-4-error-package-play-does-not-exist – Lull Mar 10 '16 at 09:34