{"record":{"id":"3d7fccf94903caa8","repo":"gradle/gradle","slug":"taskname-groovyclasspath-must-not-be-empty-if","errorCode":null,"errorMessage":"'{taskName}.groovyClasspath' must not be empty. If a Groovy compile dependency is provided, the 'groovy-base' plugin will attempt to configure 'groovyClasspath' automatically. Alternatively, you may configure 'groovyClasspath' explicitly.","messagePattern":"'(.+?)\\.groovyClasspath' must not be empty\\. If a Groovy compile dependency is provided, the 'groovy-base' plugin will attempt to configure 'groovyClasspath' automatically\\. Alternatively, you may configure 'groovyClasspath' explicitly\\.","errorType":"exception","errorClass":"InvalidUserDataException","httpStatus":null,"severity":"error","filePath":"platforms/jvm/language-groovy/src/main/java/org/gradle/api/tasks/compile/GroovyCompile.java","lineNumber":288,"sourceCode":"        if (sourceCompatibility == null) {\n            sourceCompatibility = toolchainVersion;\n        }\n        String targetCompatibility = getTargetCompatibility();\n        if (targetCompatibility == null) {\n            targetCompatibility = sourceCompatibility;\n        }\n\n        spec.setSourceCompatibility(sourceCompatibility);\n        spec.setTargetCompatibility(targetCompatibility);\n    }\n\n    private JavaInstallationMetadata getToolchain() {\n        return getJavaLauncher().map(JavaLauncher::getMetadata).get();\n    }\n\n    private void checkGroovyClasspathIsNonEmpty() {\n        if (getGroovyClasspath().isEmpty()) {\n            throw new InvalidUserDataException(\"'\" + getName() + \".groovyClasspath' must not be empty. If a Groovy compile dependency is provided, \"\n                + \"the 'groovy-base' plugin will attempt to configure 'groovyClasspath' automatically. Alternatively, you may configure 'groovyClasspath' explicitly.\");\n        }\n    }\n\n    /**\n     * We need to track the Java version of the JVM the Groovy compiler is running on, since the Groovy compiler produces different results depending on it.\n     *\n     * This should be replaced by a property on the Groovy toolchain as soon as we model these.\n     *\n     * @since 4.0\n     */\n    @Input\n    protected String getGroovyCompilerJvmVersion() {\n        return getToolchain().getLanguageVersion().toString();\n    }\n\n    /**\n     * {@inheritDoc}","sourceCodeStart":270,"sourceCodeEnd":306,"githubUrl":"https://github.com/gradle/gradle/blob/534f27719b66953f95cc907aae7f2c1b12f5482d/platforms/jvm/language-groovy/src/main/java/org/gradle/api/tasks/compile/GroovyCompile.java#L270-L306","documentation":"GroovyCompile needs the Groovy distribution (compiler + runtime jars) on groovyClasspath to run. The groovy-base plugin normally infers it from the 'groovy' configuration; checkGroovyClasspathIsNonEmpty throws InvalidUserDataException when that inference produced an empty classpath at execution time.","triggerScenarios":"Running a GroovyCompile task when groovyClasspath resolves empty: no dependency on the groovy configuration, a manually created GroovyCompile task never given groovyClasspath, or build logic that cleared/replaced the groovy configuration after evaluation.","commonSituations":"Applying the groovy plugin but declaring groovy only as implementation from a repository that failed; hand-rolled tasks.withType(GroovyCompile) tasks in a plugin; excluding the groovy dependency for artifact-size reasons.","solutions":["Declare a Groovy dependency: dependencies { groovy 'org.apache.groovy:groovy:4.0.21' } or groovy localGroovy()","Or configure the task directly: tasks.named('compileGroovy') { groovyClasspath = files('/path/to/groovy-all.jar') }","Check nothing removes dependencies from the groovy configuration (configuration filtering, resolutionStrategy overrides)"],"exampleFix":"// before\nplugins { id 'groovy' } // no groovy dependency -> empty groovyClasspath\n// after\nplugins { id 'groovy' }\ndependencies { groovy localGroovy() } // or org.apache.groovy:groovy:4.0.21","handlingStrategy":"validation","validationCode":"afterEvaluate {\n  def groovyCfg = configurations.findByName('groovy')\n  if (groovyCfg == null || groovyCfg.dependencies.empty) {\n    dependencies.add('groovy', dependencies.localGroovy())\n  }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always declare a groovy dependency when applying the groovy plugin","For manually created GroovyCompile tasks, set groovyClasspath explicitly","Add a convention plugin that guarantees the groovy configuration is populated"],"tags":["groovy","classpath","missing-dependency","build-configuration"],"backgroundTag":"missing-dependency","analyzedSha":"534f27719b66953f95cc907aae7f2c1b12f5482d","analyzedAt":"2026-08-22T08:09:12.375Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}