Sunday, June 15, 2014

Module Naming Conventions for Play 2.2 and IntelliJ 13.1

So today I noticed something strange with +IntelliJ IDEA and the +Play Framework 's build.sbt file.

Say you create a project using the following method:


1. Create a new app using the play new command (testapp)
2. Naming the application (Test_Application)
3. Selecting the Simple Java application template

When you open the project with IntelliJ and look at the build.sbt file, this is what you see:


This means that the project ins't properly resolving within IntelliJ. This can lead to false error flags and almost zero code assist support when building your controllers and whatnot. Now your Play application will still run as normal, but at this point you might as well use Notepad to do your code editing - IntelliJ will be almost useless to you.

The fix, however is simple. Simply rename the project's build module to the same name as the main project module and attach "-build" to the end of it. This can be achieved by going to File > Project structure... > Modules. Mine show up like this;


From here what I will do is change the build module's name to "testapp-build", 



click OK and when I look at my build.sbt file again, everything should resolve properly and my code assist should work splendidly:


Well, it's almost fixed. Restructure the file as follows to make sure the library dependencies resolve properly as well:


To avoid all this tra-la-la, I would advise skipping the step to name your application when creating the application from the command line. 

Happy coding!

Bug affects:
Play 2.2.3
IntelliJ 13.1.3 Build IU-135.909
Play plugin 0.38.437


No comments: