Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to debug Play 2 Application built with Gradle

There seems to be extensive documentation for debugging Play applications with IntelliJ IDEA, but they all assume that Play is built with SBT.

Debugging with Gradle should be as easy as:

  • Set some breakpoints
  • Run GRADLE_OPTS="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=9999" gradlew --no-daemon :runPlayBinary
  • Run an IntelliJ Remote Configuration that looks like this:

IntelliJ Remote Configuration

  • Hit http://localhost:9000 and do something interesting to cause a breakpoint to be hit

The problem I'm having is: the breakpoint is never hit, processing continues as normal. Technologies: Play 2.3.X, IDEA 14.1, Gradle 2.8, Scala 2.10

I must be missing something, what is it?

like image 318
Eric Wendelin Avatar asked Nov 20 '15 00:11

Eric Wendelin


Video Answer


2 Answers

Play 2.7, Java 8, Gradle combo required the following: run it with: gradle runPlay -Ddebug=true

play {
    injectedRoutesGenerator = true
    platform {
        playVersion = playV
        scalaVersion = scalaV
        javaVersion = javaV
    }
    if (System.getProperty("debug")) {
        def runPlayTask = tasks.findByName('runPlay')
        runPlayTask.forkOptions.jvmArgs = ['-Xdebug', '-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5005']
    }
}```
like image 70
Yonz Avatar answered Oct 01 '22 08:10

Yonz


Building on joao's answer, you can create a new task and use your remote configuration to connect to it:

task debugPlayBinary {
    doLast {
        def runPlayTask = tasks.findByName('runPlayBinary')
        runPlayTask.forkOptions.jvmArgs = ['-Xdebug', '-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005']
        runPlayTask.run()
    }
}

This allows runPlayBinary to remain untouched.

like image 24
Jacob Wallace Avatar answered Oct 01 '22 06:10

Jacob Wallace