IntelliJ + Play 2 integration

The Gradle IDEA plugin doesn’t seem to know how to handle Play Framework apps yet (as of Gradle 2.8).

In order to prevent IDEA from going fireball red everywhere when developing on Play I had to add this to my build.gradle file:

apply plugin: "idea"

idea {
  module {
    sourceDirs += file("app")
    testSourceDirs += file("test")
    scopes.COMPILE = [plus: [], minus: []]
    scopes.RUNTIME = [plus: [configurations.playRun], minus: []]
    scopes.TEST = [plus: [configurations.playTest], minus: [configurations.playRun]]

It’d be cool if the Gradle Play plugin could handle this automatically, or at least put this in the Play Documentation


1 Like

Thats all? I have added that to my code but it still “can’t resolve symbol …” :frowning:

You’ll have to have the standard Play directory structure.

gradle cleanIdea idea

is assumed as well.

This is Gradle 2.8, Play 2.3.x and Java 8

1 Like

I have tried with Play 2.4.3 and 2.3.10, Gradle 2.8-RC2 and java 1.8-20 and IntelliJ 14 Ultimate. IntelliJ still can’t resolve symbols and everything is red. This is my build.gradle.

Maybe you done something more?

Ok. I tried again and now this working!

gradlew cleanIdea
gradelw idea
gradlew ideaModule

Thanks for that! :smile:

1 Like

Glad it worked out :+1:

I’ve found it helpful to mark the compile/test resources and generated sources as well.

idea.module {
    // Source directories
    sourceDirs += file('app')
    testSourceDirs += file('test')

    // Generated sources
    def generated = [
    generated.each { src ->
        sourceDirs += src
        generatedSourceDirs += src

    // Output directories
    outputDir = file("$buildDir/playBinary/classes")
    testOutputDir = file("$buildDir/playBinary/testClasses")

    // Excluded dirs
    excludeDirs -= buildDir
    excludeDirs += [

    // Dependencies
    scopes.COMPILE = [ 'plus' : [ ] ]
    scopes.TEST = [ 'plus' : [ configurations.playTest ] ]

    iml.withXml { provider ->
        def content = provider.node.component.content.first()

        // Resources
        def confUrl = 'file://$MODULE_DIR$/conf'
        def confAttrs = content.find { it.@url == confUrl }?.attributes()
        if (confAttrs) {
            confAttrs.type = 'java-resource'
        } else {
            content.appendNode('sourceFolder', [url: confUrl, type: 'java-resource'])

        // Test resources
        def testResourcesUrl = 'file://$MODULE_DIR$/test/resources'
        def testResourcesAttrs = content.find { it.@url == testResourcesUrl }?.attributes()
        if (testResourcesAttrs) {
            testResourcesAttrs.type = 'java-test-resource'
        } else {
            content.appendNode('sourceFolder', [url: testResourcesUrl, type: 'java-resource'])

Admittedly, the code for marking resources is ugly. I’m all ears for improvements.

I cant find anything about evolutions working with play plugin :frowning: Does it works for you? What dependencies I need to add? I think have tried everything(play 2.4.3 and 2.3.10 with playEbean, play java ebean and avaje ebeanorm) and it still doesnt work.

There’s an outstanding pull request for the Gradle Play plugin to package resources (including evolution scripts) correctly.

Thanks!! Can’t wait it will be released! Btw. What ebean plugin in dependency you are using? I found this … But

play ‘’

  • model class nit fiund exception
    play ‘’
  • when running model enhancement exception
    play ‘org.avaje.ebeanorm:avaje-ebeanorm:6.9.1’
  • compiling but not evolution

I have build your pull request. But now I see there is no evolution file generating at all… Does it work for you?

Sorry, I’m not using ebean.

You need to write your own evolution files and place them in the right directory.

Ok, thanks a lot! :smile:

This works like charm for me. Thanks, Eric
Just curious how/where did you figure it out - I am unable to find any other reference/documents on this
-Chris L

1 Like

Chris, IIRC I figured it out by looking at the XML under the .idea/ directory and cross-referenced that with a bit of the Gradle source code. Wasn’t as easy as we’d like.

Hey guys,

Has anyone else had success with this approach and IntelliJ 16? I’ve followed everything here and my IntelliJ 16 isn’t even recognizing the external libraries besides Java 1.8. Things seem totally broken with the IDE.


I can confirm that the above works in IntelliJ 15 but not in the current 2016.1 or any versions above 15, any help would be appreciated.

It looks like IDEA 16 splits projects into several modules that are not affected by idea.module, I think? I fixed the highlighting issue by going into Build, Execution & Deployment > Build Tools > Gradle from Idea’s Settings dialog and unchecking “Create separate module per source set”. Would there be a way to target a particular module with the idea plugin?

1 Like

Greetings guys! Any everyone who have have success experience of generate idea project using gradle?
Just I’m spend a little bit time trying fix it. After generated idea project and opened it, intellijIdea don’t see gradle’s dependencies. Could someone help me please?

So, In my module .iml file there are orderEntry nodes with correct absolute path:

<orderEntry type="module-library">
      <root url="jar:///home/user/.gradle/caches/modules-2/files-2.1/!/"/>
      <root url="jar:///home/user/.gradle/caches/modules-2/files-2.1/!/"/>
<orderEntry type="module-library">
      <root url="jar:///home/user/.gradle/caches/modules-2/files-2.1/org.postgresql/postgresql/9.4-1204-jdbc42/aae989d89b2f9b10900044d85881e3a65137b1a7/postgresql-9.4-1204-jdbc42.jar!/"/>
      <root url="jar:///home/user/.gradle/caches/modules-2/files-2.1/org.postgresql/postgresql/9.4-1204-jdbc42/9519b3d8569209b31a27a99f9faecaff2c97efbd/postgresql-9.4-1204-jdbc42-sources.jar!/"/>

Why Intellij Idea don’t see these dependencies? I cannot work, because of error. Could some one help me please?

Thanks! It’s working well for me after I wasted of time (5 days)