systemProperty set on root and sub project OK on cmd line, missing in Intellij Idea?

When I run unit tests on command line my property is set and my tests fine the cacerts file. When I run unit test within intellij my property is not set and my tests fail.

Any idea why idea doesn’t pick up this property and what I need to do to help it? Do I need to use the idea plugin?

Thanks

Peter

Parent

configure(allprojects) { project ->
...
    test {
        systemProperty "javax.net.ssl.trustStore","${rootProject.projectDir}/my.cacerts"
    }

Child (initially didn’t define trustStore prop and then added - still fails)

...
    test {
        systemProperty "javax.net.ssl.trustStore","${rootProject.projectDir}/my.cacerts"
    }

This information is not transferred from Gradle to IDEA (it is not part of the project model that is exposed to IDEA).

If you use idea plugin you can customize how projects files are generated. There is a code that can help you in https://github.com/gradle/gradle/blob/master/gradle/idea.gradle#L232 - when gradle project is imported it creates some run configuration with properties needed to run tests.

Hi Radim, thanks for the help. I used your techniques and those found here to craft a solution. https://gist.github.com/stephanos/8645809

Here’s the solution adapted from Radmin and Stephanos’ examples

configure(allprojects) { project ->
apply plugin: "idea"
...
  rootProject.idea.workspace.iws.withXml { xmlFile ->
    def runManager = xmlFile.asNode().component.find { it.@name == 'RunManager' }
          def jvmTestFlags= """
    -Djavax.net.ssl.trustStore=${rootProject.projectDir}/my.cacerts
    -ea
    """.split().toList()
      def junitDefaults = runManager.configuration.find { it.@default == 'true' && it.@type == 'JUnit' }
    junitDefaults.option.find { it.@name == 'VM_PARAMETERS' }.replaceNode {
      option(name: 'VM_PARAMETERS', value: jvmTestFlags.join(" "))
    }
       }

The result is a set of project files and most importantly a workspace file which defines the defaults for Junit execution with my cacerts param in place.