diff --git a/gradle/validation/jar-checks.gradle b/gradle/validation/jar-checks.gradle index d21cae30c02..6e1f97aea57 100644 --- a/gradle/validation/jar-checks.gradle +++ b/gradle/validation/jar-checks.gradle @@ -333,9 +333,13 @@ configure([project(":solr"), project(":lucene"),]) { } doFirst { - def allReferenced = validationTasks.collectMany { task -> - task.project.jarInfos.collectMany { it.referencedFiles } - }.collect { it.toString() } + def allReferenced = validationTasks + // Only collect for enabled tasks: https://issues.apache.org/jira/browse/LUCENE-9780 + .findAll { it.enabled } + .collectMany { task -> + task.project.jarInfos.collectMany { it.referencedFiles } + } + .collect { it.toString() } def patterns = ext.exclude def allExisting = fileTree(licensesDir, {