Hey team, I am currently migrating a maven projec...
# community-support
a
Hey team, I am currently migrating a maven project to gradle but I am having one challenge. How would I set a system property after Gradle setting up the
org.gradle.test.worker
. So here is the Maven plugin
Copy code
<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-failsafe-plugin</artifactId>
    <configuration>
       ..........
       <systemPropertyVariables>
          <spring.data.mongodb.database>parties-${surefire.forkNumber}</spring.data.mongodb.database> 
       </systemPropertyVariables>
    </configuration>
</plugin>
My challenge is how to set the
spring.data.mongodb.database
system property and at the same time use the
org.gradle.test.worker
to set the value of this property, similar to what Maven is doing with the
surefire.forkNumber
I tried
systemProperty("spring.data.mongodb.database", "parties-${System.getProperty("org.gradle.test.worker")}")
in my test task but no luck. Is there a way to achieve that.
v
That property is set within the test worker process. The
systemProperty
call is evaluated in the daemon process, so there it is not set. If you want to use that property, you have to set the mongo property from within the test process somehow.
a
Hey @Vampire, that is true! What is the recommended way to set properties within the test process? Is there any hook that can be applied in the build script?
v
Nothing from Gradle side I'm aware of. You have to check with your test framework whether there is some way.
👍 1
a
Thanks @Vampire
👌 1