Cannot infer Groovy class path because no Groovy Jar


#1

Getting this error when running custom task “integTest”

FAILURE: Build failed with an exception.

  • What went wrong:
    Cannot infer Groovy class path because no Groovy Jar was found on class path: file collection

The integration tests all run fine individually, it’s just that I can’t run them all because this task does not seem to be getting the right classpath.

Any insight would be appreciated.

Here is the relevant configuration:

sourceSets {
integTest {
groovy {
compileClasspath += main.output + test.output
runtimeClasspath += main.output + test.output
srcDir file(‘src/integTest/groovy’)
}
resources.srcDir file(‘src/integTest/resources’)
}
}

task integTest(type: Test) {
testClassesDir = sourceSets.integTest.output.classesDir
classpath = sourceSets.integTest.runtimeClasspath
}


(René Groeschke) #2

How do you invoke them succesfully individually? Via commandline or via IDE? I assume this only works in the ide and your classpath is not configured correctly within Gradle. Can you provide further information about the failing build? maybe share a build scan (see https://scans.gradle.com) ? that would make diagnosing your build much easier. Most likely you havn’t declared a dependency on groovy for your integration tests.


#3

It fails regardless of which way i execute (IntelliJ and CLI). I’ve tried running gradle integTest --debug and --info, and neither makes it easy to see what the reconciled classpath is (after processing all the gradle configurations). Am i missing it?


#4

I added this to the build.gradle file and it seems to be working now:

configurations {
    integTestCompile.extendsFrom testCompile
    integTestRuntime.extendsFrom testRuntime
}