I figured out how to do this :
task executeLocalSmokeTest (type: Test, dependsOn:":uberJar") { //Note the colons for parent’s tasks.
def jettyProcess
useJUnit {
includeCategories = [‘TestCategories$SmokeTest’] as Set
}
testLogging {
exceptionFormat “full”
events “started”, “passed”, “skipped”, “failed”, “standardOut”, “standardError”
displayGranularity = 0
}
doFirst {
//Pass all system properties to the Test JVM
systemProperties = System.getProperties()
String command = System.getProperty(“java.home”) + “/bin/java”
jettyProcess = new ProcessBuilder(command ,
“-jar” , “-D@environment=local”, “-D@appId=myapp”, (project(":").libsDir.toString() + “/” + project.archiveName) )
.inheritIO()
.directory( new File(".")).start()
logger.debug( systemProperties.toString() )
systemProperty ‘@appId’ , ‘myapp’
systemProperty ‘@environment’ , ‘local’ //For Archaius
sleep(2000) //TODO Implement polling and Throw Exception instead of Sleep.
}
doLast{
if ( jettyProcess != null ) {
jettyProcess.destroy()
}
} }
Please let me know if this is a good approach.