Resolving dependency configuration 'testRuntimeOnly' is not allowed

Failure 1 of 1

After upgrading to Gradle 7 and replacing testRuntime with testRuntimeOnly in the following lines in my build.gradle file:
I am getting the following error:
Resolving dependency configuration ‘testRuntimeOnly’ is not allowed as it is defined as ‘canBeResolved=false’. Instead, a resolvable (‘canBeResolved=true’) dependency configuration that extends ‘testRuntimeOnly’ should be resolved. “
Any idea how to fix this?

Could not determine the dependencies of task ‘:integrationTest’.

Resolving dependency configuration ‘testRuntimeOnly’ is not allowed as it is defined as ‘canBeResolved=false’. Instead, a resolvable (‘canBeResolved=true’) dependency configuration that extends ‘testRuntimeOnly’ should be resolved.

Exception

org.gradle.api.internal.tasks.TaskDependencyResolveException: Could not determine the dependencies of task ‘:integrationTest’.

at org.gradle.api.internal.tasks.CachingTaskDependencyResolveContext.getDependencies(CachingTaskDependencyResolveContext.java:71)
•••
Caused by: java.lang.IllegalStateException: Resolving dependency configuration ‘testRuntimeOnly’ is not allowed as it is defined as ‘canBeResolved=false’.
Instead, a resolvable (‘canBeResolved=true’) dependency configuration that extends ‘testRuntimeOnly’ should be resolved.

How are you using the testRuntimeOnly configuration? I suspect that you’re trying to use it to configure the classpath of your integrationTest task. If so, use the testRuntimeClasspath configuration instead. Or use a sourceSet’s runtimeClasspath, similar to what’s shown in Testing in Java & JVM projects

Hi, Thank you.
Correct, but the following step is necessary because of duplicate copiesThank you. It worked. I have another question. I have server.xml for Liberty configuration. For my integration test. I expect this code within Gradle (7.1.1) to copy server.xml for Server INstanz. But it doesn’t happen.

// Tell the liberty plugin about the server to use in the test

liberty {
install {
runtimeUrl = ‘https://public.dhe.ibm.com/ibmdl/export/pub/software/websphere/wasdev/downloads/wlp/19.0.0.9/wlp-kernel-19.0.0.9.zip
}
server {

	features {
        acceptLicense = true
    }
	
	
	def configFile = file('src/integrationTest/resources/test-server.xml')
	
	bootstrapProperties = ['appLocation':war.archiveName]
	def apps = [war]
	
	// The name of the server instance to create. The default value is defaultServer.
	name = 'integrationTestServer'
	
	// Inline List of jvm options that is written to the jvm.
	// options file in the server directory. These properties take precedence over a specified jvm.options file.
	jvmOptions = ["-javaagent:${projectDir}/src/integrationTest/resources/jacocoagent.jar=destfile=${project.buildDir}/jacoco/jacoco-it.exec,append=false,includes=${gradle.ext.itIncludePath}"]
}

}


with this def configFile = file(‘src/integrationTest/resources/test-server.xml’)

I expect test-server.xml to be copied as server.xml for the server instance “integrationServer”. But unfortunately no. Why?

What are you expecting will do the copy?

def configFile = file('src/integrationTest/resources/test-server.xml')

This is creating a new File variable named configFile, but nothing is done with the value assigned to it.

Hi Chris,

thank you.

That was a problem or a change in Liberty Server from IBM. I read the IBM site and got through
// Configuration files and folder structure will be copied to the server instance.
configDirectory = file (‘src / integrationTest / resources’)

reconfigured. It is ok now.

Hi Chris,

I have a little problem, when executing Gradle 7.1.1 in my dependencies I have a dependency from a local service as xxx.jar, why if ch was executing build locally, does Gradle not find the jar file?

Canyou help me, please. Thank you

Farhad