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

后端 未结 3 1496
名媛妹妹
名媛妹妹 2021-02-09 09:23

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

plugins {
  id \'play\'
  id \'idea\'
}

reposit         


        
3条回答
  •  故里飘歌
    2021-02-09 10:06

    First of all you have to change your project according to gradle play plugins. here is the links, how to change your sbt project to gradle and make sure that you can execute all the necessary commands(build, clean, runPlayBinary, etc) from command prompt or terminal. When you are able to build successfully then you can import in Intellj IDE. Here is the steps you have to follow. Add idea plugins and following config for idea source configuration in build.gradle file.

    plugins {
         ....
        id 'idea'
    }
    ..
    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]]
         }
    }
    ...
    
    • Type "./gradlew idea" to generate idea's necessary project files
    • Open the project in intellj(Don't import)
    • Setup sdk(java) from project structure
    • In IDE at the bottom, you will see message like "Unlinked Gradle project? Import Gradle project, this will also enable Gradle Tool Window. Don't want to see the message for the project again: press here."
      • click on this message an enable gradle fort this project and setup gradle home and JVM(not project jvm) for gradle

    To Run(Run config)

    • Open run configuration window
    • Click on(+) and Select Gradle
    • Name: as you need
    • Gradle project: your root project or location of your root project
    • Tasks: runPlayBinary

    Go to intellj preference

    • Go to [Build, Execution and Deployment] section
    • Select build tool as gradle
    • Set "Service diretory path" ex: "/Users/.../gradle/gradle-4.10.2"
    • uncheck "offline work"`

    Tested with Grade 4.10.2, IntelliJ IDEA 2018.3.2 (Ultimate Edition) snd Play 2.5.2

提交回复
热议问题