Skip to content

Commit

Permalink
Added basic support for Gradle incremental tasks (issue cursive-ide#10).
Browse files Browse the repository at this point in the history
When Gradle detects there were no changes to the input files, it won't call Clojure compile task at all.
  • Loading branch information
pbzdyl committed Nov 25, 2016
1 parent 596daf1 commit 663c939
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/main/kotlin/cursive/ClojurePlugin.kt
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import org.gradle.api.plugins.JavaPluginConvention
import org.gradle.api.tasks.SourceSet
import org.gradle.api.tasks.TaskAction
import org.gradle.api.tasks.compile.AbstractCompile
import org.gradle.api.tasks.incremental.IncrementalTaskInputs
import org.gradle.process.JavaForkOptions
import org.gradle.process.internal.DefaultJavaForkOptions
import org.gradle.process.internal.ExecException
Expand Down Expand Up @@ -65,7 +66,6 @@ class ClojurePlugin : Plugin<Project> {
conventionMapping.map("classpath", {
mainSourceSet.compileClasspath
.plus(SimpleFileCollection(mainSourceSet.allSource.srcDirs))
.plus(SimpleFileCollection(mainSourceSet.output.classesDir))
})
conventionMapping.map("namespaces", {
mainCompileTask.findNamespaces()
Expand Down Expand Up @@ -205,6 +205,10 @@ open class ClojureCompiler @Inject constructor(val fileResolver: FileResolver) :
}

@TaskAction
fun compile(inputs: IncrementalTaskInputs) {
compile()
}

override fun compile() {
logger.info("Starting ClojureCompiler task")

Expand Down Expand Up @@ -298,7 +302,7 @@ open class ClojureCompiler @Inject constructor(val fileResolver: FileResolver) :
val exec = JavaExecHandleBuilder(fileResolver)
copyTo(exec)
exec.main = "clojure.main"
exec.classpath = classpath
exec.classpath = classpath.plus(SimpleFileCollection(destinationDir))
exec.setArgs(listOf("-i", file.canonicalPath))
exec.defaultCharacterEncoding = "UTF8"

Expand Down

0 comments on commit 663c939

Please sign in to comment.