Skip to content

Commit 663c939

Browse files
committed
Added basic support for Gradle incremental tasks (issue #10).
When Gradle detects there were no changes to the input files, it won't call Clojure compile task at all.
1 parent 596daf1 commit 663c939

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/main/kotlin/cursive/ClojurePlugin.kt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import org.gradle.api.plugins.JavaPluginConvention
3434
import org.gradle.api.tasks.SourceSet
3535
import org.gradle.api.tasks.TaskAction
3636
import org.gradle.api.tasks.compile.AbstractCompile
37+
import org.gradle.api.tasks.incremental.IncrementalTaskInputs
3738
import org.gradle.process.JavaForkOptions
3839
import org.gradle.process.internal.DefaultJavaForkOptions
3940
import org.gradle.process.internal.ExecException
@@ -65,7 +66,6 @@ class ClojurePlugin : Plugin<Project> {
6566
conventionMapping.map("classpath", {
6667
mainSourceSet.compileClasspath
6768
.plus(SimpleFileCollection(mainSourceSet.allSource.srcDirs))
68-
.plus(SimpleFileCollection(mainSourceSet.output.classesDir))
6969
})
7070
conventionMapping.map("namespaces", {
7171
mainCompileTask.findNamespaces()
@@ -205,6 +205,10 @@ open class ClojureCompiler @Inject constructor(val fileResolver: FileResolver) :
205205
}
206206

207207
@TaskAction
208+
fun compile(inputs: IncrementalTaskInputs) {
209+
compile()
210+
}
211+
208212
override fun compile() {
209213
logger.info("Starting ClojureCompiler task")
210214

@@ -298,7 +302,7 @@ open class ClojureCompiler @Inject constructor(val fileResolver: FileResolver) :
298302
val exec = JavaExecHandleBuilder(fileResolver)
299303
copyTo(exec)
300304
exec.main = "clojure.main"
301-
exec.classpath = classpath
305+
exec.classpath = classpath.plus(SimpleFileCollection(destinationDir))
302306
exec.setArgs(listOf("-i", file.canonicalPath))
303307
exec.defaultCharacterEncoding = "UTF8"
304308

0 commit comments

Comments
 (0)