Unable to start jboss using gradle test task


(kikimoreva) #1

Hey Gradle Community,

Trying to convert a legacy maven-arquillian-jboss testing project to gradle-arquillian-jboss project.
My compile configuration looks like this:

compile (group: ‘org.jboss.as’, name: ‘jboss-as-arquillian-container-managed’, version: ‘7.2.0.Final’)
compile (group: ‘junit’, name: ‘junit’, version: ‘4.12’)
compile (group: ‘org.jboss.spec’, name: ‘jboss-javaee-6.0’, version: ‘1.0.0.Final’)
compile (group: ‘org.jboss.arquillian’, name: ‘arquillian-bom’, version: ‘1.1.8.Final’)
compile (group: ‘org.jboss.arquillian.junit’, name: ‘arquillian-junit-container’, version: ‘1.1.11.Final’)
compile (group: ‘org.jboss.ejb3’, name: ‘jboss-ejb3-ext-api’, version: ‘2.1.0’)
compile (group: ‘org.jboss.arquillian.protocol’, name: ‘arquillian-protocol-servlet’, version: ‘1.1.1.Final’)

My test task definition looks like this:

test {
environment “JBOSS_HOME”, resouceAdapterTestingBuildDir + jBossEapLabel
environment “JAVA_HOME”, System.getProperty(“JAVA7_HOME”, “C:/Program Files/Java/jdk1.7.0_79”)
jvmArgs = [’-Xrunjdwp:transport=dt_socket,address=8181,server=y,suspend=n’]
systemProperties =
[‘arquillian.debug’ :‘false’,
‘javaHome’ :System.getProperty(“JAVA7_HOME”, “C:/Program Files/Java/jdk1.7.0_79”),
‘jbossHome’:resouceAdapterTestingBuildDir + jBossEapLabel,
‘arquillian.launch’:‘jbossas-managed-jenkins’]
}

When I run ‘gradlew build -x test idea’ and import the newly build project into idea, all tests can be successfully ran from the IDE. Just perfect.

BUT if I try to the same thing using gradle task ‘gradlew test’, I run into problems -> arquillian is unable to start jboss.

My assumption is this happens because of numerous process builders that take place underneath… but I am not sure.
I tried tricking gradle by adding a wicked dependency between tasks (creating an exec task that invokes internally the test task) and now I see that jboss process is comming up:

task myTests (type: Test) {
environment “JBOSS_HOME”, resouceAdapterTestingBuildDir + jBossEapLabel
environment “JAVA_HOME”, System.getProperty(“JAVA7_HOME”, “C:/Program Files/Java/jdk1.7.0_79”)
jvmArgs = [’-Xrunjdwp:transport=dt_socket,address=8181,server=y,suspend=n’]
systemProperties =
[‘arquillian.debug’ :‘false’,
‘javaHome’ :System.getProperty(“JAVA7_HOME”, “C:/Program Files/Java/jdk1.7.0_79”),
‘jbossHome’:resouceAdapterTestingBuildDir + jBossEapLabel,
‘arquillian.launch’:‘jbossas-managed-jenkins’]
}
}
task myExecute (type: Exec) {
tasks.myTests.execute()
}

but that ends up with java.lang.IllegalStateException: Cannot call TaskInputs.source(Object) on task ‘:test/resource-adapter-testing:myTests’ after task has started execution.

Any idea how to fix this situation? It is clear that gradle test task is not running my setup properly…