Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Seeking advice: combined usage of Gretty with IntelliJ #435

Open
ggalmazor opened this issue Sep 12, 2018 · 0 comments
Open

Seeking advice: combined usage of Gretty with IntelliJ #435

ggalmazor opened this issue Sep 12, 2018 · 0 comments

Comments

@ggalmazor
Copy link

ggalmazor commented Sep 12, 2018

Hi! I'm kind of stuck between Gretty and IntelliJ, trying to figure out how to proceed :)

I work with IntelliJ and I maintain a project that uses Gretty for development purposes. Up until recently, I've been using this workaround to launch Gretty and a debug session in one click, but now that workaround is not viable anymore.

Starting with IntelliJ 2018, the init script it creates to launch Gradle tasks can't be parsed to get the JVM args that IntelliJ injects to get the debugging session work. This is an example of such an init script taken from an IntelliJ Ultimate v2018.2:

//-- Generated by org.jetbrains.plugins.gradle.service.project.BaseGradleProjectResolverExtension
initscript {
  dependencies {
    classpath files("/home/guillermo/.local/share/JetBrains/Toolbox/apps/IDEA-U/ch-0/182.4129.33/lib/external-system-rt.jar")
  }
}
gradle.taskGraph.beforeTask { Task task ->
 if (task instanceof org.gradle.api.tasks.testing.Test) {
  task.maxParallelForks = 1
  task.forkEvery = 0
 }
 if (task instanceof JavaForkOptions) {
  def jvmArgs = task.jvmArgs.findAll{!it?.startsWith('-agentlib:jdwp') && !it?.startsWith('-Xrunjdwp')}
  jvmArgs << com.intellij.openapi.externalSystem.rt.execution.ForkedDebuggerHelper.setupDebugger(task.path, 44701)
  task.jvmArgs = jvmArgs
 }
}
gradle.taskGraph.afterTask { Task task ->
    if (task instanceof JavaForkOptions) {
        com.intellij.openapi.externalSystem.rt.execution.ForkedDebuggerHelper.processFinished(task.path, 44701)
    }
}
//
  • Notice how it checks if the task extends JavaForkOptions to inject the output of the ForkedDebuggerHelper.setupDebugger call.

  • This ForkedDebuggerHelper builds a JVM args string like this: -agentlib:jdwp=transport=dt_socket,server=n,suspend=y,address=12345, which links the gradle task with the debugger session IntelliJ has set up.

Since Gretty tasks appRunWar, etc. don't implement JavaForkOptions, it is impossible to get a debugging session without recurring to other tasks like appRunWarDebug and starting a remote debug session.

It's great that we can start a remote debugging session, but I wonder if all app* tasks could implement JavaForkOptions like other standard Gradle tasks. This would be very useful for people like me, that work with IntelliJ.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant