Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make gradle / intellij / play framework work together?

Here is a Gradle build as advised here for using play web framework.

plugins {
  id 'play'
  id 'idea'
}

repositories {
  jcenter()
  maven {
    name "typesafe-maven-release"
    url "https://repo.typesafe.com/typesafe/maven-releases"
  }
  ivy {
    name "typesafe-ivy-release"
    url "https://repo.typesafe.com/typesafe/ivy-releases"
    layout "ivy"
  }
}

It works fine when building, launching etc... from command line but once the project is imported in intellij (idea's project files generated with gradle idea), dependencies (from the play plugin) don't show up in the project view/external libraries (even after having hit "refresh all gradle projects" in the gradle panel).

Thanks :)

PS: intellij 15.0.2 / gradle 2.6 / play plugin

enter image description here

like image 531
Aurelien Avatar asked Dec 25 '15 13:12

Aurelien


People also ask

How do I sync Gradle project in IntelliJ?

If you have some custom plugins that require you to import your project from the IntelliJ IDEA model, press Ctrl+Shift+A and search for the Project from Existing Sources action. In the dialog that opens, select a directory containing a Gradle project and click OK. IntelliJ IDEA opens and syncs the project in the IDE.


1 Answers

Answer found here. Apparently the gradle idea plugin needs to be told explicitely how to wire the dependencies.

To sum up :

  1. Create a typical play layout
  2. Add a build.gradle (as below)
  3. Type gradle idea to generate idea's project files
  4. Open the project in intellij

    plugins {
        id 'play'
        id 'idea'
    }
    
    repositories {
        jcenter()
        maven {
            name "typesafe-maven-release"
            url "https://repo.typesafe.com/typesafe/maven-releases"
        }
        ivy {
            name "typesafe-ivy-release"
            url "https://repo.typesafe.com/typesafe/ivy-releases"
            layout "ivy"
        }
    }  
    
    idea {
        module {
            sourceDirs += file("app")
            testSourceDirs += file("test")
            scopes.COMPILE = [plus: [configurations.play], minus: []]
            scopes.RUNTIME = [plus: [configurations.playRun], minus:[configurations.play]]
            scopes.TEST = [plus: [configurations.playTest], minus: [configurations.playRun]]
         }
    }
    

PS: tested with intellij 15.0.2 / gradle 2.10 / gradle play plugin

like image 76
Aurelien Avatar answered Oct 03 '22 08:10

Aurelien