Cannot debug groovy file when run with gradle task in IntelliJ IDE

Hi All,

I am trying to run groovy/gradle project in IntelliJ IDEA. The problem is, when run with gradle task not able to debug groovy file via IDEA.

task cucumber(dependsOn: [assemble, encryptionPropertyForTest]) << {

javaexec {

main = ‘cucumber.api.cli.Main’

classpath = configurations.cucumberRuntime

def arguments = []

if(rootProject.hasProperty(“tags”)) {

tags.tokenize().each { tag ->

arguments.add(’–tags’)

arguments.add(tag)

}

}

args = arguments + [

‘–tags’, ‘~@ignore’,

‘–format’, ‘junit:build/test-reports/all.xml’,

‘–format’, ‘html:build/test-reports/html/’,

‘–format’, ‘json:build/test-reports/cucumber-report.json’,

‘–format’, ‘pretty’,

‘–glue’, ‘src/test/resources/features’,

‘src/test/resources/features’]

systemProperties = config

} }

task encryptionPropertyForTest() << {

loadEnvironmentConfiguration()

println System.properties[‘os.name’]

if (System.properties[‘os.name’].contains(“Windows”)) {

copy(“src/test/resources/encryption/$env/document_security_windows.properties”, “document_security.properties”)

copy(“src/test/resources/encryption/$env/truststore.jks”, “truststore.jks”)

}

else {

copy(“src/test/resources/encryption/$env/document_security.properties”, “document_security.properties”)

println “Copied unix 1”

copy(“src/test/resources/encryption/$env/truststore.jks”, “truststore.jks”)

} }

Further where can I see default task like “test”. because I cannot see them under build.gradle file in the project. I was able to see the in intelliJ under “Tools Window” >>> “Gradle” menu but not the code

To debug code run in this way, you’d have to set the usual JVM debug args via ‘javaexec.jvmArgs’ (with ‘suspend=y’), execute the task, and then start an external debugger in IntelliJ. Don’t understand your second question.

Hi Peter,

In “JAVA OPTS” and “GRADLE OPTS” are we set same arguments? If not where can I check them.

Because I am using ‘GRADLE OPTS= -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005’. So if I set JAVA OPTS not sure what would be the value

My second question may be dumb one. My curiosity was some projects I can run cucumber test with following command >gradle test. But I cannot find see this ‘test’ task within build.gradle