My goal is to develop a Gradle
script that starts my Wildfly before the tests start running, and stop it after the tests complete, this way, Selenium tests can run.
To achieve this goal, I've decided to do the following at my build.gradle
:
Before the test (test.doFirst)
- Check if
JBOSS_HOME
environment variable exists; If it exists, I run the following to start my Wildfly:
ext.jbossHome = System.getenv('JBOSS_HOME') ext.isWildflyAvailable = (jbossHome != null) task startWildfly(type:Exec) { if (!isWildflyAvailable) { return; } println 'Starting Wildfly...' println 'JBOSS_HOME: ' + jbossHome workingDir = file(jbossHome + '\\bin') commandLine = ['cmd', '/C', 'standalone.bat'] } test.doFirst { startWildfly.execute() } // Ommited logic for stopping Wildfly
My Wildfly starts as I can read the log on console, but after it's startup, Gradle stuck on it and never proceed with the rest of the build.
Trying to avoid that, I appended an &
at the end of the command line, as I would do if I were starting my server manually on console, but Gradle started to raise erros, in both attempts:
commandLine = ['cmd', '/C', 'standalone.bat &']
commandLine = ['cmd', '/C', 'standalone.bat', '&&']
After some googling, I found something about running the commandLine on a different thread, but, I will lost track of the process and won't be able to know when my Wildfly started.
Is there another alternative?