From cc9ca97a346ab5e40a3852768dd2971d788b4865 Mon Sep 17 00:00:00 2001 From: Roberto Perez Alcolea Date: Wed, 22 Jul 2026 19:08:35 -0700 Subject: [PATCH] Fix ClojureCompile including non-Clojure files as source Config-cache support (14.0.2) replaced the filtered SourceDirectorySet (set.clojure, restricted to **/*.clj, **/*.cljs, **/*.cljc) with a raw project.file(src/.../clojure) to avoid serializing the SourceSet object graph. SourceDirectoryTask.getSource() then turned that directory into an unfiltered FileTree, so any non-Clojure file sitting in the source directory (e.g. a README.md) got passed to the Clojure compiler and broke the build. Restore the extension filter in SourceDirectoryTask.getSource() so only Clojure files are treated as compile/test/run/doc source, while keeping srcDirs as plain File objects for classpath purposes and configuration-cache compatibility. --- gradle.lockfile | 12 ++++---- .../utils/tasks/SourceDirectoryTask.groovy | 4 ++- ...nNebulaClojurePluginIntegrationSpec.groovy | 30 +++++++++++++++++++ 3 files changed, 39 insertions(+), 7 deletions(-) diff --git a/gradle.lockfile b/gradle.lockfile index ef28304..b941e60 100644 --- a/gradle.lockfile +++ b/gradle.lockfile @@ -6,8 +6,8 @@ com.jcraft:jzlib:1.1.2=integTestRuntimeClasspath,testRuntimeClasspath com.netflix.nebula:gradle-contacts-plugin:8.0.0=integTestRuntimeClasspath,testRuntimeClasspath com.netflix.nebula:gradle-info-plugin:16.0.0=integTestRuntimeClasspath,testRuntimeClasspath com.netflix.nebula:nebula-gradle-interop:2.3.0=integTestRuntimeClasspath,testRuntimeClasspath -com.netflix.nebula:nebula-publishing-plugin:23.0.0=integTestCompileClasspath,integTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath -com.netflix.nebula:nebula-test:11.12.0=integTestCompileClasspath,integTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath +com.netflix.nebula:nebula-publishing-plugin:23.1.0=integTestCompileClasspath,integTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath +com.netflix.nebula:nebula-test:12.5.0=integTestCompileClasspath,integTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath com.perforce:p4java:2015.2.1365273=integTestRuntimeClasspath,testRuntimeClasspath io.leangen.geantyref:geantyref:1.3.16=integTestRuntimeClasspath,testRuntimeClasspath junit:junit:4.13.2=integTestCompileClasspath,integTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath @@ -29,10 +29,10 @@ org.hamcrest:hamcrest:3.0=integTestCompileClasspath,integTestRuntimeClasspath,te org.jetbrains.kotlin:kotlin-stdlib:2.1.0=integTestRuntimeClasspath,testRuntimeClasspath org.jetbrains:annotations:13.0=integTestRuntimeClasspath,testRuntimeClasspath org.jspecify:jspecify:1.0.0=integTestCompileClasspath,integTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath -org.junit.platform:junit-platform-commons:1.14.3=integTestCompileClasspath,integTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath -org.junit.platform:junit-platform-engine:1.14.3=integTestCompileClasspath,integTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath -org.junit.platform:junit-platform-launcher:1.14.3=integTestCompileClasspath,integTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath -org.junit:junit-bom:5.14.3=integTestCompileClasspath,integTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath +org.junit.platform:junit-platform-commons:1.14.4=integTestCompileClasspath,integTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath +org.junit.platform:junit-platform-engine:1.14.4=integTestCompileClasspath,integTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath +org.junit.platform:junit-platform-launcher:1.14.4=integTestCompileClasspath,integTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath +org.junit:junit-bom:5.14.4=integTestCompileClasspath,integTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath org.objenesis:objenesis:2.4=integTestRuntimeClasspath,testRuntimeClasspath org.opentest4j:opentest4j:1.3.0=integTestCompileClasspath,integTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath org.spockframework:spock-bom:2.4-groovy-4.0=integTestCompileClasspath,integTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath diff --git a/src/main/groovy/nebula/plugin/utils/tasks/SourceDirectoryTask.groovy b/src/main/groovy/nebula/plugin/utils/tasks/SourceDirectoryTask.groovy index 706a647..94a143f 100644 --- a/src/main/groovy/nebula/plugin/utils/tasks/SourceDirectoryTask.groovy +++ b/src/main/groovy/nebula/plugin/utils/tasks/SourceDirectoryTask.groovy @@ -156,6 +156,8 @@ class SourceDirectoryTask extends DefaultTask { @IgnoreEmptyDirectories @PathSensitive(PathSensitivity.RELATIVE) def FileTree getSource() { - objectFactory.fileCollection().from(srcDirs).asFileTree + objectFactory.fileCollection().from(srcDirs).asFileTree.matching { + include "**/*.clj", "**/*.cljs", "**/*.cljc" + } } } diff --git a/src/test/groovy/nebula/plugin/clojure/NoToolchainNebulaClojurePluginIntegrationSpec.groovy b/src/test/groovy/nebula/plugin/clojure/NoToolchainNebulaClojurePluginIntegrationSpec.groovy index f840e9b..bfb897c 100644 --- a/src/test/groovy/nebula/plugin/clojure/NoToolchainNebulaClojurePluginIntegrationSpec.groovy +++ b/src/test/groovy/nebula/plugin/clojure/NoToolchainNebulaClojurePluginIntegrationSpec.groovy @@ -40,6 +40,36 @@ class NoToolchainNebulaClojurePluginIntegrationSpec extends BaseIntegrationTestK new File(projectDir, "//build/classes/java/main/test/nebula/app.clj").exists() } + def 'can compile clojure when non-clojure files are present in the source directory'() { + buildFile << '''\ + plugins { + id 'com.netflix.nebula.clojure' + } + + repositories { mavenCentral() } + + dependencies { + implementation 'org.clojure:clojure:1.10.3' + } + '''.stripIndent() + + settingsFile << 'rootProject.name="can-compile-clojure-with-readme"' + + def clojurefiles = new File(projectDir, 'src/main/clojure/test/nebula') + clojurefiles.mkdirs() + new File(clojurefiles, 'app.clj').text = APP_CLJ + new File(clojurefiles, 'README.md').text = '# Not a clojure file' + + when: + def result = runTasks('build', '-s') + + then: + noExceptionThrown() + + and: + new File(projectDir, "//build/classes/java/main/test/nebula/app.clj").exists() + } + def 'can compile clojure with aotCompile'() { buildFile << '''\ plugins {